Open SiteSearch 4.1.1
Final

ORG.oclc.fmts
Class RuleSpec

java.lang.Object
  |
  +--ORG.oclc.fmts.RuleSpec

public class RuleSpec
extends Object

The RuleSpec class defines a formatting rule including the class to execute for the rule, the data field to format, and the displayname for the rule.

The data fields to format are defined in units in the field*= variable in the formatting configuration file. Each unit can be comprised of multiple fields and multiple instructions for formatting the unit.

The syntax for describing the fields in a formatting unit is as follows:
Note: For purposes of clarity the continuation characters '\'+newline is used, but is not part of the syntax.

field* = (optional field modifiers)|\
(optional subfield modifiers);\
(optional subfield modifiers);\

where:

:
a list of record fields where full tag paths and wildcards are valid

(optional field modifiers)
lab=''
sep=''
trl=''
idx='' to indicate that a QUERY anchor will be built for the combined string that the subfield specification builds.
ind1=''
ind2=''
repeatsfld='' to indicate that each time this subfield is encountered, the field separator is inserted
dataordered or formatordered
Note: For line breaks use the keyword: BREAK for all labels, separators, and trailers. The software will replace it with the correct break characters for each specified format based on a specification outside of the this class.

|
the | delimits fields from subfields

a list of record subfields where full tag paths and wildcards are valid. Marc tags a-z are also accepted.

(optional field modifiers)
lab=''
sep=''
trl=''
anchorsep=''
dataordered or formatordered
combine (to indicate combine all subfields)
idx='' (indicates there will be a QUERY anchor built)

;
the ; delimits multiple subfield field specifications. The formatting unit fields will be evaluated in the order of specification.

Example Rule Specifications:

[Title] class = ORG.oclc.fmts.rules.AddRecordData field* = 245|a displayname = Title [Subject] class = ORG.oclc.fmts.rules.AddRecordData displayname = Subject field* = 650,651,652(sep='BREAK',repeatsfld='a',ind1='0',ind2='2',idx='sh=')| \
a-b(combine,dataordered); \
c-w(sep=' ',dataordered); \
x,y,z(sep=' -- ',dataordered)

field* = 690(sep='BREAK',repeatsfld='a')| \
a,b(idx='sh=',combine);x,y,z(idx='sh=',sep=' -- ',formatordered)

Results in:

[Title]
The formatting rule ORG.oclc.fmts.rules.AddRecordData is used to create output with a label 'title' gets the data from field '245' subfield 'a'

[Subject]
The formatting rule ORG.oclc.fmts.rules.AddRecordData is used to create output with a label 'Subject'
Field 650, 651, 652: repeated fields separated by a line break and Only fields with indicators matching '02' are kept. The whole subfield string generated is used to create a query anchor in the sh= index
Subfields a-b(1-2) combined and appended to the subfield string. When subfield 'a' occurs, a line break is inserted.
Subfields c-w(3-23) appended to the subfield with a separator of space.
Subfields x,y,z(24,25,26) appended to the subfield and a separator of ' -- ' is used.
Field 690: repeated fields separated by a line break and trailed by a line break.
Subfields a-b(1,2) combined to make a query anchor on the sh= index. When subfield 'a' occurs, a line break is inserted.
Subfields x-z(24,25,26) are located and each subfield becomes a query anchor in the sh= index. The anchors are separated by a ' -- '.

The default values for each field definition are defined in the FieldData class.

See Also:
RulesBasedDisplayGenerator, FieldData

Field Summary
 FieldData[] data
          FieldData array object containing the fields and instructions for formatting the fields.
 String label
          String data type containing the display label for the unit.
 String name
          String data type containing the named label for the unit.
 DataPairs ruleParameters
          DataPairs object containing any additional parameters needed for the rule.
 
Method Summary
 DisplayRule getRule()
          Retrieves the DisplayRule object.
 String getRuleParm(String parmName)
          Retrieves the rule parameter value for the input parameter name and returns an empty string if not found.
 String getRuleParm(String parmName, String defaultVal)
          Retrieves the rule parameter value for the input parameter name and returns the input defaultVal String if not located.
 String toString()
          Generates a String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public String name
String data type containing the named label for the unit.

label

public String label
String data type containing the display label for the unit.

data

public FieldData[] data
FieldData array object containing the fields and instructions for formatting the fields.

ruleParameters

public DataPairs ruleParameters
DataPairs object containing any additional parameters needed for the rule.
Method Detail

getRuleParm

public final String getRuleParm(String parmName)
Retrieves the rule parameter value for the input parameter name and returns an empty string if not found.
Parameters:
parmName - the name of the rule parameter
Returns:
String

getRuleParm

public final String getRuleParm(String parmName,
                                String defaultVal)
Retrieves the rule parameter value for the input parameter name and returns the input defaultVal String if not located.
Parameters:
parmName - the name of the rule parameter
defaultVal - the default value if the parm is not found
Returns:
String

toString

public String toString()
Generates a String representation of the object.
Returns:
String
Overrides:
toString in class Object

getRule

public DisplayRule getRule()
Retrieves the DisplayRule object.
Returns:
DisplayRule

Open SiteSearch 4.1.1
Final