public class Attribute extends DAPNode
Attribute
holds information about a single attribute in an
AttributeTable
. It has a type, and contains either a
Vector
of String
s containing the attribute's
values, or a reference to an AttributeTable
, if the
Attribute
is a container. An Attribute
may also
be created as an alias pointing to another Attribute
of any
type, including container.AttributeTable
,
Serialized FormDAPNode.CloneMap
Modifier and Type | Field and Description |
---|---|
static int |
ALIAS
Alias attribute type.
|
static int |
BYTE
Byte attribute type.
|
static int |
CONTAINER
Container attribute type.
|
static int |
FLOAT32
Float32 attribute type.
|
static int |
FLOAT64
Float64 attribute type.
|
static int |
INT16
Int16 attribute type.
|
static int |
INT32
Int32 attribute type.
|
static int |
STRING
String attribute type.
|
static int |
UINT16
UInt16 attribute type.
|
static int |
UINT32
UInt32 attribute type.
|
static int |
UNKNOWN
Unknown attribute type.
|
static int |
URL
URL attribute type.
|
_nameClear, _nameEncoded, log
Constructor and Description |
---|
Attribute(AttributeTable container)
Deprecated.
Use the ctor with the name.
|
Attribute(int type,
java.lang.String clearname,
java.lang.String value)
Construct an
Attribute with the given type and initial
value. |
Attribute(int type,
java.lang.String clearname,
java.lang.String value,
boolean check)
Construct an
Attribute with the given type and initial
value. |
Attribute(java.lang.String clearname,
AttributeTable container)
Construct a container attribute.
|
Attribute(java.lang.String clearname,
int type)
Construct an empty attribute with the given type.
|
Modifier and Type | Method and Description |
---|---|
void |
appendValue(java.lang.String value)
Append a value to this attribute.
|
void |
appendValue(java.lang.String value,
boolean check)
Append a value to this attribute.
|
DAPNode |
cloneDAG(DAPNode.CloneMap map)
Returns a clone of this
Attribute . |
void |
deleteValueAt(int index)
Remove the
i 'th String from this attribute. |
AttributeTable |
getContainer()
Returns the
AttributeTable container. |
AttributeTable |
getContainerN()
Returns the
AttributeTable container. |
int |
getNumVal()
Returns the nummber of values held in this attribute.
|
int |
getType()
Returns the attribute type constant.
|
java.lang.String |
getTypeString()
Returns the attribute type as a
String . |
static int |
getTypeVal(java.lang.String s)
Returns the attribute type as a
String . |
java.lang.String |
getValueAt(int index)
Returns the attribute value at
index . |
java.lang.String |
getValueAtN(int index)
Returns the attribute value at
index . |
java.util.Enumeration |
getValues()
Returns the values of this attribute as an
Enumeration
of String . |
java.util.Iterator |
getValuesIterator()
Returns the values of this attribute as an
Enumeration of String . |
boolean |
isAlias()
Returns true if the attribute is an alias.
|
boolean |
isContainer()
Returns true if the attribute is a container.
|
void |
print(java.io.OutputStream os)
Print the attribute on the given
OutputStream with
four spaces of indentation. |
void |
print(java.io.OutputStream os,
java.lang.String pad)
Print the attribute on the given
OutputStream . |
void |
print(java.io.PrintWriter os)
Print the attribute on the given
PrintWriter with
four spaces of indentation. |
void |
print(java.io.PrintWriter os,
java.lang.String pad) |
void |
printXML(java.io.OutputStream os) |
void |
printXML(java.io.OutputStream os,
java.lang.String pad) |
void |
printXML(java.io.PrintWriter pw) |
void |
printXML(java.io.PrintWriter pw,
java.lang.String pad) |
void |
printXML(java.io.PrintWriter pw,
java.lang.String pad,
boolean constrained) |
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
public static final int UNKNOWN
public static final int ALIAS
public static final int CONTAINER
public static final int BYTE
public static final int INT16
public static final int UINT16
public static final int INT32
public static final int UINT32
public static final int FLOAT32
public static final int FLOAT64
public static final int STRING
public static final int URL
public Attribute(AttributeTable container)
container
- the AttributeTable
container.public Attribute(int type, java.lang.String clearname, java.lang.String value, boolean check) throws AttributeBadValueException
Attribute
with the given type and initial
value.type
- the type of attribute to create. Use one of the type
constants defined by this class.clearname
- the name of the attribute.value
- the initial value of this attribute. Use the
appendValue
method to create a vector of values.check
- if true, check the value and throw
AttributeBadValueException if it's not valid; if false do not check its
validity.AttributeBadValueException
- thrown if the value is not a legal
member of typepublic Attribute(int type, java.lang.String clearname, java.lang.String value) throws AttributeBadValueException
Attribute
with the given type and initial
value. Checks the value of the attribute and throws an exception if
it's not valid.type
- the type of attribute to create. Use one of the type
constants defined by this class.clearname
- the name of the attribute.value
- the initial value of this attribute. Use the
appendValue
method to create a vector of values.AttributeBadValueException
- thrown if the value is not a legal
member of typepublic Attribute(java.lang.String clearname, AttributeTable container)
container
- the AttributeTable
container.public Attribute(java.lang.String clearname, int type) throws java.lang.IllegalArgumentException
type
- the type of attribute to create. Use one of the type
constants defined by this class, other than CONTAINER
.java.lang.IllegalArgumentException
- thrown if
type
is CONTAINER
. To construct an empty
container attribute, first construct and empty AttributeTable and then
use that to construct the Attribute.public final java.lang.String getTypeString()
String
.String
.public static final int getTypeVal(java.lang.String s)
String
.String
.public int getType()
public boolean isContainer()
public boolean isAlias()
public AttributeTable getContainer() throws NoSuchAttributeException
AttributeTable
container.AttributeTable
container.NoSuchAttributeException
- If
the instance of Attribute on which it is called is not a container.public AttributeTable getContainerN()
AttributeTable
container.AttributeTable
container, or null if not a container.public java.util.Enumeration getValues() throws NoSuchAttributeException
Enumeration
of String
.Enumeration
of String
.NoSuchAttributeException
public java.util.Iterator getValuesIterator()
Enumeration
of String
.Iterator
of String , or null if a container..public int getNumVal() throws NoSuchAttributeException
String
at index
.NoSuchAttributeException
public java.lang.String getValueAt(int index) throws NoSuchAttributeException
index
.index
- the index of the attribute value to return.String
at index
.NoSuchAttributeException
public java.lang.String getValueAtN(int index)
index
.index
- the index of the attribute value to return.String
at index
, or null if a container..public void appendValue(java.lang.String value) throws NoSuchAttributeException, AttributeBadValueException
value
- the attribute String
to add.AttributeBadValueException
- thrown if the value is not a legal
member of typeNoSuchAttributeException
public void appendValue(java.lang.String value, boolean check) throws NoSuchAttributeException, AttributeBadValueException
value
- the attribute String
to add.check
- if true, check the validity of he attribute's value, if
false don't.AttributeBadValueException
- thrown if the value is not a legal
member of typeNoSuchAttributeException
public void deleteValueAt(int index) throws AttributeBadValueException, NoSuchAttributeException
i
'th String
from this attribute.index
- the index of the value to remove.AttributeBadValueException
NoSuchAttributeException
public void print(java.io.PrintWriter os, java.lang.String pad)
public final void print(java.io.OutputStream os, java.lang.String pad)
OutputStream
.os
- the OutputStream
to use for output.pad
- the number of spaces to indent each line.public final void print(java.io.PrintWriter os)
PrintWriter
with
four spaces of indentation.os
- the PrintWriter
to use for output.public final void print(java.io.OutputStream os)
OutputStream
with
four spaces of indentation.os
- the OutputStream
to use for output.public void printXML(java.io.OutputStream os)
os
- public void printXML(java.io.OutputStream os, java.lang.String pad)
os
- pad
- public void printXML(java.io.PrintWriter pw)
pw
- public void printXML(java.io.PrintWriter pw, java.lang.String pad)
pw
- pad
- public void printXML(java.io.PrintWriter pw, java.lang.String pad, boolean constrained)
pw
- pad
- constrained
- public DAPNode cloneDAG(DAPNode.CloneMap map) throws java.lang.CloneNotSupportedException
Attribute
.
See DAPNode.cloneDag()