| 1 | |
package org.jaudiotagger.audio.asf.tag; |
| 2 | |
|
| 3 | |
import org.jaudiotagger.audio.asf.data.AsfHeader; |
| 4 | |
import org.jaudiotagger.audio.asf.data.ContentDescriptor; |
| 5 | |
import org.jaudiotagger.audio.asf.util.Utils; |
| 6 | |
import org.jaudiotagger.tag.TagTextField; |
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
public class AsfTagTextField extends AsfTagField implements TagTextField |
| 14 | |
{ |
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
public AsfTagTextField(ContentDescriptor source) |
| 22 | |
{ |
| 23 | 800 | super(source); |
| 24 | 800 | if (source.getType() == ContentDescriptor.TYPE_BINARY) |
| 25 | |
{ |
| 26 | 0 | throw new IllegalArgumentException("Cannot interpret binary as string."); |
| 27 | |
} |
| 28 | 800 | } |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
public AsfTagTextField(String fieldKey, String value) |
| 36 | |
{ |
| 37 | 1779 | super(new ContentDescriptor(fieldKey, ContentDescriptor.TYPE_STRING)); |
| 38 | 1779 | setContent(value); |
| 39 | 1779 | } |
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | |
public String getContent() |
| 45 | |
{ |
| 46 | 2915 | return getDescriptor().getString(); |
| 47 | |
} |
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
public String getEncoding() |
| 53 | |
{ |
| 54 | 4 | return AsfHeader.ASF_CHARSET.name(); |
| 55 | |
} |
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
public void setContent(String content) |
| 61 | |
{ |
| 62 | 1779 | getDescriptor().setStringValue(content); |
| 63 | 1779 | } |
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
public void setEncoding(String encoding) |
| 69 | |
{ |
| 70 | 0 | if (!AsfHeader.ASF_CHARSET.name().equals(encoding)) |
| 71 | |
{ |
| 72 | 0 | throw new IllegalArgumentException("Only UTF-16LE is possible with ASF."); |
| 73 | |
} |
| 74 | 0 | } |
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
public boolean isEmpty() |
| 80 | |
{ |
| 81 | 1152 | return Utils.isBlank(getContent()); |
| 82 | |
} |
| 83 | |
} |