org.jaudiotagger.tag.vorbiscomment
Class VorbisCommentTagField

java.lang.Object
  extended by org.jaudiotagger.tag.vorbiscomment.VorbisCommentTagField
All Implemented Interfaces:
TagField, TagTextField

public class VorbisCommentTagField
extends java.lang.Object
implements TagTextField

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

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

Field Summary
private  boolean common
          If true, the id of the current encapsulated tag field is specified as a common field.
private  java.lang.String content
          Stores the content of the tag field.
private static java.lang.String ERRONEOUS_ID
          If id is invalid
private  java.lang.String id
          Stores the id (name) of the tag field.
 
Constructor Summary
VorbisCommentTagField(byte[] raw)
          Creates an instance.
VorbisCommentTagField(java.lang.String fieldId, java.lang.String fieldContent)
          Creates an instance.
 
Method Summary
private  void checkCommon()
          This method examines the ID of the current field and modifies commonin order to reflect if the tag id is a commonly used one.
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)
          This method copies the data of the given field to the current data.
protected  byte[] getBytes(java.lang.String s, java.lang.String encoding)
          This method will try to return the byte representation of the given string after it has been converted to the given encoding.
 java.lang.String getContent()
          Returns the content of the field.
 java.lang.String getEncoding()
          Returns the current used charset encoding.
 java.lang.String getId()
          Returns the Id of the represented tag field.
This value should uniquely identify a kind of tag data, like title.
 byte[] getRawContent()
          This method delivers the binary representation of the fields data in order to be directly written to the file.
 boolean isBinary()
          Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.
 void isBinary(boolean b)
          This method will set the field to represent binary data.

Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this method to perform useful operations.

 boolean isCommon()
          Identifies a field to be of common use.

Some software may differ between common and not common fields.

 boolean isEmpty()
          Determines whether the content of the field is empty.
 void setContent(java.lang.String s)
          Sets the content of the field.
 void setEncoding(java.lang.String s)
          Sets the charset encoding used by the field.
 java.lang.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
 

Field Detail

common

private boolean common
If true, the id of the current encapsulated tag field is specified as a common field.
Example is "ARTIST" which should be interpreted by any application as the artist of the media content.
Will be set during construction with checkCommon().


content

private java.lang.String content
Stores the content of the tag field.


id

private java.lang.String id
Stores the id (name) of the tag field.


ERRONEOUS_ID

private static final java.lang.String ERRONEOUS_ID
If id is invalid

See Also:
Constant Field Values
Constructor Detail

VorbisCommentTagField

public VorbisCommentTagField(byte[] raw)
                      throws java.io.UnsupportedEncodingException
Creates an instance.

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

VorbisCommentTagField

public VorbisCommentTagField(java.lang.String fieldId,
                             java.lang.String fieldContent)
Creates an instance.

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

checkCommon

private void checkCommon()
This method examines the ID of the current field and modifies commonin order to reflect if the tag id is a commonly used one.


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)
Description copied from interface: TagField
This method copies the data of the given field to the current data.

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

getBytes

protected byte[] getBytes(java.lang.String s,
                          java.lang.String encoding)
                   throws java.io.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:
java.io.UnsupportedEncodingException - If the requested encoding is not available.

getContent

public java.lang.String getContent()
Description copied from interface: TagTextField
Returns the content of the field.

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

getEncoding

public java.lang.String getEncoding()
Description copied from interface: TagTextField
Returns the current used charset encoding.

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

getId

public java.lang.String getId()
Description copied from interface: TagField
Returns the Id of the represented tag field.
This value should uniquely identify a kind of tag data, like title. AbstractTag will use the "id" to summarize multiple fields.

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

getRawContent

public byte[] getRawContent()
                     throws java.io.UnsupportedEncodingException
Description copied from interface: TagField
This method delivers the binary representation of the fields data in order to be directly written to the file.

Specified by:
getRawContent in interface TagField
Returns:
Binary data representing the current tag field.
Throws:
java.io.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()
Description copied from interface: TagField
Determines whether the represented field contains (is made up of) binary data, instead of text data.
Software can identify fields to be displayed because they are human readable if this method returns false.

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)
Description copied from interface: TagField
This method will set the field to represent binary data.

Some implementations may support conversions.
As of now (Octobre 2005) there is no implementation really using this method to perform useful operations.

Specified by:
isBinary in interface TagField
Parameters:
b - true, if the field contains binary data. //@deprecated As for now is of no use. Implementations should use another // way of setting this property.
See Also:
TagField.isBinary(boolean)

isCommon

public boolean isCommon()
Description copied from interface: TagField
Identifies a field to be of common use.

Some software may differ between common and not common fields. A common one is for sure the title field. A web link may not be of common use for tagging. However some file formats, or future development of users expectations will make more fields common than now can be known.

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

isEmpty

public boolean isEmpty()
Description copied from interface: TagField
Determines whether the content of the field is empty.

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

setContent

public void setContent(java.lang.String s)
Description copied from interface: TagTextField
Sets the content of the field.

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

setEncoding

public void setEncoding(java.lang.String s)
Description copied from interface: TagTextField
Sets the charset encoding used by the field.

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

toString

public java.lang.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 java.lang.Object
Returns:
Description of the fields content.