Package opendap.dap
Class Attribute
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.Attribute
-
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
Alias
public class Attribute extends DAPNode
AnAttribute
holds information about a single attribute in anAttributeTable
. It has a type, and contains either aVector
ofString
s containing the attribute's values, or a reference to anAttributeTable
, if theAttribute
is a container. AnAttribute
may also be created as an alias pointing to anotherAttribute
of any type, including container.- See Also:
AttributeTable
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
-
-
Field Summary
Fields Modifier and Type Field 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.-
Fields inherited from class opendap.dap.DAPNode
_nameClear, _nameEncoded, log
-
-
Constructor Summary
Constructors Constructor Description Attribute(int type, String clearname, String value)
Construct anAttribute
with the given type and initial value.Attribute(int type, String clearname, String value, boolean check)
Construct anAttribute
with the given type and initial value.Attribute(String clearname, int type)
Construct an empty attribute with the given type.Attribute(String clearname, AttributeTable container)
Construct a container attribute.Attribute(AttributeTable container)
Deprecated.Use the ctor with the name.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
appendValue(String value)
Append a value to this attribute.void
appendValue(String value, boolean check)
Append a value to this attribute.DAPNode
cloneDAG(DAPNode.CloneMap map)
Returns a clone of thisAttribute
.void
deleteValueAt(int index)
Remove thei
'thString
from this attribute.AttributeTable
getContainer()
Returns theAttributeTable
container.AttributeTable
getContainerN()
Returns theAttributeTable
container.int
getNumVal()
Returns the nummber of values held in this attribute.int
getType()
Returns the attribute type constant.String
getTypeString()
Returns the attribute type as aString
.static int
getTypeVal(String s)
Returns the attribute type as aString
.String
getValueAt(int index)
Returns the attribute value atindex
.String
getValueAtN(int index)
Returns the attribute value atindex
.Enumeration
getValues()
Returns the values of this attribute as anEnumeration
ofString
.Iterator
getValuesIterator()
Returns the values of this attribute as anEnumeration
ofString
.boolean
isAlias()
Returns true if the attribute is an alias.boolean
isContainer()
Returns true if the attribute is a container.void
print(OutputStream os)
Print the attribute on the givenOutputStream
with four spaces of indentation.void
print(OutputStream os, String pad)
Print the attribute on the givenOutputStream
.void
print(PrintWriter os)
Print the attribute on the givenPrintWriter
with four spaces of indentation.void
print(PrintWriter os, String pad)
void
printXML(OutputStream os)
void
printXML(OutputStream os, String pad)
void
printXML(PrintWriter pw)
void
printXML(PrintWriter pw, String pad)
void
printXML(PrintWriter pw, String pad, boolean constrained)
-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Field Detail
-
UNKNOWN
public static final int UNKNOWN
Unknown attribute type. This is currently unused.- See Also:
- Constant Field Values
-
ALIAS
public static final int ALIAS
Alias attribute type. This is an attribute that works like a UNIX style soft link to another attribute.- See Also:
- Constant Field Values
-
CONTAINER
public static final int CONTAINER
Container attribute type. This Attribute holds an AttributeTable.- See Also:
- Constant Field Values
-
BYTE
public static final int BYTE
Byte attribute type. Holds an unsigned Byte.- See Also:
- Constant Field Values
-
INT16
public static final int INT16
Int16 attribute type. Holds a signed Short.- See Also:
- Constant Field Values
-
UINT16
public static final int UINT16
UInt16 attribute type. Holds an unsigned Short.- See Also:
- Constant Field Values
-
INT32
public static final int INT32
Int32 attribute type. Holds a signed Integer.- See Also:
- Constant Field Values
-
UINT32
public static final int UINT32
UInt32 attribute type. Holds an unsigned Integer.- See Also:
- Constant Field Values
-
FLOAT32
public static final int FLOAT32
Float32 attribute type. Holds a Float.- See Also:
- Constant Field Values
-
FLOAT64
public static final int FLOAT64
Float64 attribute type. Holds a Double.- See Also:
- Constant Field Values
-
STRING
public static final int STRING
String attribute type. Holds a String.- See Also:
- Constant Field Values
-
URL
public static final int URL
URL attribute type. Holds a String representing a URL.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Attribute
public Attribute(AttributeTable container)
Deprecated.Use the ctor with the name.Construct a container attribute.- Parameters:
container
- theAttributeTable
container.
-
Attribute
public Attribute(int type, String clearname, String value, boolean check) throws AttributeBadValueException
Construct anAttribute
with the given type and initial value.- Parameters:
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 theappendValue
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.- Throws:
AttributeBadValueException
- thrown if the value is not a legal member of type
-
Attribute
public Attribute(int type, String clearname, String value) throws AttributeBadValueException
Construct anAttribute
with the given type and initial value. Checks the value of the attribute and throws an exception if it's not valid.- Parameters:
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 theappendValue
method to create a vector of values.- Throws:
AttributeBadValueException
- thrown if the value is not a legal member of type
-
Attribute
public Attribute(String clearname, AttributeTable container)
Construct a container attribute.- Parameters:
container
- theAttributeTable
container.
-
Attribute
public Attribute(String clearname, int type) throws IllegalArgumentException
Construct an empty attribute with the given type.- Parameters:
type
- the type of attribute to create. Use one of the type constants defined by this class, other thanCONTAINER
.- Throws:
IllegalArgumentException
- thrown iftype
isCONTAINER
. To construct an empty container attribute, first construct and empty AttributeTable and then use that to construct the Attribute.
-
-
Method Detail
-
getTypeString
public final String getTypeString()
Returns the attribute type as aString
.- Returns:
- the attribute type
String
.
-
getTypeVal
public static final int getTypeVal(String s)
Returns the attribute type as aString
.- Returns:
- the attribute type
String
.
-
getType
public int getType()
Returns the attribute type constant.- Returns:
- the attribute type constant.
-
isContainer
public boolean isContainer()
Returns true if the attribute is a container.- Returns:
- true if the attribute is a container.
-
isAlias
public boolean isAlias()
Returns true if the attribute is an alias.- Returns:
- true if the attribute is an alias.
-
getContainer
public AttributeTable getContainer() throws NoSuchAttributeException
Returns theAttributeTable
container.- Returns:
- the
AttributeTable
container. - Throws:
NoSuchAttributeException
- If the instance of Attribute on which it is called is not a container.
-
getContainerN
public AttributeTable getContainerN()
Returns theAttributeTable
container.- Returns:
- the
AttributeTable
container, or null if not a container.
-
getValues
public Enumeration getValues() throws NoSuchAttributeException
Returns the values of this attribute as anEnumeration
ofString
.- Returns:
- an
Enumeration
ofString
. - Throws:
NoSuchAttributeException
-
getValuesIterator
public Iterator getValuesIterator()
Returns the values of this attribute as anEnumeration
ofString
.- Returns:
- an
Iterator
of String , or null if a container..
-
getNumVal
public int getNumVal() throws NoSuchAttributeException
Returns the nummber of values held in this attribute.- Returns:
- the attribute
String
atindex
. - Throws:
NoSuchAttributeException
-
getValueAt
public String getValueAt(int index) throws NoSuchAttributeException
Returns the attribute value atindex
.- Parameters:
index
- the index of the attribute value to return.- Returns:
- the attribute
String
atindex
. - Throws:
NoSuchAttributeException
-
getValueAtN
public String getValueAtN(int index)
Returns the attribute value atindex
.- Parameters:
index
- the index of the attribute value to return.- Returns:
- the attribute
String
atindex
, or null if a container..
-
appendValue
public void appendValue(String value) throws NoSuchAttributeException, AttributeBadValueException
Append a value to this attribute. Always checks the validity of the attribute's value.- Parameters:
value
- the attributeString
to add.- Throws:
AttributeBadValueException
- thrown if the value is not a legal member of typeNoSuchAttributeException
-
appendValue
public void appendValue(String value, boolean check) throws NoSuchAttributeException, AttributeBadValueException
Append a value to this attribute.- Parameters:
value
- the attributeString
to add.check
- if true, check the validity of he attribute's value, if false don't.- Throws:
AttributeBadValueException
- thrown if the value is not a legal member of typeNoSuchAttributeException
-
deleteValueAt
public void deleteValueAt(int index) throws AttributeBadValueException, NoSuchAttributeException
Remove thei
'thString
from this attribute.- Parameters:
index
- the index of the value to remove.- Throws:
AttributeBadValueException
NoSuchAttributeException
-
print
public void print(PrintWriter os, String pad)
-
print
public final void print(OutputStream os, String pad)
Print the attribute on the givenOutputStream
.- Parameters:
os
- theOutputStream
to use for output.pad
- the number of spaces to indent each line.
-
print
public final void print(PrintWriter os)
Print the attribute on the givenPrintWriter
with four spaces of indentation.- Parameters:
os
- thePrintWriter
to use for output.
-
print
public final void print(OutputStream os)
Print the attribute on the givenOutputStream
with four spaces of indentation.- Parameters:
os
- theOutputStream
to use for output.
-
printXML
public void printXML(OutputStream os)
-
printXML
public void printXML(OutputStream os, String pad)
-
printXML
public void printXML(PrintWriter pw)
-
printXML
public void printXML(PrintWriter pw, String pad)
-
printXML
public void printXML(PrintWriter pw, String pad, boolean constrained)
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisAttribute
. See DAPNode.cloneDag()- Overrides:
cloneDAG
in classDAPNode
- Parameters:
map
- track previously cloned nodes- Returns:
- a clone of this
Attribute
. - Throws:
CloneNotSupportedException
-
-