Copyright 2013-01-06 Werner Randelshofer

org.monte.media
Class Format

java.lang.Object
  extended by org.monte.media.Format

public class Format
extends java.lang.Object

Specifies the format of a media, for example of audio and video.

Version:
$Id: Format.java 299 2013-01-03 07:40:18Z werner $
Author:
Werner Randelshofer

Constructor Summary
Format(java.util.Map<FormatKey,java.lang.Object> properties)
          Creates a new format onlyWith the specified properties.
Format(java.lang.Object... p)
          Creates a new format onlyWith the specified properties.
 
Method Summary
 Format append(Format that)
          Creates a new format which contains all properties from this format and additional properties from that format.
 Format append(java.lang.Object... p)
          Creates a new format which contains all properties from this format and additional properties listed.
 boolean containsKey(FormatKey key)
           
 Format containsKeys(FormatKey... keys)
          Returns true if the format has the specified keys.
<T> T
get(FormatKey<T> key)
           
<T> T
get(FormatKey<T> key, T defaultValue)
           
 java.util.Set<FormatKey> getKeys()
          Gets the keys of the format as an unmodifiable set.
 java.util.Map<FormatKey,java.lang.Object> getProperties()
          Gets the properties of the format as an unmodifiable map.
 Format intersectKeys(FormatKey... keys)
          Creates a new format which only has the specified keys (or less).
 boolean matches(Format that)
          Returns true if that format matches this format.
 boolean matchesWithout(Format that, FormatKey... without)
           
 Format prepend(Format that)
          Creates a new format which contains all properties from the specified format and additional properties from this format.
 Format prepend(java.lang.Object... p)
          Creates a new format which contains all specified properties and additional properties from this format.
 Format removeKeys(FormatKey... keys)
          Creates a new format without the specified keys.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Format

public Format(java.util.Map<FormatKey,java.lang.Object> properties)
Creates a new format onlyWith the specified properties.


Format

public Format(java.lang.Object... p)
Creates a new format onlyWith the specified properties. The properties must be given as key value pairs.

Method Detail

get

public <T> T get(FormatKey<T> key)

get

public <T> T get(FormatKey<T> key,
                 T defaultValue)

containsKey

public boolean containsKey(FormatKey key)

getProperties

public java.util.Map<FormatKey,java.lang.Object> getProperties()
Gets the properties of the format as an unmodifiable map.


getKeys

public java.util.Set<FormatKey> getKeys()
Gets the keys of the format as an unmodifiable set.


matches

public boolean matches(Format that)
Returns true if that format matches this format. That is iff all properties defined in both format objects are identical. Properties which are only defined in one of the format objects are not considered.

Parameters:
that - Another format.
Returns:
True if the other format matches this format.

matchesWithout

public boolean matchesWithout(Format that,
                              FormatKey... without)

append

public Format append(Format that)
Creates a new format which contains all properties from this format and additional properties from that format.

If a property is specified in both formats, then the property value from this format is used. It overwrites that format.

If one of the format has more properties than the other, then the new format is more specific than this format.

Parameters:
that -
Returns:
That format with properties overwritten by this format.

append

public Format append(java.lang.Object... p)
Creates a new format which contains all properties from this format and additional properties listed.

If a property is specified in both formats, then the property value from this format is used. It overwrites that format.

If one of the format has more properties than the other, then the new format is more specific than this format.

Parameters:
p - The properties must be given as key value pairs.
Returns:
That format with properties overwritten by this format.

prepend

public Format prepend(Format that)
Creates a new format which contains all properties from the specified format and additional properties from this format.

If a property is specified in both formats, then the property value from this format is used. It overwrites that format.

If one of the format has more properties than the other, then the new format is more specific than this format.

Parameters:
that -
Returns:
That format with properties overwritten by this format.

prepend

public Format prepend(java.lang.Object... p)
Creates a new format which contains all specified properties and additional properties from this format.

If a property is specified in both formats, then the property value from this format is used. It overwrites that format.

If one of the format has more properties than the other, then the new format is more specific than this format.

Parameters:
p - The properties must be given as key value pairs.
Returns:
That format with properties overwritten by this format.

intersectKeys

public Format intersectKeys(FormatKey... keys)
Creates a new format which only has the specified keys (or less).

If the keys are reduced, then the new format is less specific than this format.


removeKeys

public Format removeKeys(FormatKey... keys)
Creates a new format without the specified keys.

If the keys are reduced, then the new format is less specific than this format.


containsKeys

public Format containsKeys(FormatKey... keys)
Returns true if the format has the specified keys.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2013-01-06 Werner Randelshofer