com.waveset.object
Class WSAttribute

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.WSAttribute
All Implemented Interfaces:
javax.naming.Referenceable, XmlObject

public class WSAttribute
extends AbstractXmlObject

WSAttribute class used as a generic attribute class. Also used as a base class for attributes that need to carry around additional information (e.g. ResourceAttribute class)


Field Summary
static java.lang.String code_id
           
static java.lang.String ELEMENT
           
static java.lang.String TRUNCATION_STRING
           
 
Fields inherited from class com.waveset.util.AbstractXmlObject
_trace
 
Constructor Summary
WSAttribute()
           
WSAttribute(Attribute attribute)
           
WSAttribute(Attribute attribute, AttributeValues value)
           
WSAttribute(Attribute attribute, java.lang.Object attrVal)
           
WSAttribute(AttributeValues value, java.lang.String name, java.lang.String type)
           
WSAttribute(AttributeValues value, java.lang.String name, Syntax syntax)
           
WSAttribute(org.w3c.dom.Element e)
           
WSAttribute(java.lang.String name)
           
WSAttribute(java.lang.String name, java.lang.Object attrVal)
           
WSAttribute(java.lang.String name, java.lang.Object attrVal, java.lang.String type)
           
WSAttribute(java.lang.String name, java.lang.Object attrVal, Syntax syntax)
           
WSAttribute(WSAttribute src)
           
 
Method Summary
 boolean add(java.lang.Object attrVal)
          Adds a value if this attribute does not already contain the value, or if this attribute is ordered.
 boolean add(java.lang.Object attrVal, int limit, java.lang.String truncationString)
          Adds a value if this attribute does not already contain the value, or if this attribute is ordered.
 void clear()
           
 boolean contains(java.lang.Object attrVal)
           
 boolean containsIgnoreCase(java.lang.Object attrVal)
           
 java.lang.Object get()
           
 java.lang.Object get(int n)
           
 java.lang.Object[] getAll()
           
 AttributeValues getAttrValues()
           
 java.lang.String getElementName()
          Return the element name.
 java.lang.String getID()
           
 boolean getMultiValued()
           
 java.lang.String getName()
           
 java.lang.Object getStandardValue()
           
 java.lang.String getType()
           
 java.lang.Object getValue()
           
 java.lang.Object getValue(int n)
           
 java.lang.String getValueAsString()
           
 java.lang.String getValueAsString(int n)
           
 boolean isOrdered()
           
static void main(java.lang.String[] args)
           
 void parseXml(org.w3c.dom.Element e)
          Assumes that the element is an Attribute.
 void parseXml(java.lang.String xml)
          Looks for the first instance of an Attribute element in the XML string and parse it.
 boolean put(java.lang.Object attrVal)
          Adds a value if this attribute does not already contain the value.
 void setIsOrdered(boolean ord)
           
 void setName(java.lang.String name)
           
 void setSyntax(Syntax syntax)
           
 void setType(java.lang.String type)
           
 void setValue(int n, java.lang.Object attrVal)
          Replaces a specified value with the value passed in.
 void setValue(java.lang.Object attrVal)
          Replaces the attribute's values with the value passed in.
 void setValues(java.util.List attrVals)
          Replaces the attribute's values with the values passed in.
 void setValues(java.lang.Object[] attrVals)
          Replaces the attribute's values with the values passed in.
 int size()
           
 java.lang.String toString()
           
 java.lang.String toXml()
          Returns the string buffer built by toXml(StringBuffer) as a String.
 void toXml(java.lang.StringBuffer buf)
          This isn't defined in the XmlObject interface, but its used a lot in older code, so provide an implementation to ease the transition.
 void toXml(java.lang.StringBuffer buf, int indent)
          Writes the attribute to XML in one of the following formats: or v1 ...
 int truncate(int limit)
          Limit the number of values that this WSAttribute contains.
 int truncate(int limit, java.lang.String truncationString)
          Limit the number of values that this WSAttribute contains.
 
Methods inherited from class com.waveset.util.AbstractXmlObject
addXmlHeader, cloneObject, dump, dumpFile, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values

ELEMENT

public static final java.lang.String ELEMENT
See Also:
Constant Field Values

TRUNCATION_STRING

public static final java.lang.String TRUNCATION_STRING
See Also:
Constant Field Values
Constructor Detail

WSAttribute

public WSAttribute()

WSAttribute

public WSAttribute(org.w3c.dom.Element e)
            throws WavesetException

WSAttribute

public WSAttribute(java.lang.String name)

WSAttribute

public WSAttribute(java.lang.String name,
                   java.lang.Object attrVal)

WSAttribute

public WSAttribute(java.lang.String name,
                   java.lang.Object attrVal,
                   Syntax syntax)

WSAttribute

public WSAttribute(AttributeValues value,
                   java.lang.String name,
                   Syntax syntax)

WSAttribute

public WSAttribute(AttributeValues value,
                   java.lang.String name,
                   java.lang.String type)

WSAttribute

public WSAttribute(java.lang.String name,
                   java.lang.Object attrVal,
                   java.lang.String type)

WSAttribute

public WSAttribute(Attribute attribute)

WSAttribute

