edu.vt.marian.search
Class UncontrolledStringClassManager

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

public class UncontrolledStringClassManager
extends java.lang.Object
implements NodeClassManager

Class Manager for "opaque" (unsearchable, incomparable) strings. This is the manager used for classes of raw document objects and the like: classes where the underlying representation is as strings, but none of the String functionality really makes sense. Instance identity is decided externally to the class, so when an object is added it is added with an instance ID attached. The class manager enforces uniqueness of instance IDs, but not of strings. Similarly, the manager can retrieve on instance IDs, but not on strings.

See Also:
ClassManager, NodeClassManager, ControlledStringClassManager

Constructor Summary
UncontrolledStringClassManager()
           
 
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).
 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.
 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?
 WtdObjSet match(edu.vt.marian.common.InfoDesc description)
          Create (or find in the local cache) a set of matches to description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UncontrolledStringClassManager

public UncontrolledStringClassManager()
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
Parameters:
description - An abstract description of a set of nodes in this class, including their "context": significant links with other parts of the collection network.
Returns:
A WtdObjSet of instances of this class, weighted by how well they match the description.

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

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'.

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 (presumably) previously unseen String of this class.
Returns:
OK -- id has not already been used, and it and str have been added;
ClassManager.ALREADY_EXISTS -- id is already used;
NO_CAN_DO -- something else went wrong.

NOTE: Uncontrolled strings are not comparable, so this cannot check whether str has already been added. It is up to the caller to ensure that strings are not added multiple times with different ids.


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.

classSize

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