org.jaudiotagger.audio.asf.data
Class GUID

java.lang.Object
  extended by org.jaudiotagger.audio.asf.data.GUID

public final class GUID
extends java.lang.Object

This class is used for representation of GUIDs and as a reference list of all Known GUIDs.

Author:
Christian Laireiter

Field Summary
private  java.lang.String description
          Stores an optionally description of the GUID.
static GUID GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT
          This constant defines the GUID for stream chunks describing audio streams, indicating the the audio stream has no error concealment.
static GUID GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED
          This constant defines the GUID for stream chunks describing audio streams, indicating the the audio stream has interleaved error concealment.
static GUID GUID_AUDIOSTREAM
          This constant stores the GUID indicating that stream type is audio.
static GUID GUID_CONTENT_BRANDING
          This constant stores the GUID indicating a content branding object.
static GUID GUID_CONTENT_ENCRYPTION
          This is for the Content Encryption Object 2211B3FB-BD23-11D2-B4B7-00A0C955FC6E, needs to be little-endian.
static GUID GUID_CONTENTDESCRIPTION
          This constant represents the guidData for a chunk which contains Title, author, copyright, description and rating.
static GUID GUID_ENCODING
          This constant stores the GUID for Encoding-Info chunks.
static GUID GUID_EXTENDED_CONTENT_DESCRIPTION
          This constant defines the GUID for a WMA "Extended Content Description" chunk.
static GUID GUID_FILE
          GUID of ASF file header.
static GUID GUID_HEADER
          This constant defines the GUID of a asf header chunk.
static GUID GUID_HEADER_EXTENSION
          This constant stores a GUID whose functionality is unknown.
static GUID GUID_LANGUAGE_LIST
          This constant stores the GUID indicating the asf language list object.
static int GUID_LENGTH
          This constant stores the length of GUIDs used with ASF streams.
static GUID GUID_METADATA
          This constant stores the GUID indicating the asf metadata object.
static GUID GUID_METADATA_LIBRARY
          This constant stores the GUID indicating the asf metadata library object.
private static java.util.regex.Pattern GUID_PATTERN
          The GUID String values format.
static GUID GUID_STREAM
          This constant stores the GUID indicating a stream object.
static GUID GUID_STREAM_BITRATE_PROPERTIES
          This constant stores a GUID indicating a "stream bitrate properties" chunk.
private static java.util.Map<GUID,GUID> GUID_TO_CONFIGURED
          This map is used, to get the description of a GUID instance, which has been created by reading.
The map comparison is done against the guidData field.
static GUID GUID_UNSPECIFIED
          This constant represents a GUID implementation which can be used for generic implementations, which have to provide a GUID, but do not really require a specific GUID to work.
static GUID GUID_VIDEOSTREAM
          This constant stores the GUID indicating that stream type is video.
private  int[] guidData
          An instance of this class stores the value of the wrapped GUID in this field.
private  int hash
          Stores the hash code of the object.
"-1" if not determined yet.
static GUID[] KNOWN_GUIDS
          This field stores all known GUIDs.
static GUID SCRIPT_COMMAND_OBJECT
          This constant stores the GUID for a "script command object".
 
Constructor Summary
GUID(byte[] value)
          Creates an instance and assigns given value.
GUID(int[] value)
          Creates an instance and assigns given value.
GUID(int[] value, java.lang.String desc)
          Creates an instance like GUID(int[])and sets the optional description.
GUID(java.lang.String guidString, java.lang.String desc)
          Creates an instance like GUID(int[]) and sets the optional description.
 
Method Summary
static boolean assertGUID(int[] value)
          This method checks if the given value is matching the GUID specification of ASF streams.
 boolean equals(java.lang.Object obj)
          This method compares two objects.
 byte[] getBytes()
          This method returns the GUID as an array of bytes.
