sg.edu.nus.comp.nlp.ims.instance
Class CInstance

java.lang.Object
  extended by sg.edu.nus.comp.nlp.ims.instance.CInstance
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, IInstance

public class CInstance
extends java.lang.Object
implements IInstance

a common instance.

Author:
zhongzhi
See Also:
Serialized Form

Field Summary
protected  java.lang.String m_DocID
           
protected  java.util.ArrayList<IFeature> m_Features
           
protected  java.lang.String m_ID
           
protected  java.util.Hashtable<java.lang.String,java.lang.Integer> m_KeyMap
           
protected  java.util.ArrayList<java.lang.String> m_Keys
           
protected  java.lang.String m_LexeltID
           
protected  java.util.ArrayList<java.lang.String> m_Tags
           
 
Constructor Summary
CInstance(java.lang.String p_InstanceID)
          initial with instance id
CInstance(java.lang.String p_InstanceID, java.lang.String p_LexeltID)
          initial with instance id and lexelt id
CInstance(java.lang.String p_InstanceID, java.lang.String p_LexeltID, java.lang.String p_DocumentID)
          initial with instance id, lexelt id and document id
 
Method Summary
 boolean addFeature(IFeature p_Feature)
          add one feature to the instance.
 java.lang.Object clone()
          clone instance
 java.lang.String getDocID()
          get the document ID of this instance
 IFeature getFeature(int p_Index)
          get the feature of index p_Index
 IFeature getFeature(java.lang.String p_Key)
          get the feature of this instance with p_Name
 java.lang.String getFeatureName(int p_Index)
          get the name of feature of p_Index
 java.lang.String getFeatureValue(int p_KeyIndex)
          get the feature value of feature of p_Index
 java.lang.String getFeatureValue(java.lang.String p_Key)
          get the feature value of feature of p_Name
 java.lang.String getID()
          get the ID of this instance
 java.lang.String getLexeltID()
          get the lexelt ID of this instance
 java.util.ArrayList<java.lang.String> getTag()
          get tag(s) of this instance
 boolean setDocID(java.lang.String p_DocID)
          set document ID
 boolean setLexeltID(java.lang.String p_LexeltID)
          set lexelt ID
 boolean setTag(java.lang.String p_Tag)
          add p_Tag to tag list
 boolean setTag(java.lang.String p_Tag, boolean p_Add)
          add p_Tag to tag list if p_Add == true else remove all tags and set tag as p_Tag
 int size()
          the the number of features in this instance
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_Keys

protected java.util.ArrayList<java.lang.String> m_Keys

m_KeyMap

protected java.util.Hashtable<java.lang.String,java.lang.Integer> m_KeyMap

m_Features

protected java.util.ArrayList<IFeature> m_Features

m_ID

protected java.lang.String m_ID

m_DocID

protected java.lang.String m_DocID

m_LexeltID

protected java.lang.String m_LexeltID

m_Tags

protected java.util.ArrayList<java.lang.String> m_Tags
Constructor Detail

CInstance

public CInstance(java.lang.String p_InstanceID,
                 java.lang.String p_LexeltID)
initial with instance id and lexelt id

Parameters:
p_InstanceID - instance id
p_LexeltID - instance lexelt id

CInstance

public CInstance(java.lang.String p_InstanceID,
                 java.lang.String p_LexeltID,
                 java.lang.String p_DocumentID)
initial with instance id, lexelt id and document id

Parameters:
p_InstanceID - instance id
p_LexeltID - instance lexelt id
p_DocumentID - instance document id

CInstance

public CInstance(java.lang.String p_InstanceID)
initial with instance id

Parameters:
p_InstanceID - instance id
Method Detail

addFeature

public boolean addFeature(IFeature p_Feature)
Description copied from interface: IInstance
add one feature to the instance. if the feature(identified by its key) has already been set, the old one will be replaced.

Specified by:
addFeature in interface IInstance
Parameters:
p_Feature - feature
Returns:
add success or not

getTag

public java.util.ArrayList<java.lang.String> getTag()
Description copied from interface: IInstance
get tag(s) of this instance

Specified by:
getTag in interface IInstance
Returns:
tags

getID

public java.lang.String getID()
Description copied from interface: IInstance
get the ID of this instance

Specified by:
getID in interface IInstance
Returns:
instance ID

getDocID

public java.lang.String getDocID()
Description copied from interface: IInstance
get the document ID of this instance

Specified by:
getDocID in interface IInstance
Returns:
document id

getLexeltID

public java.lang.String getLexeltID()
Description copied from interface: IInstance
get the lexelt ID of this instance

Specified by:
getLexeltID in interface IInstance
Returns:
lexelt ID

setDocID

public boolean setDocID(java.lang.String p_DocID)
Description copied from interface: IInstance
set document ID

Specified by:
setDocID in interface IInstance
Parameters:
p_DocID - document ID
Returns:
success or not

setLexeltID

public boolean setLexeltID(java.lang.String p_LexeltID)
Description copied from interface: IInstance
set lexelt ID

Specified by:
setLexeltID in interface IInstance
Parameters:
p_LexeltID - lexelt ID
Returns:
set success or not

setTag

public boolean setTag(java.lang.String p_Tag)
Description copied from interface: IInstance
add p_Tag to tag list

Specified by:
setTag in interface IInstance
Parameters:
p_Tag - tag
Returns:
success or not

setTag

public boolean setTag(java.lang.String p_Tag,
                      boolean p_Add)
Description copied from interface: IInstance
add p_Tag to tag list if p_Add == true else remove all tags and set tag as p_Tag

Specified by:
setTag in interface IInstance
Parameters:
p_Tag - tag
p_Add - append or replace
Returns:
success or not

getFeature

public IFeature getFeature(java.lang.String p_Key)
Description copied from interface: IInstance
get the feature of this instance with p_Name

Specified by:
getFeature in interface IInstance
Parameters:
p_Key - feature name
Returns:
feature

getFeature

public IFeature getFeature(int p_Index)
Description copied from interface: IInstance
get the feature of index p_Index

Specified by:
getFeature in interface IInstance
Parameters:
p_Index - feature index
Returns:
feature

getFeatureValue

public java.lang.String getFeatureValue(java.lang.String p_Key)
Description copied from interface: IInstance
get the feature value of feature of p_Name

Specified by:
getFeatureValue in interface IInstance
Parameters:
p_Key - feature name
Returns:
feature value

getFeatureValue

public java.lang.String getFeatureValue(int p_KeyIndex)
Description copied from interface: IInstance
get the feature value of feature of p_Index

Specified by:
getFeatureValue in interface IInstance
Parameters:
p_KeyIndex - feature index
Returns:
feature value

getFeatureName

public java.lang.String getFeatureName(int p_Index)
Description copied from interface: IInstance
get the name of feature of p_Index

Specified by:
getFeatureName in interface IInstance
Parameters:
p_Index - feature index
Returns:
feature name

size

public int size()
Description copied from interface: IInstance
the the number of features in this instance

Specified by:
size in interface IInstance
Returns:
feature size

clone

public java.lang.Object clone()
Description copied from interface: IInstance
clone instance

Specified by:
clone in interface IInstance
Overrides:
clone in class java.lang.Object
Returns:
clone instance