public class Structure extends NativeObject
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 set{Integer,String}() etc functions.
Field values can be retrieved with get{Integer,String}() etc functions.
Fields can be removed with removeField(java.lang.String)
or removeFields(java.lang.String...)
Modifier and Type | Class and Description |
---|---|
class |
Structure.InvalidFieldException |
NativeObject.Initializer
defaultInit, LIFECYCLE, ownsHandle
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
Structure |
copy() |
protected void |
disposeNativeHandle(com.sun.jna.Pointer ptr) |
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) |
boolean |
getBoolean(java.lang.String fieldName,
int i) |
double |
getDouble(java.lang.String fieldName) |
double |
getDouble(java.lang.String fieldName,
int i) |
int |
getFields()
Get the number of fields in the
Structure . |
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) |
int |
getInteger(java.lang.String fieldName,
int i) |
java.lang.String |
getName()
Get the name of @structure as a string.
|
java.lang.String |
getName(int i)
Get the @structure's ith field name as a string.
|
Range |
getRange(java.lang.String fieldName)
Gets Range field representation
|
java.lang.String |
getString(java.lang.String fieldName) |
java.lang.String |
getString(java.lang.String fieldName,
int i) |
java.lang.Object |
getValue(java.lang.String fieldName) |
ValueList |
getValueList(java.lang.String fieldName)
Gets ValueList field representation
|
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.
|
void |
setPointer(java.lang.String field,
com.sun.jna.Pointer value) |
void |
setValue(java.lang.String field,
GType type,
java.lang.Object value) |
java.lang.String |
toString() |
classFor, disown, dispose, equals, finalize, getNativeAddress, handle, hashCode, initializer, initializer, instanceFor, invalidate, isDisposed, nativeValue, objectFor, objectFor, objectFor, objectFor
public Structure(NativeObject.Initializer init)
public Structure(java.lang.String name)
name
- The name of new structure.public Structure(java.lang.String name, java.lang.String firstFieldName, java.lang.Object... data)
name
- The name of new structure.firstFieldName
- The name of first field to setdata
- Additional arguments.public static Structure fromString(java.lang.String data)
data
- A string representation of a Structure.public Structure copy()
public ValueList getValueList(java.lang.String fieldName)
fieldName
- The name of the field.public java.lang.Object getValue(java.lang.String fieldName)
public int getInteger(java.lang.String fieldName)
public int getInteger(java.lang.String fieldName, int i)
public double getDouble(java.lang.String fieldName)
public double getDouble(java.lang.String fieldName, int i)
public java.lang.String getString(java.lang.String fieldName)
public java.lang.String getString(java.lang.String fieldName, int i)
public boolean getBoolean(java.lang.String fieldName)
fieldName
- public boolean getBoolean(java.lang.String fieldName, int i)
public Fraction getFraction(java.lang.String fieldName)
public int getFourcc(java.lang.String fieldName)
fieldName
- The name of the field.public java.lang.String getFourccString(java.lang.String fieldName)
fieldName
- The name of the field.public Range getRange(java.lang.String fieldName)
fieldName
- The name of the field.public boolean fixateNearestInteger(java.lang.String field, java.lang.Integer value)
public void setInteger(java.lang.String field, java.lang.Integer value)
field
- the name of the field to set.value
- the value to set for the field.public void setValue(java.lang.String field, GType type, java.lang.Object value)
public void setDouble(java.lang.String field, java.lang.Double value)
public void setPointer(java.lang.String field, com.sun.jna.Pointer value)
public void setIntegerRange(java.lang.String field, java.lang.Integer min, java.lang.Integer max)
public void setDoubleRange(java.lang.String field, java.lang.Double min, java.lang.Double max)
public java.lang.String getName()
public void setName(java.lang.String name)
name
- The new name of the structure.public boolean hasName(java.lang.String name)
name
- structure name to check forpublic boolean hasField(java.lang.String fieldName)
Structure
contains a field named fieldName.fieldName
- The name of the field to check.public int getFields()
Structure
.public boolean hasField(java.lang.String fieldName, GType fieldType)
Structure
contains a field named fieldName.fieldName
- The name of the field to check.fieldType
- The type of the field.public boolean hasField(java.lang.String fieldName, java.lang.Class<?> fieldType)
Structure
contains a field named fieldName.fieldName
- The name of the field to check.fieldType
- The type of the field.public boolean hasIntField(java.lang.String fieldName)
Structure
contains an integer field named fieldName.fieldName
- The name of the field to check.public boolean hasDoubleField(java.lang.String fieldName)
Structure
contains a double field named fieldName.fieldName
- The name of the field to check.public void removeField(java.lang.String fieldName)
fieldName
- The name of the field to remove.public void removeFields(java.lang.String... fieldNames)
fieldNames
- A list of field names to remove.public java.lang.String getName(int i)
i
- the requested filed numberpublic java.lang.String toString()
toString
in class NativeObject
public static Structure objectFor(com.sun.jna.Pointer ptr, boolean needRef, boolean ownsHandle)
protected void disposeNativeHandle(com.sun.jna.Pointer ptr)
disposeNativeHandle
in class NativeObject