static GUID getConfigured(GUID orig)
          This method looks up a GUID instance from KNOWN_GUIDS which matches the value of the given GUID.
 java.lang.String getDescription()
           
 int[] getGUID()
          This method returns the GUID of this object.
static java.lang.String getGuidDescription(GUID guid)
          This method searches a GUID in KNOWN_GUIDSwhich is equal to the given guidData and returns its description.
private  java.lang.String[] getHex(byte[] bytes)
          Convenience method to get 2digit hex values of each byte.
 int hashCode()
          
 boolean isValid()
          This method checks if the currently stored GUID (guidData) is correctly filled.
static GUID parseGUID(java.lang.String guid)
          This method parses a String as GUID.
The format is like the one in the ASF specification.
An Example: C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA
 java.lang.String prettyPrint()
          This method gives a hex formatted representation of getGUID()
private  void setGUID(int[] value)
          This method saves a copy of the given value as the represented value of this object.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT

public static final GUID GUID_AUDIO_ERROR_CONCEALEMENT_ABSENT
This constant defines the GUID for stream chunks describing audio streams, indicating the the audio stream has no error concealment.


GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED

public static final GUID GUID_AUDIO_ERROR_CONCEALEMENT_INTERLEAVED
This constant defines the GUID for stream chunks describing audio streams, indicating the the audio stream has interleaved error concealment.


GUID_AUDIOSTREAM

public static final GUID GUID_AUDIOSTREAM
This constant stores the GUID indicating that stream type is audio.


GUID_CONTENT_BRANDING

public static final GUID GUID_CONTENT_BRANDING
This constant stores the GUID indicating a content branding object.


GUID_CONTENT_ENCRYPTION

public static final GUID GUID_CONTENT_ENCRYPTION
This is for the Content Encryption Object 2211B3FB-BD23-11D2-B4B7-00A0C955FC6E, needs to be little-endian.


GUID_CONTENTDESCRIPTION

public static final GUID GUID_CONTENTDESCRIPTION
This constant represents the guidData for a chunk which contains Title, author, copyright, description and rating.


GUID_ENCODING

public static final GUID GUID_ENCODING
This constant stores the GUID for Encoding-Info chunks.


GUID_EXTENDED_CONTENT_DESCRIPTION

public static final GUID GUID_EXTENDED_CONTENT_DESCRIPTION
This constant defines the GUID for a WMA "Extended Content Description" chunk.


GUID_FILE

public static final GUID GUID_FILE
GUID of ASF file header.


GUID_HEADER

public static final GUID GUID_HEADER
This constant defines the GUID of a asf header chunk.


GUID_HEADER_EXTENSION

public static final GUID GUID_HEADER_EXTENSION
This constant stores a GUID whose functionality is unknown.


GUID_LANGUAGE_LIST

public static final GUID GUID_LANGUAGE_LIST
This constant stores the GUID indicating the asf language list object.


GUID_LENGTH

public static final int GUID_LENGTH
This constant stores the length of GUIDs used with ASF streams.

See Also:
Constant Field Values

GUID_METADATA

public static final GUID GUID_METADATA
This constant stores the GUID indicating the asf metadata object.


GUID_METADATA_LIBRARY

public static final GUID GUID_METADATA_LIBRARY
This constant stores the GUID indicating the asf metadata library object.


GUID_PATTERN

private static final java.util.regex.Pattern GUID_PATTERN
The GUID String values format.


GUID_STREAM

public static final GUID GUID_STREAM
This constant stores the GUID indicating a stream object.


GUID_STREAM_BITRATE_PROPERTIES

public static final GUID GUID_STREAM_BITRATE_PROPERTIES
This constant stores a GUID indicating a "stream bitrate properties" chunk.


GUID_TO_CONFIGURED

private static final java.util.Map<GUID,GUID> GUID_TO_CONFIGURED
This map is used, to get the description of a GUID instance, which has been created by reading.
The map comparison is done against the guidData field. But only the KNOWN_GUIDS have a description set.


