| 1 | package org.farng.mp3.id3; |
| 2 | |
| 3 | import org.farng.mp3.TagException; |
| 4 | import org.farng.mp3.TagNotFoundException; |
| 5 | |
| 6 | import java.io.IOException; |
| 7 | import java.io.RandomAccessFile; |
| 8 | |
| 9 | /** |
| 10 | * Superclass for all ID3v1 tags. |
| 11 | * |
| 12 | * @author $author$ |
| 13 | * @version $Revision: 1.3 $ |
| 14 | */ |
| 15 | public abstract class AbstractID3v1 extends AbstractID3 { |
| 16 | |
| 17 | /** |
| 18 | * Creates a new AbstractID3v1 object. |
| 19 | */ |
| 20 | protected AbstractID3v1() { |
| 21 | super(); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Creates a new AbstractID3v1 object. |
| 26 | */ |
| 27 | protected AbstractID3v1(final AbstractID3v1 copyObject) { |
| 28 | super(copyObject); |
| 29 | } |
| 30 | |
| 31 | public void append(final RandomAccessFile file) throws IOException, TagException { |
| 32 | AbstractID3v1 oldTag; |
| 33 | try { |
| 34 | oldTag = new ID3v1_1(file); |
| 35 | oldTag.append(this); |
| 36 | oldTag.write(file); |
| 37 | } catch (TagNotFoundException ex) { |
| 38 | try { |
| 39 | oldTag = new ID3v1(file); |
| 40 | oldTag.append(this); |
| 41 | oldTag.write(file); |
| 42 | } catch (TagNotFoundException ex2) { |
| 43 | write(file); |
| 44 | } |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | public void overwrite(final RandomAccessFile file) throws IOException, TagException { |
| 49 | AbstractID3v1 oldTag; |
| 50 | try { |
| 51 | oldTag = new ID3v1_1(file); |
| 52 | oldTag.overwrite(this); |
| 53 | oldTag.write(file); |
| 54 | } catch (TagNotFoundException ex) { |
| 55 | try { |
| 56 | oldTag = new ID3v1(file); |
| 57 | oldTag.overwrite(this); |
| 58 | oldTag.write(file); |
| 59 | } catch (TagNotFoundException ex2) { |
| 60 | write(file); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | } |