edu.vt.marian.search
Class ControlledStringClassManager

java.lang.Object
  |
  +--edu.vt.marian.search.ControlledStringClassManager

public class ControlledStringClassManager
extends java.lang.Object
implements NodeClassManager

Class Manager for searchable Strings. Controlled strings are those that can be recognized, compared, and searched, as opposed to the long uncontrolled strings that serve as underlayment for raw documents. Examples of controlled string classes are persons' names, subject descriptors, and English words. Since the criteria for identity is determined by the raw objects (in Java, it is just String.equals()) the class manager can enforce instance identity, and can and does generate its own instance IDs. Thus, when a client adds a string to the class, it is the class manager, not the client, that generates the instance ID. In fact, adding a string and generating an ID is not semantically separable from recognizing a string already in the class and returning its previously generated ID.

See Also:
ClassManager, NodeClassManager, UncontrolledStringClassManager

Constructor Summary
ControlledStringClassManager()
           
 
Method Summary
 int add(edu.vt.marian.common.FullID id, java.lang.String str)
          Add a new String and a new FullID for it to this class (See note).
 edu.vt.marian.common.FullID add(java.lang.String str)
          Add a new String to this class, and generate its new FullID.
 long classSize()
          Return the number of class instances currently in the factory.
 int delete(edu.vt.marian.common.FullID id)
          Forget about the object referred to by id.
 int delete(java.lang.String str)
          Forget about a String currently among the class instances.
 java.util.Vector idsToObjects(java.util.Vector ids)
          Do idToObject() for a bunch of FullIDs.
 java.lang.Object idToObject(edu.vt.marian.common.FullID id)
          Return the Java Object that implements the instance of this class picked out by id.
 java.lang.String idToString(edu.vt.marian.common.FullID id)
          Map this ID to the String form of class instance.
 boolean isInClass(edu.vt.marian.common.FullID id)
          Is this the ID of an instance currently in this class?
 boolean isInClass(java.lang.String str)
          Is this String an instance currently in this class?
 WtdObjSet match(edu.vt.marian.common.InfoDesc description)
          Create (or find in the local cache) a set of matches to description.
 edu.vt.marian.common.FullID stringToID(java.lang.String str)
          Map this String to a FullID of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ControlledStringClassManager

public ControlledStringClassManager()
Method Detail

match

public WtdObjSet match(edu.vt.marian.common.InfoDesc description)
Create (or find in the local cache) a set of matches to description.
Specified by:
match in interface NodeClassManager

isInClass

public boolean isInClass(edu.vt.marian.common.FullID id)
Is this the ID of an instance currently in this class?
Specified by:
isInClass in interface NodeClassManager

isInClass

public boolean isInClass(java.lang.String str)
Is this String an instance currently in this class?

idToString

public java.lang.String idToString(edu.vt.marian.common.FullID id)
Map this ID to the String form of class instance.
Parameters:
id - The FullID of an instance of this class.
Returns:
The String form of that instance, or
'null' if id does not pick out any current class instance.

idToObject

public java.lang.Object idToObject(edu.vt.marian.common.FullID id)
Return the Java Object that implements the instance of this class picked out by id.
Specified by:
idToObject in interface NodeClassManager
Parameters:
id - The FullID for an object of this class.
Returns:
the (Java form of the) real object, or 'null' if id does not describe an instance currently in this class.

idsToObjects

public java.util.Vector idsToObjects(java.util.Vector ids)
Do idToObject() for a bunch of FullIDs.
Specified by:
idsToObjects in interface NodeClassManager
Parameters:
ids - A Vector of FullIDs for objects of this class.
Returns:
A Vector of real (Java) objects, in one-to-one correspondence with their FullIDs in ids. NOTE: Should a FullID in ids not pick out a valid instance of this class, the corresponding element of the return vector is set to 'null'.

stringToID

public edu.vt.marian.common.FullID stringToID(java.lang.String str)
Map this String to a FullID of this class.
Parameters:
str - The String form of an instance of this class.
Returns:
The ID of that instance.

NOTE: This is a "find-or-add" operation. If str is already known as a member of this class, then an ID has already been assigned to it in an earlier invocation of this method of add(). The same ID will be returned this time. If str has not previsously been seen, it will be added to the known instances of the class. A previously unused instanceID will be generated for it and used to construct the FullID that is returned.

See Also:
add(String)

add

public int add(edu.vt.marian.common.FullID id,
               java.lang.String str)
Add a new String and a new FullID for it to this class (See note).
Parameters:
id - An unused FullID of this class.
str - A previously unseen String of this class.
Returns:
OK -- Both id and str are unknown, and have been added, orboth were known, and id is already the FullID of str;
ClassManager.ALREADY_EXISTS -- either id or str is already used;
NO_CAN_DO -- something else went wrong.

NOTE: This method should not be used under normal circumstances. Normally all FullIDs of a controlled string class are generated by the class manager. Overriding that responsibility and adding one created "on the outside" introduces inefficiencies and the potential for confusion. Insead, add(Sting str) and stringToID() are preferred.


add

public edu.vt.marian.common.FullID add(java.lang.String str)
Add a new String to this class, and generate its new FullID.
Parameters:
str - The String form of an instance of this class.
Returns:
The ID of that instance, or
'null' if str is already a known instance of this class.

NOTE: This method is identical to stringToID() except that str is presumed to not already be a known instance of this class. If it is an instance already managed by this, add() will fail.

See Also:
stringToID(java.lang.String)

delete

public int delete(edu.vt.marian.common.FullID id)
Forget about the object referred to by id.
Returns:
OK -- There was such a string in the class, and now there isn't;
ClassManager.NO_SUCH_OBJECT -- There never was such an instance.
NO_CAN_DO -- The object was there, but could not be deleted.

delete

public int delete(java.lang.String str)
Forget about a String currently among the class instances.
Returns:
OK -- There was such a string in the class, and now there isn't;
ClassManager.NO_SUCH_OBJECT -- There never was such an instance.
NO_CAN_DO -- The object was there, but could not be deleted.

classSize

public long classSize()
Return the number of class instances currently in the factory.