public int getSize() { int size = 0; AbstractMP3Object object; final Iterator iterator = this.objectList.listIterator(); while (iterator.hasNext()) { object = (AbstractMP3Object) iterator.next(); size += object.getSize(); } return size; }
public String toString() { String str = ""; AbstractMP3Object object; final Iterator iterator = this.objectList.listIterator(); while (iterator.hasNext()) { object = (AbstractMP3Object) iterator.next(); str += (object.toString() + "\n"); } return str; }
public byte[] writeByteArray() { AbstractMP3Object object; final byte[] totalArray = new byte[this.getSize()]; byte[] objectArray; final Iterator iterator = this.objectList.listIterator(); while (iterator.hasNext()) { object = (AbstractMP3Object) iterator.next(); objectArray = object.writeByteArray(); System.arraycopy(objectArray, 0, totalArray, 0, totalArray.length); } return totalArray; }
public void readByteArray(final byte[] arr, int offset) { if (arr == null) { throw new NullPointerException("Byte array is null"); } if ((offset < 0) || (offset >= arr.length)) { throw new IndexOutOfBoundsException( "Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length); } AbstractMP3Object object; Class className; Iterator iterator; if (this.propertyList.size() > 0) { while (offset < arr.length) { iterator = this.propertyList.listIterator(); while (iterator.hasNext()) { className = iterator.next().getClass(); try { object = (AbstractMP3Object) className.newInstance(); this.objectList.add(object); object.readByteArray(arr, offset); offset += object.getSize(); } catch (IllegalAccessException ex) { ex.printStackTrace(); // do nothing, just skip this one } catch (InstantiationException ex) { ex.printStackTrace(); // do nothing, just skip this one } } } } }