org.jafer.record
Class Field

java.lang.Object
  extended by org.jafer.record.Field

public class Field
extends java.lang.Object


Field Summary
private  org.w3c.dom.Node recordFragment
           
private  org.w3c.dom.Node recordRoot
           
 
Constructor Summary
Field(org.w3c.dom.Node recordRoot, org.w3c.dom.Node recordFragment)
           
 
Method Summary
private  boolean checkAttributeValues(org.w3c.dom.Element element, java.lang.String[] attributeProfile)
           
 Field[] get(java.lang.String fieldName)
           
 Field[] get(java.lang.String fieldName, java.lang.String[] attributeProfile)
           
 Field[] get(java.lang.String fieldName, java.lang.String attributeName, java.lang.String attributeValue)
           
 java.lang.String getAllFieldData(java.lang.String delimiter)
          Returns the textual content of a field and all its subfields, each separated by the delimiter/s supplied (which can be an empty string.)
private  java.lang.String getData(org.w3c.dom.NodeList nodeList)
           
 java.lang.String getDataBaseName()
           
 java.lang.String getFieldData(java.lang.String field)
          Deprecated. Use get(fieldName) or getFirst(fieldName) with getAllFieldData(delimiter) to produce a more controllable result.
 java.lang.String getFieldData(java.lang.String field, java.lang.String attributeName, java.lang.String attributeValue)
           
 Field getFirst(java.lang.String fieldName)
          Returns the first occurrence of the named field.
 Field getFirst(java.lang.String fieldName, java.lang.String[] attributeProfile)
          Returns the first occurrence of the named field with the given attributes and values.
 Field getFirst(java.lang.String fieldName, java.lang.String attributeName, java.lang.String attributeValue)
          Returns the first occurrence of the named field with the given attribute name and value.
 org.w3c.dom.NodeList getList(java.lang.String field)
           
 java.lang.String getName()
           
private  org.w3c.dom.NodeList getNamedChildren(java.lang.String name, java.lang.String[] attributeProfile, org.w3c.dom.Node startNode, boolean recursive)
          Returns a NodeList of all ancestor nodes with the name/s and attribute value/s supplied in attributeProfile[].
 java.lang.String getRecordSchema()
           
 java.lang.String getRecordSyntax()
           
 org.w3c.dom.Node getRoot()
           
 java.lang.String getValue()
          Returns the textual content of the field.
 org.w3c.dom.Node getXML()
           
private  Field[] toFieldArray(org.w3c.dom.NodeList nodeList)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

recordRoot

private org.w3c.dom.Node recordRoot

recordFragment

private org.w3c.dom.Node recordFragment
Constructor Detail

Field

public Field(org.w3c.dom.Node recordRoot,
             org.w3c.dom.Node recordFragment)
Method Detail

getRoot

public org.w3c.dom.Node getRoot()

getXML

public org.w3c.dom.Node getXML()

getRecordSyntax

public java.lang.String getRecordSyntax()

getDataBaseName

public java.lang.String getDataBaseName()

getRecordSchema

public java.lang.String getRecordSchema()

getValue

public java.lang.String getValue()
Returns the textual content of the field. (Doesn't include children/subfield content.)

Returns:
the textual content of the field, or an empty string.

getName

public java.lang.String getName()

get

public Field[] get(java.lang.String fieldName)

get

public Field[] get(java.lang.String fieldName,
                   java.lang.String attributeName,
                   java.lang.String attributeValue)

get

public Field[] get(java.lang.String fieldName,
                   java.lang.String[] attributeProfile)

getFirst

public Field getFirst(java.lang.String fieldName)
Returns the first occurrence of the named field.

Searches by level-order traversal, i.e. all fields at one level before their children.

Parameters:
fieldName - the name of the field to find.
Returns:
the first occurrence of the named field, or a new null Field.

getFirst

public Field getFirst(java.lang.String fieldName,
                      java.lang.String attributeName,
                      java.lang.String attributeValue)
Returns the first occurrence of the named field with the given attribute name and value.

Searches by level-order traversal, i.e. all fields at one level before their children.

Parameters:
fieldName - the name of the field to find.
attributeName - the name of the required attribute.
attributeValue - the required value of the attribute.
Returns:
the first matching occurrence of the field, or a new null Field.

getFirst

public Field getFirst(java.lang.String fieldName,
                      java.lang.String[] attributeProfile)
Returns the first occurrence of the named field with the given attributes and values.

(The attributeProfile param is a String[] containing 1 or more attribute names and the required attribute values, in the format: "nameA", "valueA", "nameB", "valueB"...)

Searches by level-order traversal, i.e. all fields at one level before their children.

Parameters:
fieldName - the name of the field to find.
attributeProfile - an array of attribute name/ value pairs.
Returns:
the first matching occurrence of the field, or a new null Field.

getAllFieldData

public java.lang.String getAllFieldData(java.lang.String delimiter)
Returns the textual content of a field and all its subfields, each separated by the delimiter/s supplied (which can be an empty string.)

Suggested use for convenience: getFirst("name").getAllFieldData(", ") which would return a concatenation of the subfield data of the first element found, separated by a comma and a space.

If only one subfield is present, no delimiter is applied.

Parameters:
delimiter - the string to use as a delimiter between field and subfield contents.
Returns:
a concatenated string of the textual content of a field and all its subfields content, or an empty string.

getNamedChildren

private org.w3c.dom.NodeList getNamedChildren(java.lang.String name,
                                              java.lang.String[] attributeProfile,
                                              org.w3c.dom.Node startNode,
                                              boolean recursive)
Returns a NodeList of all ancestor nodes with the name/s and attribute value/s supplied in attributeProfile[]. Searches by level-order traversal, i.e. all sibling children of the start node before their children.

Parameters:
name - the name of the node/s to search for.
attributeProfile - the names and values of the required attributes.
startNode - the node whose children should be searched.
recursive - when set to false, processing will halt when the first matching node is found.
Returns:
NodeList of all ancestor nodes with this name and attribute values, or an empty NodeList.

checkAttributeValues

private boolean checkAttributeValues(org.w3c.dom.Element element,
                                     java.lang.String[] attributeProfile)

toFieldArray

private Field[] toFieldArray(org.w3c.dom.NodeList nodeList)

getFieldData

public java.lang.String getFieldData(java.lang.String field)
Deprecated. Use get(fieldName) or getFirst(fieldName) with getAllFieldData(delimiter) to produce a more controllable result.

Concatenates the textual content of all fields with the given name, and all their subfields, separated by a space.

If no field is found, an empty String is returned.

Parameters:
field - the field name to search for.
Returns:
a concatenated string of the textual content of all fields with the given name and their subfields content, or an empty string.

getFieldData

public java.lang.String getFieldData(java.lang.String field,
                                     java.lang.String attributeName,
                                     java.lang.String attributeValue)

getData

private java.lang.String getData(org.w3c.dom.NodeList nodeList)

getList

public org.w3c.dom.NodeList getList(java.lang.String field)