| 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 ObjectStringSizeTerminated extends AbstractMP3Object { |
| 11 | |
| 12 | /** |
| 13 | * Creates a new ObjectStringSizeTerminated object. |
| 14 | */ |
| 15 | public ObjectStringSizeTerminated(final String identifier) { |
| 16 | this.identifier = identifier; |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * Creates a new ObjectStringSizeTerminated object. |
| 21 | */ |
| 22 | public ObjectStringSizeTerminated(final ObjectStringSizeTerminated object) { |
| 23 | super(object); |
| 24 | } |
| 25 | |
| 26 | public int getSize() { |
| 27 | final String str = writeString(); |
| 28 | if (str != null) { |
| 29 | return str.length(); |
| 30 | } |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | public boolean equals(final Object obj) { |
| 35 | if (obj instanceof ObjectStringSizeTerminated == false) { |
| 36 | return false; |
| 37 | } |
| 38 | return super.equals(obj); |
| 39 | } |
| 40 | |
| 41 | public void readString(final String str, final int offset) { |
| 42 | if (str == null) { |
| 43 | throw new NullPointerException("String is null"); |
| 44 | } |
| 45 | if ((offset < 0) || (offset >= str.length())) { |
| 46 | throw new IndexOutOfBoundsException("Offset to String is out of bounds: offset = " + |
| 47 | offset + |
| 48 | ", string.length()" + |
| 49 | str.length()); |
| 50 | } |
| 51 | this.value = str.substring(offset); |
| 52 | } |
| 53 | |
| 54 | public String toString() { |
| 55 | return writeString(); |
| 56 | } |
| 57 | |
| 58 | public String writeString() { |
| 59 | return (String) this.value; |
| 60 | } |
| 61 | } |