| 1 | package org.farng.mp3.object; |
| 2 | |
| 3 | /** |
| 4 | * ID3v2 and Lyrics3v2 tags have individual fields <code>AbstractMP3Fragment</code>s Then each fragment is broken down |
| 5 | * in to individual <code>AbstractMP3Object</code>s |
| 6 | * |
| 7 | * @author Eric Farng |
| 8 | * @version $Revision: 1.5 $ |
| 9 | */ |
| 10 | public class ObjectBooleanString extends AbstractMP3Object { |
| 11 | |
| 12 | /** |
| 13 | * Creates a new ObjectBooleanString object. |
| 14 | */ |
| 15 | public ObjectBooleanString(final String identifier) { |
| 16 | this.identifier = identifier; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Creates a new ObjectBooleanString object. |
| 21 | */ |
| 22 | public ObjectBooleanString(final ObjectBooleanString object) { |
| 23 | super(object); |
| 24 | } |
| 25 | |
| 26 | public int getSize() { |
| 27 | return 1; |
| 28 | } |
| 29 | |
| 30 | public boolean equals(final Object obj) { |
| 31 | if (obj instanceof ObjectBooleanString == false) { |
| 32 | return false; |
| 33 | } |
| 34 | return super.equals(obj); |
| 35 | } |
| 36 | |
| 37 | public void readString(final String str, final int offset) { |
| 38 | if (str == null) { |
| 39 | throw new NullPointerException("String is null"); |
| 40 | } |
| 41 | if ((offset < 0) || (offset >= str.length())) { |
| 42 | throw new IndexOutOfBoundsException("Offset to image string is out of bounds: offset = " + |
| 43 | offset + |
| 44 | ", string.length()" + |
| 45 | str.length()); |
| 46 | } |
| 47 | final char ch = str.charAt(offset); |
| 48 | this.value = new Boolean(ch != '0'); |
| 49 | } |
| 50 | |
| 51 | public String toString() { |
| 52 | return "" + this.value; |
| 53 | } |
| 54 | |
| 55 | public String writeString() { |
| 56 | if (this.value == null) { |
| 57 | // default false |
| 58 | return "0"; |
| 59 | } |
| 60 | return ((Boolean) this.value).booleanValue() ? "1" : "0"; |
| 61 | } |
| 62 | } |