public class MetadataContainer extends Chunk implements WriteableChunk
Modifier and Type | Class and Description |
---|---|
private static class |
MetadataContainer.DescriptorPointer
This class is used to uniquely identify an enclosed descriptor by its
name, language index and stream number.
The type of the descriptor is ignored, since it just specifies the data content. |
Modifier and Type | Field and Description |
---|---|
private ContainerType |
containerType
stores the represented container type.
|
private java.util.Map<MetadataContainer.DescriptorPointer,java.util.List<MetadataDescriptor>> |
descriptors
Stores the descriptors.
|
private MetadataContainer.DescriptorPointer |
perfPoint
for performance reasons this instance is used to look up existing
descriptors in
descriptors . |
chunkLength, guid, position
Constructor and Description |
---|
MetadataContainer(ContainerType type)
Creates an instance.
|
MetadataContainer(ContainerType type,
long pos,
java.math.BigInteger size)
Creates an instance.
|
MetadataContainer(GUID containerGUID,
long pos,
java.math.BigInteger size)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addDescriptor(MetadataDescriptor toAdd)
Adds a metadata descriptor.
|
protected MetadataDescriptor |
assertDescriptor(java.lang.String key)
This method asserts that this container has a descriptor with the
specified key, means returns an existing or creates a new descriptor.
|
protected MetadataDescriptor |
assertDescriptor(java.lang.String key,
int type)
This method asserts that this container has a descriptor with the
specified key, means returns an existing or creates a new descriptor.
|
boolean |
containsDescriptor(MetadataDescriptor lookup)
Checks whether a descriptor already exists.
Name, stream number and language index are compared. |
private static ContainerType |
determineType(GUID guid)
Looks up all guids and
returns the matching type.
|
ContainerType |
getContainerType()
Returns the type of container this instance represents.
|
long |
getCurrentAsfChunkSize()
This method calculates the total amount of bytes, the chunk would consume
in an ASF file.
|
int |
getDescriptorCount()
Returns the number of contained descriptors.
|
java.util.List<MetadataDescriptor> |
getDescriptors()
Returns all stored descriptors.
|
java.util.List<MetadataDescriptor> |
getDescriptorsByName(java.lang.String name)
Returns a list of descriptors with the given
name.
|
protected java.lang.String |
getValueFor(java.lang.String name)
This method looks up a descriptor with given name and returns its value
as string.
|
boolean |
hasDescriptor(java.lang.String name)
Determines if this container contains a descriptor with given
name.
|
boolean |
isAddSupported(MetadataDescriptor descriptor)
Determines/checks if the given descriptor may be added to the container.
This implies a check for the capabilities of the container specified by its container type. |
boolean |
isEmpty()
true if it is not necessary to write the chunk into an ASF
file, since it contains no information. |
java.lang.String |
prettyPrint(java.lang.String prefix)
This method creates a String containing useful information prepared to be
printed on STD-OUT.
|
void |
removeDescriptorsByName(java.lang.String name)
Removes all stored descriptors with the given
name.
|
protected void |
setStringValue(java.lang.String name,
java.lang.String value)
|
long |
writeInto(java.io.OutputStream out)
Writes the chunk into the specified output stream, as ASF stream chunk.
|
getChunckEnd, getChunkEnd, getChunkLength, getGuid, getPosition, setPosition, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getGuid
private final ContainerType containerType
private final java.util.Map<MetadataContainer.DescriptorPointer,java.util.List<MetadataDescriptor>> descriptors
private final MetadataContainer.DescriptorPointer perfPoint
descriptors
.public MetadataContainer(ContainerType type)
type
- determines the type of the containerpublic MetadataContainer(ContainerType type, long pos, java.math.BigInteger size)
type
- determines the type of the containerpos
- location in the ASF filesize
- size of the chunk.public MetadataContainer(GUID containerGUID, long pos, java.math.BigInteger size)
containerGUID
- the containers GUIDpos
- location in the ASF filesize
- size of the chunk.private static ContainerType determineType(GUID guid) throws java.lang.IllegalArgumentException
guid
- GUID to look upjava.lang.IllegalArgumentException
- if no container type matchespublic final void addDescriptor(MetadataDescriptor toAdd) throws java.lang.IllegalArgumentException
toAdd
- the descriptor to add.java.lang.IllegalArgumentException
- if descriptor does not meet container requirements, or
already exist.protected final MetadataDescriptor assertDescriptor(java.lang.String key)
key
- the descriptor name to look up (or create)MetadataDescriptor.TYPE_STRING
.protected final MetadataDescriptor assertDescriptor(java.lang.String key, int type)
key
- the descriptor name to look up (or create)type
- if the descriptor is created, this data type is applied.public final boolean containsDescriptor(MetadataDescriptor lookup)
lookup
- descriptor to look up.true
if such a descriptor already exists.public final ContainerType getContainerType()
public long getCurrentAsfChunkSize()
getCurrentAsfChunkSize
in interface WriteableChunk
public final int getDescriptorCount()
public final java.util.List<MetadataDescriptor> getDescriptors()
public final java.util.List<MetadataDescriptor> getDescriptorsByName(java.lang.String name)
name
- name of the descriptors to returnprotected final java.lang.String getValueFor(java.lang.String name)
name
- the name of the descriptor to look up.public final boolean hasDescriptor(java.lang.String name)
name
- Name of the descriptor to look for.true
if descriptor has been found.public boolean isAddSupported(MetadataDescriptor descriptor)
descriptor
- the descriptor to test.true
if addDescriptor(MetadataDescriptor)
can be called with given descriptor.public final boolean isEmpty()
true
if it is not necessary to write the chunk into an ASF
file, since it contains no information.isEmpty
in interface WriteableChunk
true
if no useful data will be preserved.public java.lang.String prettyPrint(java.lang.String prefix)
prettyPrint
in class Chunk
prefix
- each line gets this string prepended.public final void removeDescriptorsByName(java.lang.String name)
name
- the name to remove.protected final void setStringValue(java.lang.String name, java.lang.String value)
name
- the name of the descriptor to set the value for.value
- the string value.public long writeInto(java.io.OutputStream out) throws java.io.IOException
writeInto
in interface WriteableChunk
out
- stream to write into.java.io.IOException
- on I/O errorsCopyright © 2005-2013 java.net. All Rights Reserved.