GUID_UNSPECIFIED

public static final GUID GUID_UNSPECIFIED
This constant represents a GUID implementation which can be used for generic implementations, which have to provide a GUID, but do not really require a specific GUID to work.


GUID_VIDEOSTREAM

public static final GUID GUID_VIDEOSTREAM
This constant stores the GUID indicating that stream type is video.


KNOWN_GUIDS

public static final GUID[] KNOWN_GUIDS
This field stores all known GUIDs.


SCRIPT_COMMAND_OBJECT

public static final GUID SCRIPT_COMMAND_OBJECT
This constant stores the GUID for a "script command object".


description

private java.lang.String description
Stores an optionally description of the GUID.


guidData

private int[] guidData
An instance of this class stores the value of the wrapped GUID in this field.


hash

private int hash
Stores the hash code of the object.
"-1" if not determined yet.

Constructor Detail

GUID

public GUID(byte[] value)
Creates an instance and assigns given value.

Parameters:
value - GUID, which should be assigned. (will be converted to int[])

GUID

public GUID(int[] value)
Creates an instance and assigns given value.

Parameters:
value - GUID, which should be assigned.

GUID

public GUID(int[] value,
            java.lang.String desc)
Creates an instance like GUID(int[])and sets the optional description.

Parameters:
value - GUID, which should be assigned.
desc - Description for the GUID.

GUID

public GUID(java.lang.String guidString,
            java.lang.String desc)
Creates an instance like GUID(int[]) and sets the optional description. (the int[] is obtained by parseGUID(String))

Parameters:
guidString - GUID, which should be assigned.
desc - Description for the GUID.
Method Detail

assertGUID

public static boolean assertGUID(int[] value)
This method checks if the given value is matching the GUID specification of ASF streams.

Parameters:
value - possible GUID.
Returns:
true if value matches the specification of a GUID.

getConfigured

public static GUID getConfigured(GUID orig)
This method looks up a GUID instance from KNOWN_GUIDS which matches the value of the given GUID.

Parameters:
orig - GUID to look up.
Returns:
a GUID instance from KNOWN_GUIDS if available. null else.

getGuidDescription

public static java.lang.String getGuidDescription(GUID guid)
This method searches a GUID in KNOWN_GUIDSwhich is equal to the given guidData and returns its description.
This method is useful if a GUID was read out of a file and no identification has been done yet.

Parameters:
guid - GUID, which description is needed.
Returns:
description of the GUID if found. Else null

parseGUID

public static GUID parseGUID(java.lang.String guid)
                      throws GUIDFormatException
This method parses a String as GUID.
The format is like the one in the ASF specification.
An Example: C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA

Parameters:
guid - the string to parse.
Returns:
the GUID.
Throws:
GUIDFormatException - If the GUID has an invalid format.

equals

public boolean equals(java.lang.Object obj)
This method compares two objects. If the given Object is a GUID, the stored GUID values are compared.

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

getBytes

public byte[] getBytes()
This method returns the GUID as an array of bytes.

Returns:
The GUID as a byte array.
See Also:
getGUID()

getDescription

public java.lang.String getDescription()
Returns:
Returns the description.

getGUID

public int[] getGUID()
This method returns the GUID of this object.

Returns:
stored GUID.

getHex

private java.lang.String[] getHex(byte[] bytes)
Convenience method to get 2digit hex values of each byte.

Parameters:
bytes - bytes to convert.
Returns:
each byte as 2 digit hex.

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

isValid

public boolean isValid()
This method checks if the currently stored GUID (guidData) is correctly filled.

Returns:
true if it is.

prettyPrint

public java.lang.String prettyPrint()
This method gives a hex formatted representation of getGUID()

Returns:
hex formatted representation.

setGUID

private void setGUID(int[] value)
This method saves a copy of the given value as the represented value of this object.
The given value is checked with assertGUID(int[]).

Parameters:
value - GUID to assign.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object