public class MetadataDescriptor extends Object implements Comparable<MetadataDescriptor>, Cloneable
MetadataContainer
.ContainerType
at construction.Integer.MAX_VALUE
, this implementation does it (due to java
nature).Modifier and Type | Field and Description |
---|---|
static long |
DWORD_MAXVALUE
Maximum value for WORD.
|
static int |
MAX_LANG_INDEX
The maximum language index allowed.
|
static int |
MAX_STREAM_NUMBER
Maximum stream number.
|
static BigInteger |
QWORD_MAXVALUE
Maximum value for a QWORD value (64 bit unsigned).
|
static int |
TYPE_BINARY
Constant for the metadata descriptor-type for binary data.
|
static int |
TYPE_BOOLEAN
Constant for the metadata descriptor-type for booleans.
|
static int |
TYPE_DWORD
Constant for the metadata descriptor-type for DWORD (32-bit unsigned).
|
static int |
TYPE_GUID
Constant for the metadata descriptor-type for GUIDs (128-bit).
|
static int |
TYPE_QWORD
Constant for the metadata descriptor-type for QWORD (64-bit unsinged).
|
static int |
TYPE_STRING
Constant for the metadata descriptor-type for Strings.
|
static int |
TYPE_WORD
Constant for the metadata descriptor-type for WORD (16-bit unsigned).
|
static int |
WORD_MAXVALUE
Maximum value for WORD.
|
Constructor and Description |
---|
MetadataDescriptor(ContainerType type,
String propName,
int propType)
Creates an Instance.
|
MetadataDescriptor(ContainerType type,
String propName,
int propType,
int stream,
int language)
Creates an Instance.
|
MetadataDescriptor(String propName)
|
MetadataDescriptor(String propName,
int propType)
|
Modifier and Type | Method and Description |
---|---|
BigInteger |
asNumber()
Converts the descriptors value into a number if possible.
A boolean will be converted to "1" if true ,
otherwise "0".String will be interpreted as number with radix "10". Binary data will be interpreted as the default WORD,DWORD or QWORD binary representation, but only if the data does not exceed 8 bytes. |
Object |
clone()
(overridden)
|
int |
compareTo(MetadataDescriptor other) |
MetadataDescriptor |
createCopy()
This method creates a copy of the current object.
|
boolean |
equals(Object obj)
(overridden)
|
boolean |
getBoolean()
Returns the value of the MetadataDescriptor as a Boolean.
|
byte[] |
getBytes()
Deprecated.
|
ContainerType |
getContainerType()
Returns the container type this descriptor ist restricted to.
|
int |
getCurrentAsfSize(ContainerType type)
Returns the size (in bytes) this descriptor will take when written to an
ASF file.
|
GUID |
getGuid()
Returns the GUID value, if content could represent one.
|
int |
getLanguageIndex()
Returns the index of the language that is referred (see
LanguageList ): |
String |
getName()
This method returns the name of the metadata descriptor.
|
long |
getNumber()
This method returns the value of the metadata descriptor as a long.
|
byte[] |
getRawData()
This method returns a copy of the content of the descriptor.
|
int |
getRawDataSize()
Returns the size (in bytes) the binary representation of the content
uses.
|
int |
getStreamNumber()
Returns the stream number this descriptor applies to.
|
String |
getString()
Returns the value of the MetadataDescriptor as a String.
|
int |
getType()
Returns the type of the metadata descriptor.
|
int |
hashCode() |
boolean |
isEmpty()
This method checks if the binary data is empty.
|
void |
setBinaryValue(byte[] data)
Sets the Value of the current metadata descriptor.
|
void |
setBooleanValue(boolean value)
Sets the Value of the current metadata descriptor.
|
void |
setDWordValue(long value)
Sets the Value of the current metadata descriptor.
|
void |
setGUIDValue(GUID value)
Sets the value of the metadata descriptor.
Using this method will change descriptorType to
TYPE_GUID |
void |
setLanguageIndex(int language)
Sets the index of the referred language (see
LanguageList ).Consider: The requirements must be held. |
void |
setQWordValue(BigInteger value)
Sets the Value of the current metadata descriptor.
|
void |
setQWordValue(long value)
Sets the Value of the current metadata descriptor.
|
void |
setStreamNumber(int stream)
Sets the stream number the descriptor applies to.
Consider: The requirements must be held. |
void |
setString(String value)
This method converts the given string value into the current
data type.
|
void |
setStringValue(String value)
Sets the Value of the current metadata descriptor.
|
void |
setWordValue(int value)
Sets the Value of the current metadata descriptor.
|
String |
toString()
(overridden)
|
int |
writeInto(OutputStream out,
ContainerType contType)
Writes this descriptor into the specified output stream.
|
public static final long DWORD_MAXVALUE
public static final int MAX_LANG_INDEX
public static final int MAX_STREAM_NUMBER
public static final BigInteger QWORD_MAXVALUE
public static final int TYPE_BINARY
public static final int TYPE_BOOLEAN
public static final int TYPE_DWORD
public static final int TYPE_GUID
public static final int TYPE_QWORD
public static final int TYPE_STRING
public static final int TYPE_WORD
public static final int WORD_MAXVALUE
public MetadataDescriptor(ContainerType type, String propName, int propType)
type
- the container type, this descriptor is resctricted to.propName
- Name of the MetadataDescriptor.propType
- Type of the metadata descriptor. See descriptorType
public MetadataDescriptor(ContainerType type, String propName, int propType, int stream, int language)
type
- The container type the values (the whole descriptor) is
restricted to.propName
- Name of the MetadataDescriptor.propType
- Type of the metadata descriptor. See descriptorType
stream
- the number of the stream the descriptor refers to.language
- the index of the language entry in a LanguageList
this
descriptor refers to.public MetadataDescriptor(String propName)
propName
- name of the metadata descriptor.public MetadataDescriptor(String propName, int propType)
propName
- Name of the MetadataDescriptor.propType
- Type of the metadata descriptor. See descriptorType
public BigInteger asNumber()
true
,
otherwise "0".NumberFormatException
- If no conversion is supported.public Object clone() throws CloneNotSupportedException
clone
in class Object
CloneNotSupportedException
Object.clone()
public int compareTo(MetadataDescriptor other)
compareTo
in interface Comparable<MetadataDescriptor>
public MetadataDescriptor createCopy()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public boolean getBoolean()
true
if first byte of content
is not zero.@Deprecated public byte[] getBytes()
writeInto(OutputStream, ContainerType)
is usedpublic ContainerType getContainerType()
public int getCurrentAsfSize(ContainerType type)
type
- the container type for which the size is calculated.public GUID getGuid()
public int getLanguageIndex()
LanguageList
):public String getName()
public long getNumber()
content
to a number. getType()
equals on of the following: TYPE_BOOLEAN
,
TYPE_DWORD
,
TYPE_QWORD
,
TYPE_WORD
public byte[] getRawData()
public int getRawDataSize()
getRawData()
)public int getStreamNumber()
public String getString()
public int getType()
descriptorType
TYPE_BINARY
,
TYPE_BOOLEAN
,
TYPE_DWORD
,
TYPE_GUID
,
TYPE_QWORD
,
TYPE_STRING
,
TYPE_WORD
public boolean isEmpty()
true
if no value is set.public void setBinaryValue(byte[] data) throws IllegalArgumentException
descriptorType
to
TYPE_BINARY
.data
- Value to set.IllegalArgumentException
- if data is invalid for container.public void setBooleanValue(boolean value)
descriptorType
to
TYPE_BOOLEAN
.value
- Value to set.public void setDWordValue(long value)
descriptorType
to
TYPE_DWORD
.value
- Value to set.public void setGUIDValue(GUID value)
descriptorType
to
TYPE_GUID
value
- value to set.public void setLanguageIndex(int language)
LanguageList
).language
- the language index to setpublic void setQWordValue(BigInteger value) throws IllegalArgumentException
descriptorType
to
TYPE_QWORD
value
- Value to set.NumberFormatException
- on null
values.IllegalArgumentException
- on illegal values or values exceeding range.public void setQWordValue(long value)
descriptorType
to
TYPE_QWORD
value
- Value to set.public void setStreamNumber(int stream)
stream
- the stream number to setpublic void setString(String value) throws IllegalArgumentException
value
- value to set.IllegalArgumentException
- If conversion was impossible.public void setStringValue(String value) throws IllegalArgumentException
descriptorType
to
TYPE_STRING
.value
- Value to set.IllegalArgumentException
- If byte representation would take more than 65535 Bytes.public void setWordValue(int value) throws IllegalArgumentException
descriptorType
to
TYPE_WORD
value
- Value to set.IllegalArgumentException
- on negative values. ASF just supports unsigned values.public String toString()
toString
in class Object
Object.toString()
public int writeInto(OutputStream out, ContainerType contType) throws IOException
out
- stream to write into.contType
- the container type this descriptor is written to.IOException
- on I/O ErrorsCopyright © 2005–2020 jthink.net. All rights reserved.