Package ucar.ma2

Class StructureData

  • Direct Known Subclasses:
    StructureDataA, StructureDataAscii, StructureDataComposite, StructureDataProxy, StructureDataRegexp, StructureDataW

    public abstract class StructureData
    extends Object
    A container for a Structure's data. Is normally contained within an ArrayStructure, which is an Array of StructureData. This is the abstract supertype for all implementations.
       for (Iterator iter = sdata.getMembers().iterator(); iter.hasNext(); ) {
          StructureMembers.Member m = (StructureMembers.Member) iter.next();
          Array sdataArray = sdata.getArray(m);
          ...
       }
     
    General ways to access data in an StructureData are:
      Array getArray(Member m)
     
      Array getArray(String memberName)
     
    The following will return an object of type Byte, Char, Double, Float, Int, Long, Short, String, or Structure, depending upon the member type:
      Object getScalarObject( Member m)
     
    A number of convenience routines may be able to avoid extra Object creation, and so are recommended for efficiency. These require that you know the data types of the member data, but they are the most efficent:
      getScalarXXX(int recnum, Member m)
      getJavaArrayXXX(int recnum, Member m)
     
    where XXX is Byte, Char, Double, Float, Int, Long, Short, or String. For members that are themselves Structures, the equivilent is:
      StructureData getScalarStructure(int recnum, Member m)
      ArrayStructure getArrayStructure(int recnum, Member m)
     
    These will return any compatible type as a double or float, but may have extra overhead when the types dont match:
      convertScalarXXX(int recnum, Member m)
      convertJavaArrayXXX(int recnum, Member m)
     
    where XXX is Double or Float
    See Also:
    ArrayStructure
    • Method Detail

      • getName

        public String getName()
        Returns:
        name of Structure
      • getStructureMembers

        public StructureMembers getStructureMembers()
        Returns:
        StructureMembers object
      • findMember

        public StructureMembers.Member findMember​(String memberName)
        Find a member by its name.
        Parameters:
        memberName - find member with this name
        Returns:
        StructureMembers.Member matching the name, or null if not found
      • getArray

        public abstract Array getArray​(StructureMembers.Member m)
        Get member data array of any type as an Array.
        Parameters:
        m - get data from this StructureMembers.Member.
        Returns:
        Array values.
      • getArray

        public Array getArray​(String memberName)
        Get member data array of any type as an Array. For more efficiency, use getScalarXXX(Member) or getJavaArrayXXX(Member) is possible.
        Parameters:
        memberName - name of member Variable.
        Returns:
        member data array of any type as an Array.
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarObject

        public Object getScalarObject​(String memberName)
        Get member data array of any type as an Object, eg, Float, Double, String etc.
        Parameters:
        memberName - name of member Variable.
        Returns:
        value as Float, Double, etc..
      • getScalarObject

        public Object getScalarObject​(StructureMembers.Member m)
        Get member data array of any type as an Object, eg, Float, Double, String etc.
        Parameters:
        m - get data from this StructureMembers.Member.
        Returns:
        value as Float, Double, etc..
      • convertScalarFloat

        public float convertScalarFloat​(String memberName)
        Get scalar value as a float, with conversion as needed. Underlying type must be convertible to float.
        Parameters:
        memberName - name of member Variable. Must be convertible to float.
        Returns:
        scalar value as a float
        Throws:
        ForbiddenConversionException - if not convertible to float.
      • convertScalarFloat

        public abstract float convertScalarFloat​(StructureMembers.Member m)
        Get scalar value as a float, with conversion as needed. Underlying type must be convertible to float.
        Parameters:
        m - member Variable.
        Returns:
        scalar value as a float
        Throws:
        ForbiddenConversionException - if not convertible to float.
      • convertScalarDouble

        public double convertScalarDouble​(String memberName)
        Get scalar value as a double, with conversion as needed. Underlying type must be convertible to double.
        Parameters:
        memberName - name of member Variable. Must be convertible to double.
        Returns:
        scalar value as a double
        Throws:
        ForbiddenConversionException - if not convertible to double.
      • convertScalarDouble

        public abstract double convertScalarDouble​(StructureMembers.Member m)
        Get scalar value as a double, with conversion as needed. Underlying type must be convertible to double.
        Parameters:
        m - member Variable.
        Returns:
        scalar value as a double
        Throws:
        ForbiddenConversionException - if not convertible to double.
      • convertScalarInt

        public int convertScalarInt​(String memberName)
        Get scalar value as a int, with conversion as needed. Underlying type must be convertible to int.
        Parameters:
        memberName - name of member Variable. Must be convertible to double.
        Returns:
        scalar value as a int
        Throws:
        ForbiddenConversionException - if not convertible to int.
      • convertScalarInt

        public abstract int convertScalarInt​(StructureMembers.Member m)
        Get scalar value as a int, with conversion as needed. Underlying type must be convertible to int.
        Parameters:
        m - member Variable.
        Returns:
        scalar value as a int
        Throws:
        ForbiddenConversionException - if not convertible to int.
      • convertScalarLong

        public long convertScalarLong​(String memberName)
        Get scalar value as a int, with conversion as needed. Underlying type must be convertible to int.
        Parameters:
        memberName - name of member Variable. Must be convertible to double.
        Returns:
        scalar value as a int
        Throws:
        ForbiddenConversionException - if not convertible to int.
      • convertScalarLong

        public abstract long convertScalarLong​(StructureMembers.Member m)
        Get scalar value as a int, with conversion as needed. Underlying type must be convertible to int.
        Parameters:
        m - member Variable.
        Returns:
        scalar value as a int
        Throws:
        ForbiddenConversionException - if not convertible to int.
      • getScalarDouble

        public double getScalarDouble​(String memberName)
        Get member data of type double.
        Parameters:
        memberName - name of member Variable. Must be of type double.
        Returns:
        scalar value as a double
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarDouble

        public abstract double getScalarDouble​(StructureMembers.Member m)
        Get member data of type double.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type double.
        Returns:
        scalar double value
      • getJavaArrayDouble

        public double[] getJavaArrayDouble​(String memberName)
        Get java double array for a member of type double.
        Parameters:
        memberName - name of member Variable. Must be of type double.
        Returns:
        1D java array of doubles
      • getJavaArrayDouble

        public abstract double[] getJavaArrayDouble​(StructureMembers.Member m)
        Get java double array for a member of type double.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type double.
        Returns:
        1D java array of doubles
      • getScalarFloat

        public float getScalarFloat​(String memberName)
        Get member data of type float.
        Parameters:
        memberName - name of member Variable. Must be of type float.
        Returns:
        scalar float value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarFloat

        public abstract float getScalarFloat​(StructureMembers.Member m)
        Get member data of type float.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type float.
        Returns:
        scalar double value
      • getJavaArrayFloat

        public float[] getJavaArrayFloat​(String memberName)
        Get java float array for a member of type float.
        Parameters:
        memberName - name of member Variable. Must be of type float.
        Returns:
        1D java array of floats
      • getJavaArrayFloat

        public abstract float[] getJavaArrayFloat​(StructureMembers.Member m)
        Get java float array for a member of type float.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type float.
        Returns:
        1D java array of floats
      • getScalarByte

        public byte getScalarByte​(String memberName)
        Get member data of type byte.
        Parameters:
        memberName - name of member Variable. Must be of type byte.
        Returns:
        scalar byte value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarByte

        public abstract byte getScalarByte​(StructureMembers.Member m)
        Get member data of type byte.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type byte.
        Returns:
        scalar byte value
      • getJavaArrayByte

        public byte[] getJavaArrayByte​(String memberName)
        Get java byte array for a member of type byte.
        Parameters:
        memberName - name of member Variable. Must be of type byte.
        Returns:
        1D java array of bytes
      • getJavaArrayByte

        public abstract byte[] getJavaArrayByte​(StructureMembers.Member m)
        Get java byte array for a member of type byte.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type byte.
        Returns:
        1D java array of bytes
      • getScalarInt

        public int getScalarInt​(String memberName)
        Get member data of type int.
        Parameters:
        memberName - name of member Variable. Must be of type int.
        Returns:
        scalar int value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarInt

        public abstract int getScalarInt​(StructureMembers.Member m)
        Get member data of type int.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type int.
        Returns:
        scalar int value
      • getJavaArrayInt

        public int[] getJavaArrayInt​(String memberName)
        Get java int array for a member of type int.
        Parameters:
        memberName - name of member Variable. Must be of type int.
        Returns:
        1D java array of ints
      • getJavaArrayInt

        public abstract int[] getJavaArrayInt​(StructureMembers.Member m)
        Get java int array for a member of type int.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type int.
        Returns:
        1D java array of ints
      • getScalarShort

        public short getScalarShort​(String memberName)
        Get member data of type short.
        Parameters:
        memberName - name of member Variable. Must be of type short.
        Returns:
        scalar short value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarShort

        public abstract short getScalarShort​(StructureMembers.Member m)
        Get member data of type short.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type short.
        Returns:
        scalar short value
      • getJavaArrayShort

        public short[] getJavaArrayShort​(String memberName)
        Get java short array for a member of type short.
        Parameters:
        memberName - name of member Variable. Must be of type short.
        Returns:
        1D java array of shorts
      • getJavaArrayShort

        public abstract short[] getJavaArrayShort​(StructureMembers.Member m)
        Get java short array for a member of type short.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type short.
        Returns:
        1D java array of shorts
      • getScalarLong

        public long getScalarLong​(String memberName)
        Get member data of type long.
        Parameters:
        memberName - name of member Variable. Must be of type long.
        Returns:
        scalar long value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarLong

        public abstract long getScalarLong​(StructureMembers.Member m)
        Get member data of type long.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type long.
        Returns:
        scalar long value
      • getJavaArrayLong

        public long[] getJavaArrayLong​(String memberName)
        Get java long array for a member of type long.
        Parameters:
        memberName - name of member Variable. Must be of type long.
        Returns:
        1D java array of longs
      • getJavaArrayLong

        public abstract long[] getJavaArrayLong​(StructureMembers.Member m)
        Get java long array for a member of type long.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type long.
        Returns:
        1D java array of longs
      • getScalarChar

        public char getScalarChar​(String memberName)
        Get member data of type char.
        Parameters:
        memberName - name of member Variable. Must be of type char.
        Returns:
        scalar char value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarChar

        public abstract char getScalarChar​(StructureMembers.Member m)
        Get member data of type char.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type char.
        Returns:
        scalar char value
      • getJavaArrayChar

        public char[] getJavaArrayChar​(String memberName)
        Get java char array for a member of type char.
        Parameters:
        memberName - name of member Variable. Must be of type char.
        Returns:
        1D java array of chars
      • getJavaArrayChar

        public abstract char[] getJavaArrayChar​(StructureMembers.Member m)
        Get java char array for a member of type char.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type char.
        Returns:
        1D java array of chars
      • getScalarString

        public String getScalarString​(String memberName)
        Get String value, from rank 0 String or rank 1 char member array.
        Parameters:
        memberName - name of member Variable.
        Returns:
        scalar String value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarString

        public abstract String getScalarString​(StructureMembers.Member m)
        Get String value, from rank 0 String or rank 1 char member array.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type char or String.
        Returns:
        scalar String value
      • getJavaArrayString

        public String[] getJavaArrayString​(String memberName)
        Get java String array for a member of type String.
        Parameters:
        memberName - name of member Variable. Must be of type char or String.
        Returns:
        1D java array of String
      • getJavaArrayString

        public abstract String[] getJavaArrayString​(StructureMembers.Member m)
        Get java array of Strings for a member of type char or String.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type char or String.
        Returns:
        1D java array of String
      • getScalarStructure

        public StructureData getScalarStructure​(String memberName)
        Get member data of type Structure.
        Parameters:
        memberName - name of member Variable.
        Returns:
        scalar StructureData value
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getScalarStructure

        public abstract StructureData getScalarStructure​(StructureMembers.Member m)
        Get member data of type Structure.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type Structure.
        Returns:
        StructureData
      • getArrayStructure

        public ArrayStructure getArrayStructure​(String memberName)
        Get member data of type Structure.
        Parameters:
        memberName - name of member Variable.
        Returns:
        array of StructureData
        Throws:
        IllegalArgumentException - if name is not legal member name.
      • getArrayStructure

        public abstract ArrayStructure getArrayStructure​(StructureMembers.Member m)
        Get ArrayStructure for a member of type Structure.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type Structure.
        Returns:
        ArrayStructure
      • getArraySequence

        public ArraySequence getArraySequence​(String memberName)
        Get ArraySequence for a member of type Sequence.
        Parameters:
        memberName - name of member Variable. Must be of type Sequence.
        Returns:
        ArrayStructure
      • getArraySequence

        public abstract ArraySequence getArraySequence​(StructureMembers.Member m)
        Get ArraySequence for a member of type Sequence.
        Parameters:
        m - get data from this StructureMembers.Member. Must be of type Sequence.
        Returns:
        ArrayStructure
      • showInternalMembers

        public void showInternalMembers​(Formatter f,
                                        Indent indent)