public class MetadataContainer extends Chunk implements WriteableChunk
chunkLength, guid, position
Constructor and Description |
---|
MetadataContainer(ContainerType type)
Creates an instance.
|
MetadataContainer(ContainerType type,
long pos,
BigInteger size)
Creates an instance.
|
MetadataContainer(GUID containerGUID,
long pos,
BigInteger size)
Creates an instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addDescriptor(MetadataDescriptor toAdd)
Adds a metadata descriptor.
|
protected MetadataDescriptor |
assertDescriptor(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(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. |
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.
|
List<MetadataDescriptor> |
getDescriptors()
Returns all stored descriptors.
|
List<MetadataDescriptor> |
getDescriptorsByName(String name)
Returns a list of descriptors with the given
name.
|
protected String |
getValueFor(String name)
This method looks up a descriptor with given name and returns its value
as string.
|
boolean |
hasDescriptor(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. |
String |
prettyPrint(String prefix)
This method creates a String containing useful information prepared to be
printed on STD-OUT.
|
void |
removeDescriptorsByName(String name)
Removes all stored descriptors with the given
name.
|
protected void |
setStringValue(String name,
String value)
|
long |
writeInto(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
public MetadataContainer(ContainerType type)
type
- determines the type of the containerpublic MetadataContainer(ContainerType type, long pos, BigInteger size)
type
- determines the type of the containerpos
- location in the ASF filesize
- size of the chunk.public MetadataContainer(GUID containerGUID, long pos, BigInteger size)
containerGUID
- the containers GUIDpos
- location in the ASF filesize
- size of the chunk.public final void addDescriptor(MetadataDescriptor toAdd) throws IllegalArgumentException
toAdd
- the descriptor to add.IllegalArgumentException
- if descriptor does not meet container requirements, or
already exist.protected final MetadataDescriptor assertDescriptor(String key)
key
- the descriptor name to look up (or create)MetadataDescriptor.TYPE_STRING
.protected final MetadataDescriptor assertDescriptor(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 List<MetadataDescriptor> getDescriptors()
public final List<MetadataDescriptor> getDescriptorsByName(String name)
name
- name of the descriptors to returnprotected final String getValueFor(String name)
name
- the name of the descriptor to look up.public final boolean hasDescriptor(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 String prettyPrint(String prefix)
prettyPrint
in class Chunk
prefix
- each line gets this string prepended.public final void removeDescriptorsByName(String name)
name
- the name to remove.protected final void setStringValue(String name, String value)
name
- the name of the descriptor to set the value for.value
- the string value.public long writeInto(OutputStream out) throws IOException
writeInto
in interface WriteableChunk
out
- stream to write into.IOException
- on I/O errorsCopyright © 2005–2020 jthink.net. All rights reserved.