public WSAttribute(Attribute attribute,
                   java.lang.Object attrVal)

WSAttribute

public WSAttribute(Attribute attribute,
                   AttributeValues value)

WSAttribute

public WSAttribute(WSAttribute src)
Method Detail

getElementName

public java.lang.String getElementName()
Description copied from class: AbstractXmlObject
Return the element name.

Specified by:
getElementName in interface XmlObject
Specified by:
getElementName in class AbstractXmlObject

contains

public boolean contains(java.lang.Object attrVal)
Returns:
true if this attribute already contains the value; otherwise false.

containsIgnoreCase

public boolean containsIgnoreCase(java.lang.Object attrVal)
Returns:
true if this attribute already contains the value treated as a case-insensitive string; otherwise false.

put

public boolean put(java.lang.Object attrVal)
Adds a value if this attribute does not already contain the value.

Returns:
true if the value was added; otherwise false.

add

public boolean add(java.lang.Object attrVal)
Adds a value if this attribute does not already contain the value, or if this attribute is ordered.

Returns:
true if the value was added; otherwise false.
See Also:
isOrdered()

add

public boolean add(java.lang.Object attrVal,
                   int limit,
                   java.lang.String truncationString)
Adds a value if this attribute does not already contain the value, or if this attribute is ordered.

Will limit the number of attributes and append the truncation string if at the limit. If there are six elements and you call add(bob,6,"..."); The passed element will not be added, the truncation string will (making a seventh element), and false is returned. The same call made again (now with seven elements) will return false and do nothing.

The type will be forced to Syntax.STRING.getName() to add the truncationString element.

Returns:
true if the value was added; otherwise false.
See Also:
isOrdered()

truncate

public int truncate(int limit)
Limit the number of values that this WSAttribute contains.

If this WSAttribute contains a number of values that is greater than the specified limit, reduce the number of actual values to the limit. Add (beyond the limit) one final, sentinel value that indicates that values were truncated. (Otherwise, do nothing.)

Parameters:
limit - - the maximum number of original values to retain.
Returns:
the number of original values removed.

truncate

public int truncate(int limit,
                    java.lang.String truncationString)
Limit the number of values that this WSAttribute contains.

If this WSAttribute contains a number of values that is greater than the specified limit, reduce the number of actual values to the limit. Add (beyond the limit) one final, sentinel value that indicates that values were truncated. (Otherwise, do nothing.)

Parameters:
limit - - the maximum number of original values to retain.
truncationString - - the final, sentinel value that indicates truncation.
Returns:
the number of original values removed.

setValue

public void setValue(int n,
                     java.lang.Object attrVal)
Replaces a specified value with the value passed in.

Parameters:
n - - the index of the value to replace.

setValue

public void setValue(java.lang.Object attrVal)
Replaces the attribute's values with the value passed in.


setValues

public void setValues(java.lang.Object[] attrVals)
Replaces the attribute's values with the values passed in.


setValues

public void setValues(java.util.List attrVals)
Replaces the attribute's values with the values passed in.


clear

public void clear()

getID

public java.lang.String getID()

getName

public java.lang.String getName()

size

public int size()

get

public java.lang.Object get()

getValue

public java.lang.Object getValue()

get

public java.lang.Object get(int n)

getValue

public java.lang.Object getValue(int n)

getAll

public java.lang.Object[] getAll()

getMultiValued

public boolean getMultiValued()

getValueAsString

public java.lang.String getValueAsString()

getValueAsString

public java.lang.String getValueAsString(int n)

getAttrValues

public AttributeValues getAttrValues()

toString

public java.lang.String toString()

isOrdered

public boolean isOrdered()

setIsOrdered

public void setIsOrdered(boolean ord)

getType

public java.lang.String getType()

setType

public void setType(java.lang.String type)

setName

public void setName(java.lang.String name)

setSyntax

public void setSyntax(Syntax syntax)

getStandardValue

public java.lang.Object getStandardValue()
Returns:
the value of a WSAttribute as a Java List if it is a multi-valued attribute; otherwise just return the value.

toXml

public java.lang.String toXml()
Returns the string buffer built by toXml(StringBuffer) as a String.

Specified by:
toXml in interface XmlObject
Overrides:
toXml in class AbstractXmlObject

toXml

public void toXml(java.lang.StringBuffer buf,
                  int indent)
Writes the attribute to XML in one of the following formats: or v1 ... vn The first format is used if there is only one value. Otherwise, the second format is used.

Specified by:
toXml in interface XmlObject
Specified by:
toXml in class AbstractXmlObject

toXml

public void toXml(java.lang.StringBuffer buf)
Description copied from class: AbstractXmlObject
This isn't defined in the XmlObject interface, but its used a lot in older code, so provide an implementation to ease the transition.

Overrides:
toXml in class AbstractXmlObject

parseXml

public void parseXml(java.lang.String xml)
              throws WavesetException
Looks for the first instance of an Attribute element in the XML string and parse it.

Throws:
WavesetException

parseXml

public void parseXml(org.w3c.dom.Element e)
              throws WavesetException
Assumes that the element is an Attribute.

Throws:
WavesetException

main

public static void main(java.lang.String[] args)