Package opendap.dap

Class Attribute

  • All Implemented Interfaces:
    Serializable, Cloneable
    Direct Known Subclasses:
    Alias

    public class Attribute
    extends DAPNode
    An Attribute holds information about a single attribute in an AttributeTable. It has a type, and contains either a Vector of Strings 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.
    See Also:
    AttributeTable, Serialized Form
    • 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 - the AttributeTable container.
      • Attribute

        public Attribute​(int type,
                         String clearname,
                         String value,
                         boolean check)
                  throws AttributeBadValueException
        Construct an Attribute 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 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.
        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 - the AttributeTable 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 than CONTAINER.
        Throws:
        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.
    • Method Detail

      • getTypeString

        public final String getTypeString()
        Returns the attribute type as a String.
        Returns:
        the attribute type String.
      • getTypeVal

        public static final int getTypeVal​(String s)
        Returns the attribute type as a String.
        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.
      • getContainerN

        @Nullable
        public AttributeTable getContainerN()
        Returns the AttributeTable container.
        Returns:
        the AttributeTable container, or null if not a container.
      • getValuesIterator

        public Iterator<String> getValuesIterator()
        Returns the values of this attribute as an Iterator of String.
      • getValueAtN

        @Nullable
        public String getValueAtN​(int index)
        Returns the attribute value at index, or null if a container
      • print

        public final void print​(OutputStream os,
                                String pad)
        Print the attribute on the given OutputStream.
        Parameters:
        os - the OutputStream 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 given PrintWriter with four spaces of indentation.
        Parameters:
        os - the PrintWriter to use for output.
      • print

        public final void print​(OutputStream os)
        Print the attribute on the given OutputStream with four spaces of indentation.
        Parameters:
        os - the OutputStream to use for output.
      • printXML

        public void printXML​(PrintWriter pw,
                             String pad,
                             boolean constrained)