CAR (Context-Aware Retrieval) v1.0

Class Document

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--Document
All Implemented Interfaces:
CarFace, java.lang.Cloneable, java.util.Collection, java.util.List, java.io.Serializable

public class Document
extends java.util.Vector
implements java.io.Serializable, CarFace

A Document is a vector of Fields. In CAR it's sometimes referred to as a stick-e note, context, or just note.

See the Basic Terminology section of the User Manual for more information.

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Fields inherited from interface CarFace
BOOLEAN_LITERAL, COLLECTION, DOUBLE_LITERAL, EXTERNAL, grammarNames, INTERNAL, KEYPHRASE, LITERALcapacityIncrement, LITERALinitialCapacity, MARKUP, SERIAL, SESSION, STRING_LITERAL, STRINGVALUE_LITERAL
 
Constructor Summary
Document()
          constructs a vector of 0 fields
Document(java.lang.String s)
          For system programmer use only.
Document(java.lang.String id, java.lang.String s)
          For system programmer use only.
 
Method Summary
 void addComment(java.lang.String comment)
          add a comment to the CommentTuple of this document.
 void addField(Field f)
          add the input field to the document.
 java.lang.Object clone()
          create a clone (copy) of the document.
 Document copy()
          create a clone (copy) of the document.
 Field duplicateFields()
          checks for duplicate fields in the document.
 java.lang.String getDocId()
          For system programmer use only.
 Field getField(int i)
          gets the ith field of the document.
 Field getField(java.lang.String name)
          get the the field with the input name.
 Field getNamedFieldWithoutAttribute(java.lang.String fieldName, java.lang.String attributeName)
          gets the first field with given name that doesn't have the given attribute.
 boolean hasField(java.lang.String name)
          indicates whether the document has the named field.
 int numberOfFields()
          returns the number of fields in the document
 void removeAttribute(java.lang.String attributeName)
          rmoves the named attribute from all fields in the document
 void setCommentTuple(CommentTuple ct)
          set the CommentTuple of this document.
 void setField(java.lang.String name)
          create a field with the input name as the first 0th field of this document.
 void t(java.lang.String s)
          Provides trace output of string if -dDocument on command line of CAR run
 java.lang.String toString()
          converts the document to a string.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Constructor Detail

Document

public Document()
constructs a vector of 0 fields

Document

public Document(java.lang.String s)
For system programmer use only.

Document

public Document(java.lang.String id,
                java.lang.String s)
For system programmer use only.
Method Detail

t

public void t(java.lang.String s)
Provides trace output of string if -dDocument on command line of CAR run

clone

public java.lang.Object clone()
create a clone (copy) of the document.
Overrides:
clone in class java.util.Vector
Returns:
a clone (as an Object)

copy

public Document copy()
create a clone (copy) of the document.
Returns:
a clone (as a Document)

setCommentTuple

public void setCommentTuple(CommentTuple ct)
set the CommentTuple of this document. Each document can have a CommentTuple associated with it, which is included at the head of the string output from the method toString().
Parameters:
ct - a CommentTuple

addComment

public void addComment(java.lang.String comment)
add a comment to the CommentTuple of this document.
Parameters:
comment - the string comment to be added

getDocId

public java.lang.String getDocId()
For system programmer use only.

numberOfFields

public int numberOfFields()
returns the number of fields in the document

hasField

public boolean hasField(java.lang.String name)
indicates whether the document has the named field. The name comparison is not case-sensitive.
Parameters:
name - the name tag of the field
Returns:
true if the document has the named field, false otherwise.

setField

public void setField(java.lang.String name)
create a field with the input name as the first 0th field of this document. The created field will have a name, but no AttributeTuple, ValueTuple, or CommentTuple.
Parameters:
name - the name tag of the field

addField

public void addField(Field f)
add the input field to the document. The field will become the last field of the document.
Parameters:
f - the field to be added.

getField

public Field getField(java.lang.String name)
get the the field with the input name. A search is made for a field with a name which when converted to lower case is the same as the one input.
Parameters:
name - the field name to be found.
Returns:
the field (if it exists) else null.

getField

public Field getField(int i)
gets the ith field of the document.
Returns:
the ith field of document (field numbering starts at 0) else null if the field does not exist.

removeAttribute

public void removeAttribute(java.lang.String attributeName)
rmoves the named attribute from all fields in the document

getNamedFieldWithoutAttribute

public Field getNamedFieldWithoutAttribute(java.lang.String fieldName,
                                           java.lang.String attributeName)
gets the first field with given name that doesn't have the given attribute. Because fields with the same name (but different attributes) can exist (they are not regarded as duplicates) it's sometimes necessary to find the first field of the given name without the given attribute (e.g. as needed in the matcher).
Parameters:
fieldName - field name to look for
attributeName - attribute name that mustn't be in the desired field
Returns:
the named field (which does not have the named attribute) or null if one doesn't exist.

duplicateFields

public Field duplicateFields()
checks for duplicate fields in the document. Duplicate fields have the same name (case doesn't matter) and same attribute tuple i.e. the same name-value pairs (case and ordering of attributes is unimportant).
Returns:
if duplicates exist return first duplicate, else null

toString

public java.lang.String toString()
converts the document to a string. The format of the string is consistent with the textual representation of a document, as read from file by CAR.
Overrides:
toString in class java.util.Vector
Returns:
a string represention of the document.

CAR (Context-Aware Retrieval) v1.0

Submit bugs to Lindsey