org.jaudiotagger.audio.asf.data
Class ContentDescriptor

java.lang.Object
  extended by org.jaudiotagger.audio.asf.data.ContentDescriptor
All Implemented Interfaces:
java.lang.Comparable<ContentDescriptor>

public final class ContentDescriptor
extends java.lang.Object
implements java.lang.Comparable<ContentDescriptor>

This class is a wrapper for properties within a ExtendedContentDescription.
Each descriptor consists of the folloowing: Descriptor Name Length 16 bits Descriptor Name UTF16LE format Descriptor Value Data Type 16 bits Descriptor Value Length 16 bits Descriptor Value varies

Author:
Christian Laireiter

Field Summary
static int TYPE_BINARY
          Constant for the content descriptor-type for binary data.
static int TYPE_BOOLEAN
          Constant for the content descriptor-type for booleans.
static int TYPE_DWORD
          Constant for the content descriptor-type for integers (32-bit).
static int TYPE_QWORD
          Constant for the content descriptor-type for integers (64-bit).
static int TYPE_STRING
          Constant for the content descriptor-type for Strings.
static int TYPE_WORD
          Constant for the content descriptor-type for integers (16-bit).
 
Constructor Summary
ContentDescriptor(java.lang.String propName, int propType)
          Creates an Instance.
 
Method Summary
 java.lang.Object clone()
          (overridden)
 int compareTo(ContentDescriptor o)
          
 ContentDescriptor createCopy()
          This method creates a copy of the current object.
 boolean equals(java.lang.Object obj)
          (overridden)
 boolean getBoolean()
          Returns the value of the ContentDescriptor as a Boolean.
 byte[] getBytes()
          This method will return a byte array, which can directly be written into an "Extended Content Description"-chunk.
 int getCurrentAsfSize()
          Returns the size (in bytes) this descriptor will take when written to an ASF file.
 java.lang.String getName()
          This method returns the name of the content descriptor.
 long getNumber()
          This method returns the value of the content descriptor as an integer.
 byte[] getRawData()
          This method returns a copy of the content of the descriptor.
 java.lang.String getString()
          Returns the value of the ContentDescriptor as a String.
 int getType()
          Returns the type of the content descriptor.
 boolean isEmpty()
          This method checks if the binary data is empty.
 void setBinaryValue(byte[] data)
          Sets the Value of the current content descriptor.
 void setBooleanValue(boolean value)
          Sets the Value of the current content descriptor.
 void setDWordValue(long value)
          Sets the Value of the current content descriptor.
 void setQWordValue(long value)
          Sets the Value of the current content descriptor.
 void setStringValue(java.lang.String value)
          Sets the Value of the current content descriptor.
 void setWordValue(int value)
          Sets the Value of the current content descriptor.
 java.lang.String toString()
          (overridden)
 int writeInto(java.io.OutputStream out)
          Writes this descriptor into the specified output stream.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_BINARY

public static final int TYPE_BINARY
Constant for the content descriptor-type for binary data.

See Also:
Constant Field Values

TYPE_BOOLEAN

public static final int TYPE_BOOLEAN
Constant for the content descriptor-type for booleans.

See Also:
Constant Field Values

TYPE_DWORD

public static final int TYPE_DWORD
Constant for the content descriptor-type for integers (32-bit).

See Also:
Constant Field Values

TYPE_QWORD

public static final int TYPE_QWORD
Constant for the content descriptor-type for integers (64-bit).

See Also:
Constant Field Values

TYPE_STRING

public static final int TYPE_STRING
Constant for the content descriptor-type for Strings.

See Also:
Constant Field Values

TYPE_WORD

public static final int TYPE_WORD
Constant for the content descriptor-type for integers (16-bit).

See Also:
Constant Field Values
Constructor Detail

ContentDescriptor

public ContentDescriptor(java.lang.String propName,
                         int propType)
Creates an Instance.

Parameters:
propName - Name of the ContentDescriptor.
propType - Type of the content descriptor. See descriptorType
Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
(overridden)

Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException
See Also:
Object.clone()

compareTo

public int compareTo(ContentDescriptor o)

Specified by:
compareTo in interface java.lang.Comparable<ContentDescriptor>

createCopy

public ContentDescriptor createCopy()
This method creates a copy of the current object.
All data will be copied, too.

Returns:
A new content descriptor containing the same values as the current one.

equals

public boolean equals(java.lang.Object obj)
(overridden)

Overrides:
equals in class java.lang.Object
See Also:
Object.equals(java.lang.Object)

getBoolean

public boolean getBoolean()
Returns the value of the ContentDescriptor as a Boolean.
If no Conversion is Possible false is returned.
true if first byte of contentis not zero.

Returns:
boolean representation of the current value.

getBytes

public byte[] getBytes()
This method will return a byte array, which can directly be written into an "Extended Content Description"-chunk.

Returns:
byte[] with the data, that occurs in asf files.

getCurrentAsfSize

public int getCurrentAsfSize()
Returns the size (in bytes) this descriptor will take when written to an ASF file.

Returns:
size of the descriptor in an ASF file.

getName

public java.lang.String getName()
This method returns the name of the content descriptor.

Returns:
Name.

getNumber

public long getNumber()
This method returns the value of the content descriptor as an integer.
Converts the needed amount of byte out of contentto a number.
Only possible if getType()equals on of the following:
  • Returns:
    integer value.
    See Also:
  • ,
  • ,
  • ,

  • getRawData

    public byte[] getRawData()
    This method returns a copy of the content of the descriptor.

    Returns:
    The content in binary representation, as it would be written to asf file.

    getString

    public java.lang.String getString()
    Returns the value of the ContentDescriptor as a String.

    Returns:
    String - Representation Value

    getType

    public int getType()
    Returns the type of the content descriptor.

    Returns:
    the value of descriptorType
    See Also:
    TYPE_BINARY, TYPE_BOOLEAN, TYPE_DWORD, TYPE_QWORD, TYPE_STRING, TYPE_WORD

    isEmpty

    public boolean isEmpty()
    This method checks if the binary data is empty.
    Disregarding the type of the descriptor its content is stored as a byte array.

    Returns:
    true if no value is set.

    setBinaryValue

    public void setBinaryValue(byte[] data)
                        throws java.lang.IllegalArgumentException
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_BINARY.

    Parameters:
    data - Value to set.
    Throws:
    java.lang.IllegalArgumentException - If the byte array is greater that 65535 bytes.

    setBooleanValue

    public void setBooleanValue(boolean value)
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_BOOLEAN.

    Parameters:
    value - Value to set.

    setDWordValue

    public void setDWordValue(long value)
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_DWORD.

    Parameters:
    value - Value to set.

    setQWordValue

    public void setQWordValue(long value)
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_QWORD

    Parameters:
    value - Value to set.

    setStringValue

    public void setStringValue(java.lang.String value)
                        throws java.lang.IllegalArgumentException
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_STRING.

    Parameters:
    value - Value to set.
    Throws:
    java.lang.IllegalArgumentException - If byte representation would take more than 65535 Bytes.

    setWordValue

    public void setWordValue(int value)
    Sets the Value of the current content descriptor.
    Using this method will change descriptorTypeto TYPE_WORD

    Parameters:
    value - Value to set.

    toString

    public java.lang.String toString()
    (overridden)

    Overrides:
    toString in class java.lang.Object
    See Also:
    Object.toString()

    writeInto

    public int writeInto(java.io.OutputStream out)
                  throws java.io.IOException
    Writes this descriptor into the specified output stream.

    Parameters:
    out - stream to write into.
    Returns:
    amount of bytes written.
    Throws:
    java.io.IOException - on I/O Errors