Jet.Lisp
Class FeatureSet

java.lang.Object
  extended byJet.Lisp.FeatureSet

public class FeatureSet
extends java.lang.Object

A FeatureSet provides a mapping from interned Strings to Objects. It is intended to provide an efficient implementation for small numbers of features.


Field Summary
protected  java.util.Vector features
           
protected  java.util.Vector values
           
 
Constructor Summary
FeatureSet()
          Creates an empty FeatureSet.
FeatureSet(FeatureSet fs)
          creates a new FeatureSet with the same features and values as fs.
FeatureSet(java.io.StreamTokenizer tok, boolean allowVariables, char endChar)
          This constructor reads a feature set from StreamTokenizer tok.
FeatureSet(java.lang.String feat1, java.lang.Object val1)
          Creates a FeatureSet with one feature/value pair.
FeatureSet(java.lang.String feat1, java.lang.Object val1, java.lang.String feat2, java.lang.Object val2)
          Creates a FeatureSet with two feature/value pairs.
FeatureSet(java.lang.String feat1, java.lang.Object val1, java.lang.String feat2, java.lang.Object val2, java.lang.String feat3, java.lang.Object val3)
          Creates a FeatureSet with three feature/value pairs.
 
Method Summary
 boolean containsFeature(java.lang.String feat)
          Returns true if the FeatureSet has feature feat with some value, possibly null.
 boolean equals(FeatureSet fs)
          Returns true if the FeatureSet is equal to fs: whether the two FeatureSets have the same features with equal values.
 java.lang.Object get(java.lang.String feat)
          Returns the value associated with feature feat.
 java.util.Enumeration keys()
          Returns an Enumeration over the features in the feature set.
 void prepareToMakeString(int nestingLimit)
          add 'id' feature to all Annotations referenced by this FeatureSet.
 void put(java.lang.String feat, java.lang.Object val)
          Associates the specified value val with the feature feat.
 void putAll(FeatureSet fs)
          putAll adds all the feature/value pairs in FeatureSet fs
 int size()
          returns the number of features in the FeatureSet.
 boolean subsetOf(FeatureSet fs)
          returns true if the FeatureSet is contained in fs: if every feature in the FeatureSet is present in fs with the same value.
 FeatureSet substitute(java.util.HashMap bindings)
          Returns a new feature set in which every value of the original feature set which is a variable has been replace by the binding of that variable in bindings.
 java.lang.String toSGMLString()
          returns a string representation of the feature set, without enclosing braces, of the form
feature1=value1 feature2=value2 ...
which is suitable when the feature set is part of an annotation or SGML tag.
 java.lang.String toSGMLString(int nestingLimit, boolean quoteValues)
          returns a string representation of the feature set, without enclosing braces, of the form
feature1=value1 feature2=value2 ...
which is suitable when the feature set is part of an annotation or SGML tag.
 java.lang.String toString()
          returns a printable form of the feature set, of the form
[feature1=value1 feature2=value2 ...].
static FeatureSet unify(FeatureSet a, FeatureSet b)
          If every feature which occurs in both FeatureSets a and b has the same value in both FeatureSets, returns a new FeatureSet with the union of the features; otherwise returns null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

features

protected java.util.Vector features

values

protected java.util.Vector values
Constructor Detail

FeatureSet

public FeatureSet()
Creates an empty FeatureSet.


FeatureSet

public FeatureSet(java.lang.String feat1,
                  java.lang.Object val1)
Creates a FeatureSet with one feature/value pair.


FeatureSet

public FeatureSet(java.lang.String feat1,
                  java.lang.Object val1,
                  java.lang.String feat2,
                  java.lang.Object val2)
Creates a FeatureSet with two feature/value pairs.


FeatureSet

public FeatureSet(java.lang.String feat1,
                  java.lang.Object val1,
                  java.lang.String feat2,
                  java.lang.Object val2,
                  java.lang.String feat3,
                  java.lang.Object val3)
Creates a FeatureSet with three feature/value pairs.


FeatureSet

public FeatureSet(FeatureSet fs)
creates a new FeatureSet with the same features and values as fs.


FeatureSet

public FeatureSet(java.io.StreamTokenizer tok,
                  boolean allowVariables,
                  char endChar)
           throws java.io.IOException,
                  PatternSyntaxError
This constructor reads a feature set from StreamTokenizer tok. The input should have the general form
feature = value feature = value ... ]
where the value may be an integer, a symbol, or a string; if parameter allowVariables is true, the value may also be a variable. The FeatureSet ends in token endChar ("]" in the example above). Feature-value pairs may be optionally separated by commas. On entry, the first feature should be the next token to be read from tok (not the current token).

Method Detail

put

public void put(java.lang.String feat,
                java.lang.Object val)
Associates the specified value val with the feature feat.


putAll

public void putAll(FeatureSet fs)
putAll adds all the feature/value pairs in FeatureSet fs


get

public java.lang.Object get(java.lang.String feat)
Returns the value associated with feature feat.


containsFeature

public boolean containsFeature(java.lang.String feat)
Returns true if the FeatureSet has feature feat with some value, possibly null.


subsetOf

public boolean subsetOf(FeatureSet fs)
returns true if the FeatureSet is contained in fs: if every feature in the FeatureSet is present in fs with the same value.


equals

public boolean equals(FeatureSet fs)
Returns true if the FeatureSet is equal to fs: whether the two FeatureSets have the same features with equal values.


keys

public java.util.Enumeration keys()
Returns an Enumeration over the features in the feature set.


size

public int size()
returns the number of features in the FeatureSet.


substitute

public FeatureSet substitute(java.util.HashMap bindings)
Returns a new feature set in which every value of the original feature set which is a variable has been replace by the binding of that variable in bindings.


unify

public static FeatureSet unify(FeatureSet a,
                               FeatureSet b)
If every feature which occurs in both FeatureSets a and b has the same value in both FeatureSets, returns a new FeatureSet with the union of the features; otherwise returns null.


toString

public java.lang.String toString()
returns a printable form of the feature set, of the form
[feature1=value1 feature2=value2 ...].
Inverse features, ending in "-1", are suppressed to avoid infinite loops.


toSGMLString

public java.lang.String toSGMLString()
returns a string representation of the feature set, without enclosing braces, of the form
feature1=value1 feature2=value2 ...
which is suitable when the feature set is part of an annotation or SGML tag. Inverse features, ending in "-1", are suppressed to avoid infinite loops.


toSGMLString

public java.lang.String toSGMLString(int nestingLimit,
                                     boolean quoteValues)
returns a string representation of the feature set, without enclosing braces, of the form
feature1=value1 feature2=value2 ...
which is suitable when the feature set is part of an annotation or SGML tag. Inverse features, ending in "-1", are suppressed to avoid infinite loops.

Parameters:
nestingLimit - limit of depth of nested Annotations which will be represented in the String. Beyond that limit, references to Annotations are rendered as '#nnn', where 'nnn' is the 'id' feature of the referenced Annotation.
quoteValues - if true, values of features are enclosed in double quotes, as required by XML.

prepareToMakeString

public void prepareToMakeString(int nestingLimit)
add 'id' feature to all Annotations referenced by this FeatureSet. This is invoked prior to converting this FeatureSet to a String, if annotation references are to be converted to '#nnn' form.