entagged.audioformats.ogg.util
Class OggTagField

java.lang.Object
  extended by entagged.audioformats.ogg.util.OggTagField
All Implemented Interfaces:
TagField, TagTextField

public class OggTagField
extends Object
implements TagTextField

This class encapsulates the name and content of a tag entry in ogg-files.

Author:
@author Raphael Slinckx (KiKiDonK), Christian Laireiter (liree)

Constructor Summary
OggTagField(byte[] raw)
          Creates an instance.
OggTagField(String fieldId, String fieldContent)
          Creates an instance.
 
Method Summary
protected  void copy(byte[] src, byte[] dst, int dstOffset)
          This method will copy all bytes of src to dst at the specified location.
 void copyContent(TagField field)
          (overridden)
protected  byte[] getBytes(String s, String encoding)
          This method will try to return the byte representation of the given string after it has been converted to the given encoding.
 String getContent()
          (overridden)
 String getEncoding()
          (overridden)
 String getId()
          (overridden)
 byte[] getRawContent()
          (overridden)
 boolean isBinary()
          (overridden)
 void isBinary(boolean b)
          (overridden)
 boolean isCommon()
          (overridden)
 boolean isEmpty()
          (overridden)
 void setContent(String s)
          (overridden)
 void setEncoding(String s)
          (overridden)
 String toString()
          This method returns a human readable description of the fields contents.
For text fields it should be the text itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

OggTagField

public OggTagField(byte[] raw)
            throws UnsupportedEncodingException
Creates an instance.

Parameters:
raw - Raw byte data of the tagfield.
Throws:
UnsupportedEncodingException - If the data doesn't conform "UTF-8" specification.

OggTagField

public OggTagField(String fieldId,
                   String fieldContent)
Creates an instance.

Parameters:
fieldId - ID (name) of the field.
fieldContent - Content of the field.
Method Detail

copy

protected void copy(byte[] src,
                    byte[] dst,
                    int dstOffset)
This method will copy all bytes of src to dst at the specified location.

Parameters:
src - bytes to copy.
dst - where to copy to.
dstOffset - at which position of dst the data should be copied.

copyContent

public void copyContent(TagField field)
(overridden)

Specified by:
copyContent in interface TagField
Parameters:
field - The field containing the data to be taken.
See Also:
TagField.copyContent(entagged.audioformats.generic.TagField)

getBytes

protected byte[] getBytes(String s,
                          String encoding)
                   throws UnsupportedEncodingException
This method will try to return the byte representation of the given string after it has been converted to the given encoding.

Parameters:
s - The string whose converted bytes should be returned.
encoding - The encoding type to which the string should be converted.
Returns:
If encoding is supported the byte data of the given string is returned in that encoding.
Throws:
UnsupportedEncodingException - If the requested encoding is not available.

getContent

public String getContent()
(overridden)

Specified by:
getContent in interface TagTextField
Returns:
Content
See Also:
TagTextField.getContent()

getEncoding

public String getEncoding()
(overridden)

Specified by:
getEncoding in interface TagTextField
Returns:
Charset encoding.
See Also:
TagTextField.getEncoding()

getId

public String getId()
(overridden)

Specified by:
getId in interface TagField
Returns:
Unique identifier for the fields type. (title, artist...)
See Also:
TagField.getId()

getRawContent

public byte[] getRawContent()
                     throws UnsupportedEncodingException
(overridden)

Specified by:
getRawContent in interface TagField
Returns:
Binary data representing the current tag field.
Throws:
UnsupportedEncodingException - Most tag data represents text. In some cases the underlying implementation will need to convert the text data in java to a specific charset encoding. In these cases an UnsupportedEncodingException may occur.
See Also:
TagField.getRawContent()

isBinary

public boolean isBinary()
(overridden)

Specified by:
isBinary in interface TagField
Returns:
true if field represents binary data (not human readable).
See Also:
TagField.isBinary()

isBinary

public void isBinary(boolean b)
(overridden)

Specified by:
isBinary in interface TagField
Parameters:
b - true, if the field contains binary data.
See Also:
TagField.isBinary(boolean)

isCommon

public boolean isCommon()
(overridden)

Specified by:
isCommon in interface TagField
Returns:
true if the field is of common use.
See Also:
TagField.isCommon()

isEmpty

public boolean isEmpty()
(overridden)

Specified by:
isEmpty in interface TagField
Returns:
true if no data is stored (or empty String).
See Also:
TagField.isEmpty()

setContent

public void setContent(String s)
(overridden)

Specified by:
setContent in interface TagTextField
Parameters:
s - fields content.
See Also:
TagTextField.setContent(java.lang.String)

setEncoding

public void setEncoding(String s)
(overridden)

Specified by:
setEncoding in interface TagTextField
Parameters:
s - charset.
See Also:
TagTextField.setEncoding(java.lang.String)

toString

public String toString()
Description copied from interface: TagField
This method returns a human readable description of the fields contents.
For text fields it should be the text itself. Other fields containing images may return a formatted string with image properties like width, height and so on.

Specified by:
toString in interface TagField
Overrides:
toString in class Object
Returns:
Description of the fields content.


Copyright © 2007-2008. All Rights Reserved.