atg.endeca.index.record
Class Records

java.lang.Object
  extended by atg.endeca.index.record.Records

public class Records
extends java.lang.Object

Represents a list of records. In addition, supports having a "name" property name, that can uniquely identify a given record.

Created: November 16 2011


Nested Class Summary
static class Records.ExposedIndentXMLWriter
          An XMLWriter subclass that exposes a writeIndent() method.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string from source code control system.
protected  java.util.List<Record> mRecords
          Our list of records.
 
Constructor Summary
Records()
           
 
Method Summary
 void addRecord(Record pRecord)
          Add the specified record.
protected  Records.ExposedIndentXMLWriter createXMLWriter()
          Create our XMLWriter.
 boolean exactlyEquals(Records pRecords)
          Only equal if we have the same records in the same order.
 java.lang.String getAsXMLString(ApplicationLogging pLogging)
          Get our records as an XMLString.
protected  java.lang.String getNameOfRecord(Record pRecord)
          Get the name of the record, if any.
 java.lang.String getNamePropertyName()
          Returns property namePropertyName.
 Record getOnlyRecordByName(java.lang.String pName)
          Return the only record with the give name.
 java.util.List<Record> getRecords()
          Return the list of all records (with an unmodifiable copy.
 java.util.List<Record> getRecordsByName(java.lang.String pName)
          Get the list of records with the specified name property (as defined by the propertyNameProperty).*
 java.util.List<Record> getRecordsWithMatchingProperty(java.lang.String pPropertyName, java.lang.String pPropertyValue)
          Return all the records with the specified matching property.
 void readFromXML(java.io.InputStream pInputStream)
          Read from an XML file.
 void removeRecord(Record pRecord)
          Remove the specified record.
 void setNamePropertyName(java.lang.String pNamePropertyName)
          Sets property namePropertyName.
 java.lang.String toString()
           
 void writeAsXML(java.io.Writer pWriter, boolean pWriteXMLDeclaration, boolean pPrettyPrint, boolean pIncludeStandalone)
          Write the record out as XML.
protected  void writeXMLDeclaration(java.io.Writer pWriter, java.lang.String pXMLVersion, java.lang.String pEncoding)
          Write the XML Declaration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string from source code control system.

See Also:
Constant Field Values

mRecords

protected java.util.List<Record> mRecords
Our list of records.

Constructor Detail

Records

public Records()
Method Detail

setNamePropertyName

public void setNamePropertyName(java.lang.String pNamePropertyName)
Sets property namePropertyName. The property name of the name property. Can be null if there is no name property.


getNamePropertyName

public java.lang.String getNamePropertyName()
Returns property namePropertyName. The property name of the name property. Can be null if there is no name property.


addRecord

public void addRecord(Record pRecord)
Add the specified record. Note that the "name" property (if any) of the record should not be modified after the record is added.

Parameters:
pRecord - the record to be added.

removeRecord

public void removeRecord(Record pRecord)
Remove the specified record. Uses the unique name of the record if namePropertyName is set, and the corresponding property of pRecord is non-null. Otherwise, just search


getRecordsByName

public java.util.List<Record> getRecordsByName(java.lang.String pName)
Get the list of records with the specified name property (as defined by the propertyNameProperty).*

Parameters:
pName - the name of list of records to get.
Returns:
a list of matching records. May return null. Note

getOnlyRecordByName

public Record getOnlyRecordByName(java.lang.String pName)
Return the only record with the give name. Throws an exception if more than one record exists with the given name.

Parameters:
pName - the name of the record to get.

getRecords

public java.util.List<Record> getRecords()
Return the list of all records (with an unmodifiable copy.


getRecordsWithMatchingProperty

public java.util.List<Record> getRecordsWithMatchingProperty(java.lang.String pPropertyName,
                                                             java.lang.String pPropertyValue)
Return all the records with the specified matching property.

Parameters:
pPropertyName - the name of the property value to match.
pPropertyValue - the value of the property to match.
Returns:
the list of matching records (may be empty).

getNameOfRecord

protected java.lang.String getNameOfRecord(Record pRecord)
Get the name of the record, if any.

Parameters:
pRecord - the record whose name to get.
Returns:
the name of the record or null.

writeXMLDeclaration

protected void writeXMLDeclaration(java.io.Writer pWriter,
                                   java.lang.String pXMLVersion,
                                   java.lang.String pEncoding)
                            throws java.io.IOException
Write the XML Declaration.

Parameters:
pWriter - the writer
pXMLVersion - the XML version.
pEncoding - the character encoding.
Throws:
java.io.IOException

getAsXMLString

public java.lang.String getAsXMLString(ApplicationLogging pLogging)
Get our records as an XMLString. Meant for debugging.

Parameters:
pLogging - the logger to use if an exception is thrown.

writeAsXML

public void writeAsXML(java.io.Writer pWriter,
                       boolean pWriteXMLDeclaration,
                       boolean pPrettyPrint,
                       boolean pIncludeStandalone)
                throws java.io.IOException,
                       atg.repository.search.indexing.XMLWriterException
Write the record out as XML.

Parameters:
pWriter - the writer to write to.
pWriteXMLDeclaration - there to write an XML declaration.
pPrettyPrint - whether to do indentation.
pIncludeStandalone - whether th include the "standalone" in the root element.
Throws:
java.io.IOException
atg.repository.search.indexing.XMLWriterException

readFromXML

public void readFromXML(java.io.InputStream pInputStream)
                 throws java.io.IOException
Read from an XML file.

Parameters:
pInputStream - the input stream to read from.
Throws:
java.io.IOException

exactlyEquals

public boolean exactlyEquals(Records pRecords)
Only equal if we have the same records in the same order. We don't override equals here, since we don't necessarily want this expensive behavior in all cases.

Parameters:
pRecord - the records object to compare ourself too.
Returns:
true if we are exactly equal to pRecords.

createXMLWriter

protected Records.ExposedIndentXMLWriter createXMLWriter()
Create our XMLWriter. In this case, we use XMLWriter subclass to allow for terser pretty printing.

Returns:
our newly created ExposedIndentXMLWriter.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object