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
AnAttributeholds information about a single attribute in anAttributeTable. It has a type, and contains either aVectorofStrings containing the attribute's values, or a reference to anAttributeTable, if theAttributeis a container. AnAttributemay also be created as an alias pointing to anotherAttributeof 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 intALIASAlias attribute type.static intBYTEByte attribute type.static intCONTAINERContainer attribute type.static intFLOAT32Float32 attribute type.static intFLOAT64Float64 attribute type.static intINT16Int16 attribute type.static intINT32Int32 attribute type.static intSTRINGString attribute type.static intUINT16UInt16 attribute type.static intUINT32UInt32 attribute type.static intUNKNOWNUnknown attribute type.static intURLURL attribute type.-
Fields inherited from class opendap.dap.DAPNode
_nameClear, _nameEncoded, log
-
-
Constructor Summary
Constructors Constructor Description Attribute(int type, String clearname, String value, boolean check)Construct anAttributewith 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 voidappendValue(String value)Append a value to this attribute.voidappendValue(String value, boolean check)Append a value to this attribute.AttributecloneDAG(DAPNode.CloneMap map)Returns a clone of thisAttribute.voiddeleteValueAt(int index)Remove thei'thStringfrom this attribute.AttributeTablegetContainer()Returns theAttributeTablecontainer.AttributeTablegetContainerN()Returns theAttributeTablecontainer.intgetNumVal()Returns the nummber of values held in this attribute.intgetType()Returns the attribute type constant.StringgetTypeString()Returns the attribute type as aString.static intgetTypeVal(String s)Returns the attribute type as aString.StringgetValueAt(int index)Returns the attribute value atindex.StringgetValueAtN(int index)Returns the attribute value atindex, or null if a containerList<String>getValues()Returns the values of this attribute as anEnumerationofString.Iterator<String>getValuesIterator()Returns the values of this attribute as anIteratorofString.booleanisAlias()Returns true if the attribute is an alias.booleanisContainer()Returns true if the attribute is a container.voidprint(OutputStream os)Print the attribute on the givenOutputStreamwith four spaces of indentation.voidprint(OutputStream os, String pad)Print the attribute on the givenOutputStream.voidprint(PrintWriter os)Print the attribute on the givenPrintWriterwith four spaces of indentation.voidprint(PrintWriter os, String pad)voidprintXML(OutputStream os)voidprintXML(OutputStream os, String pad)voidprintXML(PrintWriter pw)voidprintXML(PrintWriter pw, String pad)voidprintXML(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- theAttributeTablecontainer.
-
Attribute
public Attribute(int type, String clearname, String value, boolean check) throws AttributeBadValueExceptionConstruct anAttributewith 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 theappendValuemethod 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(String clearname, AttributeTable container)
Construct a container attribute.- Parameters:
container- theAttributeTablecontainer.
-
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 iftypeisCONTAINER. 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 theAttributeTablecontainer.- Returns:
- the
AttributeTablecontainer. - Throws:
NoSuchAttributeException- If the instance of Attribute on which it is called is not a container.
-
getContainerN
@Nullable public AttributeTable getContainerN()
Returns theAttributeTablecontainer.- Returns:
- the
AttributeTablecontainer, or null if not a container.
-
getValues
public List<String> getValues() throws NoSuchAttributeException
Returns the values of this attribute as anEnumerationofString.- Returns:
- an
EnumerationofString. - Throws:
NoSuchAttributeException
-
getValuesIterator
public Iterator<String> getValuesIterator()
Returns the values of this attribute as anIteratorofString.
-
getNumVal
public int getNumVal() throws NoSuchAttributeExceptionReturns the nummber of values held in this attribute.- Throws:
NoSuchAttributeException
-
getValueAt
public String getValueAt(int index) throws NoSuchAttributeException
Returns the attribute value atindex.- Throws:
NoSuchAttributeException
-
getValueAtN
@Nullable public String getValueAtN(int index)
Returns the attribute value 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 attributeStringto 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 attributeStringto 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, NoSuchAttributeExceptionRemove thei'thStringfrom this attribute.- Parameters:
index- the index of the value to remove.- Throws:
AttributeBadValueExceptionNoSuchAttributeException
-
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- theOutputStreamto use for output.pad- the number of spaces to indent each line.
-
print
public final void print(PrintWriter os)
Print the attribute on the givenPrintWriterwith four spaces of indentation.- Parameters:
os- thePrintWriterto use for output.
-
print
public final void print(OutputStream os)
Print the attribute on the givenOutputStreamwith four spaces of indentation.- Parameters:
os- theOutputStreamto 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 Attribute cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisAttribute. See DAPNode.cloneDag()- Overrides:
cloneDAGin classDAPNode- Parameters:
map- track previously cloned nodes- Returns:
- a clone of this
Attribute. - Throws:
CloneNotSupportedException
-
-