org.gstreamer
Class Structure

java.lang.Object
  extended by org.gstreamer.lowlevel.NativeValue
      extended by org.gstreamer.lowlevel.Handle
          extended by org.gstreamer.lowlevel.NativeObject
              extended by org.gstreamer.Structure
Direct Known Subclasses:
TagList

public class Structure
extends NativeObject

Generic structure containing fields of names and values.

A Structure is a collection of key/value pairs. The keys are expressed as GQuarks and the values can be of any GType.

In addition to the key/value pairs, a Structure also has a name. The name starts with a letter and can be followed by letters, numbers and any of "/-_.:".

Structure is used by various GStreamer subsystems to store information in a flexible and extensible way.

A Structure can be created with new Structure(String) or Structure(String, String, Object...), which both take a name and an optional set of key/value pairs along with the types of the values.

Field values can be changed with #setValue or #set.

Field values can be retrieved with #getValue or the more specific get{Integer,String}() etc functions.

Fields can be removed with removeField(java.lang.String) or removeFields(java.lang.String...)

See Also:
Caps, Event

Nested Class Summary
 class Structure.InvalidFieldException
           
 
Nested classes/interfaces inherited from class org.gstreamer.lowlevel.NativeObject
NativeObject.Initializer
 
Field Summary
 
Fields inherited from class org.gstreamer.lowlevel.NativeObject
defaultInit, LIFECYCLE, ownsHandle
 
Constructor Summary
Structure(NativeObject.Initializer init)
          Creates a new instance of Structure
Structure(java.lang.String name)
          Creates a new, empty #GstStructure with the given name.
Structure(java.lang.String name, java.lang.String firstFieldName, java.lang.Object... data)
          Creates a new Structure with the given name.
 
Method Summary
 Structure copy()
           
protected  void disposeNativeHandle(com.sun.jna.Pointer ptr)
           
 boolean fixateFieldNearestInteger(java.lang.String field, java.lang.Integer target)
           
 boolean fixateNearestInteger(java.lang.String field, java.lang.Integer value)
           
static Structure fromString(java.lang.String data)
          Creates a Structure from a string representation.
 boolean getBoolean(java.lang.String fieldName)
           
 double getDouble(java.lang.String fieldName)
           
 int getFourcc(java.lang.String fieldName)
          Gets FOURCC field int representation
 java.lang.String getFourccString(java.lang.String fieldName)
          Gets FOURCC field String representation
 Fraction getFraction(java.lang.String fieldName)
           
 int getInteger(java.lang.String fieldName)
           
 java.lang.String getName()
          Get the name of @structure as a string.
 Range getRange(java.lang.String fieldName)
           
 java.lang.String getString(java.lang.String fieldName)
           
 boolean hasDoubleField(java.lang.String fieldName)
          Check if the Structure contains a double field named fieldName.
 boolean hasField(java.lang.String fieldName)
          Check if the Structure contains a field named fieldName.
 boolean hasField(java.lang.String fieldName, java.lang.Class<?> fieldType)
          Check if the Structure contains a field named fieldName.
 boolean hasField(java.lang.String fieldName, GType fieldType)
          Check if the Structure contains a field named fieldName.
 boolean hasIntField(java.lang.String fieldName)
          Check if the Structure contains an integer field named fieldName.
 boolean hasName(java.lang.String name)
          Checks if the structure has the given name.
static Structure objectFor(com.sun.jna.Pointer ptr, boolean needRef, boolean ownsHandle)
           
 void removeField(java.lang.String fieldName)
          Removes the field with the given name from the structure.
 void removeFields(java.lang.String... fieldNames)
          Removes the fields with the given names.
 void setDouble(java.lang.String field, java.lang.Double value)
           
 void setDoubleRange(java.lang.String field, java.lang.Double min, java.lang.Double max)
           
 void setInteger(java.lang.String field, java.lang.Integer value)
          Sets an integer field in the structure.
 void setIntegerRange(java.lang.String field, java.lang.Integer min, java.lang.Integer max)
           
 void setName(java.lang.String name)
          Sets the name of the structure to the given name.
 java.lang.String toString()
           
 
Methods inherited from class org.gstreamer.lowlevel.NativeObject
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, initializer, instanceFor, invalidate, isDisposed, nativeValue, objectFor, objectFor, objectFor
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Structure

public Structure(NativeObject.Initializer init)
Creates a new instance of Structure


Structure

public Structure(java.lang.String name)
Creates a new, empty #GstStructure with the given name.

Parameters:
name - The name of new structure.

Structure

public Structure(java.lang.String name,
                 java.lang.String firstFieldName,
                 java.lang.Object... data)
