Methods Summary |
---|
public void | addChunk(Chunk toAdd)Adds a chunk to the container.
final List<Chunk> list = assertChunkList(toAdd.getGuid());
if (!list.isEmpty() && !MULTI_CHUNKS.contains(toAdd.getGuid())) {
throw new IllegalArgumentException(
"The GUID of the given chunk indicates, that there is no more instance allowed."); //$NON-NLS-1$
}
list.add(toAdd);
assert chunkstartsUnique(this) : "Chunk has equal start position like an already inserted one."; //$NON-NLS-1$
|
protected java.util.List | assertChunkList(GUID lookFor)This method asserts that a {@link List} exists for the given {@link GUID}
, in {@link #chunkTable}.
List<Chunk> result = this.chunkTable.get(lookFor);
if (result == null) {
result = new ArrayList<Chunk>();
this.chunkTable.put(lookFor, result);
}
return result;
|
protected static boolean | chunkstartsUnique(org.jaudiotagger.audio.asf.data.ChunkContainer container)Tests whether all stored chunks have a unique starting position among
their brothers.
MULTI_CHUNKS = new HashSet<GUID>();
MULTI_CHUNKS.add(GUID.GUID_STREAM);
boolean result = true;
final Set<Long> chunkStarts = new HashSet<Long>();
final Collection<Chunk> chunks = container.getChunks();
for (final Chunk curr : chunks) {
result &= chunkStarts.add(curr.getPosition());
}
return result;
|
public java.util.Collection | getChunks()Returns a collection of all contained chunks.
final List<Chunk> result = new ArrayList<Chunk>();
for (final List<Chunk> curr : this.chunkTable.values()) {
result.addAll(curr);
}
return result;
|
protected Chunk | getFirst(GUID lookFor, java.lang.Class instanceOf)Looks for the first stored chunk which has the given GUID.
Chunk result = null;
final List<Chunk> list = this.chunkTable.get(lookFor);
if (list != null && !list.isEmpty()) {
final Chunk chunk = list.get(0);
if (instanceOf.isAssignableFrom(chunk.getClass())) {
result = chunk;
}
}
return result;
|
public boolean | hasChunkByGUID(GUID lookFor)This method checks if a chunk has been {@linkplain #addChunk(Chunk)
added} with specified {@linkplain Chunk#getGuid() GUID}.
return this.chunkTable.containsKey(lookFor);
|
public java.lang.String | prettyPrint(java.lang.String prefix){@inheritDoc}
return prettyPrint(prefix, "");
|
public java.lang.String | prettyPrint(java.lang.String prefix, java.lang.String containerInfo)Nearly the same as {@link #prettyPrint(String)} however, additional
information can be injected below the {@link Chunk#prettyPrint(String)}
output and the listing of the contained chunks.
final StringBuilder result = new StringBuilder(super.prettyPrint(prefix));
result.append(containerInfo);
result.append(prefix).append(" |").append(Utils.LINE_SEPARATOR);
final ArrayList<Chunk> list = new ArrayList<Chunk>(getChunks());
Collections.sort(list, new ChunkPositionComparator());
for (Chunk curr : list) {
result.append(curr.prettyPrint(prefix + " |"));
result.append(prefix).append(" |").append(Utils.LINE_SEPARATOR);
}
return result.toString();
|