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