net.sourceforge.nite.nom.nomwrite.impl
Class NOMWriteAttribute

java.lang.Object
  extended by net.sourceforge.nite.nom.nomwrite.impl.NOMWriteAttribute
All Implemented Interfaces:
NOMAttribute
Direct Known Subclasses:
NOMReadAttribute

public class NOMWriteAttribute
extends java.lang.Object
implements NOMAttribute

A simple implementation of an attribute in a NOM corpus allowing for either numerical or string attributes and teh standard get and set methods.

Author:
jonathan

Nested Class Summary
 class NOMWriteAttribute.SharedAttribute
          This inner class provides a utility functions for shared NOM users
 
Nested classes/interfaces inherited from interface net.sourceforge.nite.nom.nomwrite.NOMAttribute
NOMAttribute.SharedAtt
 
Field Summary
 
Fields inherited from interface net.sourceforge.nite.nom.nomwrite.NOMAttribute
NOMATTR_NUMBER, NOMATTR_STRING
 
Constructor Summary
NOMWriteAttribute(int type, java.lang.String name, java.lang.String string_value, java.lang.Double double_value)
          generic constructor for creating attributes.
NOMWriteAttribute(java.lang.String name, java.lang.Double double_value)
          create a numeric attribute
NOMWriteAttribute(java.lang.String name, java.lang.String string_value)
          create a string attribute
 
Method Summary
 java.lang.Comparable getComparableValue()
          get the Comparable value of the attribute (for either String or Number type attributes)
 java.lang.Double getDoubleValue()
          get the value of the attribute (for a 'number' type attribute only)
 NOMElement getElement()
          get the Element to which this attribute belongs
 java.lang.String getName()
          returns the (q)name of the attribute
 NOMAttribute.SharedAtt getShared()
          return a shared view of this attribute which simply provides utility functions for editing the attribute without thinking about locking and unlocking the corpus.
 java.lang.String getStringValue()
          get the value of the attribute (for a String type attribute only)
 int getType()
          returns a pre-defined integer value: NOMATTR_STRING or NOMATTR_NUMBER.
 void setComparableValue(java.lang.Comparable value)
          set the Comparable value of the attribute (for either String or Number type attributes)
 void setDoubleValue(java.lang.Double value)
          set the value of the attribute (for a 'Number' type attribute only)
 void setElement(NOMElement element)
          set the element to which this attribute belongs
 void setStringValue(java.lang.String value)
          set the value of the attribute (for a String type attribute only)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NOMWriteAttribute

public NOMWriteAttribute(int type,
                         java.lang.String name,
                         java.lang.String string_value,
                         java.lang.Double double_value)
generic constructor for creating attributes. The first argument is the type of the attribute (NOMATTR_STRING or NOMATTR_NUMBER), the second is the na,e of the attribute, the third is the string value (or null) and the fourth is the Double value (or null).


NOMWriteAttribute

public NOMWriteAttribute(java.lang.String name,
                         java.lang.String string_value)
create a string attribute


NOMWriteAttribute

public NOMWriteAttribute(java.lang.String name,
                         java.lang.Double double_value)
create a numeric attribute

Method Detail

setStringValue

public void setStringValue(java.lang.String value)
                    throws NOMException
set the value of the attribute (for a String type attribute only)

Specified by:
setStringValue in interface NOMAttribute
Throws:
NOMException

setDoubleValue

public void setDoubleValue(java.lang.Double value)
                    throws NOMException
set the value of the attribute (for a 'Number' type attribute only)

Specified by:
setDoubleValue in interface NOMAttribute
Throws:
NOMException

getStringValue

public java.lang.String getStringValue()
get the value of the attribute (for a String type attribute only)

Specified by:
getStringValue in interface NOMAttribute

getDoubleValue

public java.lang.Double getDoubleValue()
get the value of the attribute (for a 'number' type attribute only)

Specified by:
getDoubleValue in interface NOMAttribute

getComparableValue

public java.lang.Comparable getComparableValue()
get the Comparable value of the attribute (for either String or Number type attributes)

Specified by:
getComparableValue in interface NOMAttribute

setComparableValue

public void setComparableValue(java.lang.Comparable value)
                        throws NOMException
set the Comparable value of the attribute (for either String or Number type attributes)

Specified by:
setComparableValue in interface NOMAttribute
Throws:
NOMException

getName

public java.lang.String getName()
returns the (q)name of the attribute

Specified by:
getName in interface NOMAttribute

getType

public int getType()
returns a pre-defined integer value: NOMATTR_STRING or NOMATTR_NUMBER.

Specified by:
getType in interface NOMAttribute

getElement

public NOMElement getElement()
get the Element to which this attribute belongs

Specified by:
getElement in interface NOMAttribute

setElement

public void setElement(NOMElement element)
set the element to which this attribute belongs

Specified by:
setElement in interface NOMAttribute

getShared

public NOMAttribute.SharedAtt getShared()
return a shared view of this attribute which simply provides utility functions for editing the attribute without thinking about locking and unlocking the corpus.

Specified by:
getShared in interface NOMAttribute