|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object entagged.audioformats.asf.util.AsfCopyrightField
public final class AsfCopyrightField
This class represents the copyright field of asf files.
The copyright cannot be accessed like an ordinary "name"-"value"-property,
since it has a defined position within the asf structure.
Use:
If you want to modify the copyright field of asf files using the entagged
audio library, you should access it using this class.
You can get a it using Tag.get(String)
. The
argument must be the value of FIELD_ID
, since the reading facility
of asf files will place the copyright there. (consider that the copyright
field of asf fils is only supported once, you may place several copyright
fields into Tag
, however only the first one
will be written.)
It is recommended to use the setString(String)
method if possible
because only then you will get feedback of validity checks. If your
environment doesn't support "UTF-16LE" encoding or the
"UTF-16LE"-representation would exceed 65533 Bytes you will be notified.
Otherwise if you use the standard method setContent(String)
, the
value "Conversion Exception occured." will be placed on errors.
Alternative:
You can use your own implementation of
TagField
, then you must remember using
FIELD_ID
as the "ID", since the asf writing methods will look at
that for writing the file. Additional isCommon() must return
true
Example :
Reading copyright
AudioFile file = AudioFileIO.read(new File("/somewhere/test.wma"));
// Get the copyright field
TagTextField copyright = AsfCopyrightField.getCopyright(file.getTag());
// Will be null, if no copyright is specified.
if (copyright != null)
System.out.println(copyright.getContent());
AudioFile file = AudioFileIO.read(new File("/somewhere/test.wma"));
// Get the copyright field
TagTextField copyright = AsfCopyrightField.getCopyright(file.getTag());
// Will be null, if no copyright is specified.
if (copyright != null) {
System.out.println(copyright.getContent());
// setThe value
copyright.setContent("It belongs to me now.");
}
AudioFileIO.write(file);
AudioFile file = AudioFileIO.read(new File("/somewhere/test.wma"));
// Create field
TagTextField copyright = new AsfCopyrightField();
// setThe value
copyright.setContent("My intellectual property");
// Add the new field
file.getTag().set(copyright);
AudioFileIO.write(file);
AudioFile file = AudioFileIO.read(new File("/somewhere/test.wma"));
// Create field
TagTextField copyright = new AsfCopyrightField();
// Without a value, the field will be deleted.
file.getTag().set(copyright);
AudioFileIO.write(file);
isCommon()
will always return true
,
so that the represented value will not be handled as a
"name"-"value"-property. The
TagConverter
will identify this field
at
TagConverter.createContentDescription(Tag)
and place the value into the corresponding java object (
ContentDescription
).
Field Summary | |
---|---|
static String |
FIELD_ID
This constant represents the field id of the currently represented copyright field. |
Constructor Summary | |
---|---|
AsfCopyrightField()
|
Method Summary | |
---|---|
void |
copyContent(TagField field)
(overridden) |
String |
getContent()
(overridden) |
static TagTextField |
getCopyright(Tag tag)
This method should help programmers to extract the copyright field out of asf files. |
String |
getEncoding()
(overridden) |
String |
getId()
(overridden) Will return FIELD_ID . |
byte[] |
getRawContent()
(overridden) |
boolean |
isBinary()
(overridden) |
void |
isBinary(boolean b)
(overridden) |
boolean |
isCommon()
(overridden) This Method will return true, so it won't be used for the extended content description chunk, where the "name"-"value" properties are stored. |
boolean |
isEmpty()
(overridden) |
void |
setContent(String s)
(overridden) |
void |
setEncoding(String s)
(overridden) |
void |
setString(String s)
This method sets the content of the current copyright field. |
String |
toString()
(overridden) |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String FIELD_ID
TagConverter
.
Constructor Detail |
---|
public AsfCopyrightField()
Method Detail |
---|
public static TagTextField getCopyright(Tag tag)
tag
- The tag which contains the copyright field.
null
if the tag represents a file which is not a
asf file, or no copyright has been entered.public void copyContent(TagField field)
copyContent
in interface TagField
field
- The field containing the data to be taken.TagField.copyContent(entagged.audioformats.generic.TagField)
public String getContent()
getContent
in interface TagTextField
TagTextField.getContent()
public String getEncoding()
getEncoding
in interface TagTextField
TagTextField.getEncoding()
public String getId()
FIELD_ID
.
getId
in interface TagField
TagField.getId()
public byte[] getRawContent() throws UnsupportedEncodingException
getRawContent
in interface TagField
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.TagField.getRawContent()
public boolean isBinary()
isBinary
in interface TagField
true
if field represents binary data (not human
readable).TagField.isBinary()
public void isBinary(boolean b)
isBinary
in interface TagField
b
- true
, if the field contains binary data.TagField.isBinary(boolean)
public boolean isCommon()
isCommon
in interface TagField
true
if the field is of common use.TagConverter.assignOptionalTagValues(Tag,
ExtendedContentDescription)
,
TagField.isCommon()
public boolean isEmpty()
isEmpty
in interface TagField
true
if no data is stored (or empty String).TagField.isEmpty()
public void setContent(String s)
setContent
in interface TagTextField
s
- fields content.TagTextField.setContent(java.lang.String)
public void setEncoding(String s)
setEncoding
in interface TagTextField
s
- charset.TagTextField.setEncoding(java.lang.String)
public void setString(String s)
s
- The new copyright.
IllegalArgumentException
- If the size of the value would exceed 65535 bytes in UTF-16LE
encoding including two bytes for zero termination.public String toString()
toString
in interface TagField
toString
in class Object
TagField.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |