Class NativeField

  • Direct Known Subclasses:
    NativeSequenceField, NativeStruct

    public class NativeField
    extends BrokerField
    NativeField is a composite object that allows all field types- primatives, sequences, structs, and sequences of structs- to be treated uniformly so that field access algorithms can be greatly simplified.
    • Constructor Summary

      Constructors 
      Constructor Description
      NativeField()
      Default constructor
      NativeField​(java.lang.String name, short type, java.lang.Object value)
      Construct a new NativeField
      NativeField​(java.lang.String name, short type, java.lang.Object value, short packHints)
      Construct a new NativeField
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean clearField​(java.lang.String fieldName)
      Clear field.
      protected java.lang.Object duplicate()  
      boolean elementExists​(int[] indices)
      Returns true if the element at the specified indices exists
      boolean equals​(java.lang.Object another)
      Tests equality.
      java.lang.Object getElements​(int[] indices, int offset, int count)
      Returns a one dimensional array of sequence elements starting at the specified index
      short getElementType​(int[] indices)
      Returns the element type of the sequence at the specified indices.
      NativeField getElementValue​(int[] indices)
      Returns the value of the element at the specified indices
      NativeField getField​(java.lang.String fieldName)
      Returns a field.
      int getFieldCount()
      Returns the number of fields in the struct.
      java.lang.String[] getFieldNames()
      Returns all field names in the struct.
      int getLength​(int[] indices)
      Returns the length of the sequence at the specified indices.
      java.lang.String getName()
      Returns the field name.
      short getType()
      Returns the field type.
      java.lang.Object getValue​(short type)
      Returns the value of the field.
      int hashCode()  
      boolean isFieldSet​(java.lang.String fieldName)
      Returns true if field is set.
      boolean isPrimitive()  
      boolean isSequence()  
      boolean isStruct()  
      boolean isStructOrEvent()  
      void setElements​(int[] indices, int srcOffset, int destOffset, int count, java.lang.Object srcArray)
      Sets count elements of a sequence starting at destStart using element values obtained from the src array starting at srcStart
      void setElementValue​(int[] indices, java.lang.Object value)
      Sets the value of the element at the specified indices
      void setField​(NativeField field)
      Sets a member field.
      void setLength​(int[] indices, int length)
      Sets the length of the sequence at the specified indices.
      void setValue​(java.lang.Object value, short type)
      Sets the value of the field
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • PACK_HINT_NAME_IS_STRING8

        public static final short PACK_HINT_NAME_IS_STRING8
        See Also:
        Constant Field Values
      • name

        public java.lang.String name
    • Constructor Detail

      • NativeField

        public NativeField()
        Default constructor
      • NativeField

        public NativeField​(java.lang.String name,
                           short type,
                           java.lang.Object value)
        Construct a new NativeField
      • NativeField

        public NativeField​(java.lang.String name,
                           short type,
                           java.lang.Object value,
                           short packHints)
        Construct a new NativeField
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object another)
        Tests equality. Two NativeFields are equal if they share the same name. It is only intended to be used during field lookup in a field container.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        another - - object to test against
        Returns:
        boolean
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • getName

        public java.lang.String getName()
        Returns the field name.
        Returns:
        the field name
      • getType

        public short getType()
        Returns the field type. See BrokerTypeDef.FIELD_TYPE_XXXX constants for allowable values.
        Returns:
        short
        See Also:
        BrokerTypeDef
      • setValue

        public void setValue​(java.lang.Object value,
                             short type)
                      throws BrokerException
        Sets the value of the field
        Parameters:
        type - the value type
        value - the new field value
        Throws:
        BrokerException
      • isPrimitive

        public boolean isPrimitive()
      • isStruct

        public boolean isStruct()
      • isStructOrEvent

        public boolean isStructOrEvent()
      • isSequence

        public boolean isSequence()
      • elementExists

        public boolean elementExists​(int[] indices)
                              throws BrokerException
        Returns true if the element at the specified indices exists
        Parameters:
        indices - the indices of the element to test
        Returns:
        true if element exists
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • getElements

        public java.lang.Object getElements​(int[] indices,
                                            int offset,
                                            int count)
                                     throws BrokerException
        Returns a one dimensional array of sequence elements starting at the specified index
        Parameters:
        indices - the indices of the sequence element whose values will be returned
        offset - the index of the first element
        count - the number of elements to return
        Returns:
        a one dimensional array of elements
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • getElementType

        public short getElementType​(int[] indices)
                             throws BrokerException
        Returns the element type of the sequence at the specified indices. One dimensional sequences should pass null for indices.
        Parameters:
        indices - the indices of the sequence whose length will be returned
        Returns:
        the length of the sequence
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • getLength

        public int getLength​(int[] indices)
                      throws BrokerException
        Returns the length of the sequence at the specified indices. One dimensional sequences should pass null for indices.
        Parameters:
        indices - the indices of the sequence whose length will be returned
        Returns:
        the length of the sequence
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • setElements

        public void setElements​(int[] indices,
                                int srcOffset,
                                int destOffset,
                                int count,
                                java.lang.Object srcArray)
                         throws BrokerException
        Sets count elements of a sequence starting at destStart using element values obtained from the src array starting at srcStart
        Parameters:
        indices - the indices of the sequence element whose values will be returned
        srcOffset - starting index of source array
        destOffset - starting index of destination sequence
        count - the number of elements to return
        srcArray - the source array of elements
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • setElementValue

        public void setElementValue​(int[] indices,
                                    java.lang.Object value)
                             throws BrokerException
        Sets the value of the element at the specified indices
        Parameters:
        indices - the indices of the element to set
        value - the value of the element
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException
      • setLength

        public void setLength​(int[] indices,
                              int length)
                       throws BrokerException
        Sets the length of the sequence at the specified indices. To set the length of a one dimensional sequence pass null for indices.
        Parameters:
        indices - the indices of the sequence whose length will be set
        Throws:
        BrokerFieldTypeMismatchException - if field is not a sequence
        BrokerException