Creates a new Structure with the given name. Parses the list of variable arguments and sets fields to the values listed. Variable arguments should be passed as field name, field type, and value.

Parameters:
name - The name of new structure.
firstFieldName - The name of first field to set
data - Additional arguments.
Method Detail

fromString

public static Structure fromString(java.lang.String data)
Creates a Structure from a string representation.

Parameters:
data - A string representation of a Structure.
Returns:
A new Structure or null when the string could not be parsed.

copy

public Structure copy()

getInteger

public int getInteger(java.lang.String fieldName)

getDouble

public double getDouble(java.lang.String fieldName)

getString

public java.lang.String getString(java.lang.String fieldName)

setInteger

public void setInteger(java.lang.String field,
                       java.lang.Integer value)
Sets an integer field in the structure.

Parameters:
field - the name of the field to set.
value - the value to set for the field.

setDouble

public void setDouble(java.lang.String field,
                      java.lang.Double value)

setIntegerRange

public void setIntegerRange(java.lang.String field,
                            java.lang.Integer min,
                            java.lang.Integer max)

setDoubleRange

public void setDoubleRange(java.lang.String field,
                           java.lang.Double min,
                           java.lang.Double max)

fixateNearestInteger

public boolean fixateNearestInteger(java.lang.String field,
                                    java.lang.Integer value)

getBoolean

public boolean getBoolean(java.lang.String fieldName)
Parameters:
fieldName -
Returns:
The boolean value for fieldName

getFraction

public Fraction getFraction(java.lang.String fieldName)

fixateFieldNearestInteger

public boolean fixateFieldNearestInteger(java.lang.String field,
                                         java.lang.Integer target)

getFourcc

public int getFourcc(java.lang.String fieldName)
Gets FOURCC field int representation

Parameters:
fieldName - The name of the field.
Returns:
FOURCC field as a 4 byte integer

getFourccString

public java.lang.String getFourccString(java.lang.String fieldName)
Gets FOURCC field String representation

Parameters:
fieldName - The name of the field.
Returns:
FOURCC field as a String

getRange

public Range getRange(java.lang.String fieldName)

getName

public java.lang.String getName()
Get the name of @structure as a string.

Returns:
The name of the structure.

setName

public void setName(java.lang.String name)
Sets the name of the structure to the given name. The name must not be empty, must start with a letter and can be followed by letters, numbers and any of "/-_.:".

Parameters:
name - The new name of the structure.

hasName

public boolean hasName(java.lang.String name)
Checks if the structure has the given name.

Parameters:
name - structure name to check for
Returns:
true if @name matches the name of the structure.

hasField

public boolean hasField(java.lang.String fieldName)
Check if the Structure contains a field named fieldName.

Parameters:
fieldName - The name of the field to check.
Returns:
true if the structure contains a field with the given name.

hasField

public boolean hasField(java.lang.String fieldName,
                        GType fieldType)
Check if the Structure contains a field named fieldName.

Parameters:
fieldName - The name of the field to check.
fieldType - The type of the field.
Returns:
true if the structure contains a field named fieldName and of type fieldType

hasField

public boolean hasField(java.lang.String fieldName,
                        java.lang.Class<?> fieldType)
Check if the Structure contains a field named fieldName.

Parameters:
fieldName - The name of the field to check.
fieldType - The type of the field.
Returns:
true if the structure contains a field named fieldName and of type fieldType

hasIntField

public boolean hasIntField(java.lang.String fieldName)
Check if the Structure contains an integer field named fieldName.

Parameters:
fieldName - The name of the field to check.
Returns:
true if the structure contains an integer field named fieldName

hasDoubleField

public boolean hasDoubleField(java.lang.String fieldName)
Check if the Structure contains a double field named fieldName.

Parameters:
fieldName - The name of the field to check.
Returns:
true if the structure contains a double field named fieldName

removeField

public void removeField(java.lang.String fieldName)
Removes the field with the given name from the structure. If the field with the given name does not exist, the structure is unchanged.

Parameters:
fieldName - The name of the field to remove.

removeFields

public void removeFields(java.lang.String... fieldNames)
Removes the fields with the given names. If a field does not exist, the argument is ignored.

Parameters:
fieldNames - A list of field names to remove.

toString

public java.lang.String toString()
Overrides:
toString in class NativeObject

objectFor

public static Structure objectFor(com.sun.jna.Pointer ptr,
                                  boolean needRef,
                                  boolean ownsHandle)

disposeNativeHandle

protected void disposeNativeHandle(com.sun.jna.Pointer ptr)
Specified by:
disposeNativeHandle in class NativeObject