Class Schema.Field

  • All Implemented Interfaces:
    Serializable
    Enclosing class:
    Schema

    public static class Schema.Field
    extends Object
    implements Serializable
    Information (name, type, and optionally size) about a field in a Schema.

    A field can be looked up within a schema in three ways:

    1. By index: By the zero-based ordinal position of the field within the schema
    2. By simple name: By the name of the field itself (e.g., "myint")
    3. By path name: By a dot-separated list of names that define a path through a set of nested schemas that arise through the use of fields of type Tuple (e.g., "mynestedtuple.myint").

    A Field object can be used to obtain the value of a field in a tuple. However, there are rules that must be obeyed in doing so. For example, one must obtain the Field object from a Schema object that describes the schema of the tuple (i.e., as opposed to directly from a Field constructor).

    See the "client" StreamBase sample (streambase-install-dir/sample/client) for examples of proper use of Field objects.

    Note: Serializations of instances of this class that are created (e.g., by using ObjectOutputStream) in one version of StreamBase in general will not be deserializable in any other version of StreamBase.

    See Also:
    Serialized Form
    • Constructor Detail

      • Field

        public Field​(String name,
                     CompleteDataType completeType,
                     Location loc)
        Constructor
        Parameters:
        name - Field name
        completeType - Field data type
        loc - Source location
      • Field

        public Field​(Schema.Field field)
        Construct a Field from an existing Field.
        Parameters:
        field - Field to copy data from
      • Field

        public Field​(String name,
                     Schema.Field field)
        Construct a Field from an existing Field, giving the new field a specified name
        Parameters:
        name - The name of the field
        field - Field to copy data from
    • Method Detail

      • getLocation

        public Location getLocation()
        Get location
        Returns:
        Location
      • equalsNoCapture

        public boolean equalsNoCapture​(Schema.Field other)
        Compare non-capture fields
        Parameters:
        other - Compare with this field
        Returns:
        true if equal
      • checkType

        public void checkType​(CompleteDataType dataType)
                       throws TupleException
        Check to make sure that the given type is the same as the type of this Field
        Parameters:
        dataType - The CompleteDataType to check
        Throws:
        TupleException - thrown when the types do not match
        Since:
        6.3.7
      • getDataType

        public DataType getDataType()
        Return the DataType of the Field
        Returns:
        DataType of the Field
      • getCompleteDataType

        public CompleteDataType getCompleteDataType()
        Return the CompleteDataType of the Field
        Returns:
        CompleteDataType of the Field
        Since:
        6.3
      • getName

        public String getName()
        Return the name of the Field. If the Field was constructed from a field path name, that path name is returned
        Returns:
        The name of the Field
      • getShortName

        public String getShortName()
        Return the last (which might be the only) segment of this Field
        Returns:
        the last segment of this Field
      • getIndex

        public int getIndex()
        Return the index of this field within the Schema
        Returns:
        The index of the field within the Schema
      • getSize

        public int getSize()
        Return the size of the field (in bytes) without any header information.
        Returns:
        The size of the Field in bytes (without header information)
      • getSchema

        public Schema getSchema()
        Return the schema for this field. Valid only if the type of the field is Tuple.
        Returns:
        The schema, or null if field type is not Tuple
        Since:
        6.0
      • getNestedField

        public Schema.Field getNestedField​(String fieldPathName)
                                    throws TupleException
        Return a field that identifies a field in a nested tuple field. This method can be applied only to a field whose type is Tuple.
        Parameters:
        fieldPathName - the path name to the desired nested tuple field
        Returns:
        the field
        Throws:
        TupleException - if the field path name is invalid or this field isn't of type Tuple
        Since:
        6.0
      • getNestedFields

        public Schema.Field[] getNestedFields()
                                       throws TupleException
        Return an array of fields, each of which identifies a field in a nested tuple field. This method can be applied only to a field whose type is Tuple.
        Returns:
        the array of fields
        Throws:
        TupleException - if this field is not of type Tuple.
        Since:
        6.0
      • toString

        public String toString()
        Return a String representation of this field.
        Overrides:
        toString in class Object
        Returns:
        String representation of this Field
      • getDescription

        public String getDescription()
        Returns the description currently set for this field. At runtime this method will return null, and the description can only be guaranteed to have meaning during application development in the authoring environment.
        Returns:
        this field's description String null when unknown
      • setDescription

        public void setDescription​(String description)
        Sets this field's description.
        Parameters:
        description - the description String for this field
      • getElementType

        public CompleteDataType getElementType()
        Return the element type for this field. Valid only if the type of the field is List.
        Returns:
        The schema, or null if field type is not List
        Since:
        6.3