org.mmbase.applications.media.builders
Class MediaFragments

java.lang.Object
  extended byorg.mmbase.module.core.MMTable
      extended byorg.mmbase.module.core.MMObjectBuilder
          extended byorg.mmbase.applications.media.builders.MediaFragments

public class MediaFragments
extends MMObjectBuilder

The MediaFragment builder describes a piece of media. This can be audio, or video. A media fragment contains a title, description, and more information about the media fragment. A media fragment will have relations with mediasources which are the actual files in different formats (mp3, real, etc.) The classification, and replace methods are added for backwards compatibility.

Since:
MMBase-1.7
Version:
$Id: MediaFragments.java,v 1.31.2.2 2004/11/09 10:57:04 michiel Exp $
Author:
Rob Vermeulen (VPRO), Michiel Meeuwissen

Field Summary
static Parameter[] AVAILABLE_PARAMETERS
           
static Parameter[] DURATION_PARAMETERS
           
static Parameter[] FILTEREDURLS_PARAMETERS
           
static Parameter[] FORMAT_PARAMETERS
           
static java.lang.String FUNCTION_AVAILABLE
           
static java.lang.String FUNCTION_DURATION
           
static java.lang.String FUNCTION_FILTEREDURLS
           
static java.lang.String FUNCTION_FORMAT
           
static java.lang.String FUNCTION_NUDEURL
           
static java.lang.String FUNCTION_PARENTS
           
static java.lang.String FUNCTION_ROOT
           
static java.lang.String FUNCTION_SUBFRAGMENT
           
static java.lang.String FUNCTION_SUBFRAGMENTS
           
static java.lang.String FUNCTION_URL
           
static java.lang.String FUNCTION_URLS
           
static Parameter[] ISSUBFRAGMENT_PARAMETERS
           
static Parameter[] NUDEURL_PARAMETERS
           
static Parameter[] PARENTS_PARAMETERS
           
static Parameter[] ROOT_PARAMETERS
           
static Parameter[] SUBFRAGMENT_SPARAMETERS
           
static Parameter[] URL_PARAMETERS
           
static Parameter[] URLS_PARAMETERS
           
 
Fields inherited from class org.mmbase.module.core.MMObjectBuilder
AGE_PARAMETERS, broadcastChanges, database, DEFAULT_ALINEA, DEFAULT_EOL, description, descriptions, fields, GUI_PARAMETERS, listCache, nodeCache, OBJ2TYPE_MAX_SIZE, oType, REPLACE_CACHE, searchAge, sortedDBLayout, TEMPNODE_DEFAULT_SIZE, TemporaryNodes, virtual
 
Fields inherited from class org.mmbase.module.core.MMTable
mmb, tableName
 
Constructor Summary
MediaFragments()
           
 
Method Summary
protected  boolean addParentFragment(java.util.Stack fragments)
          Adds a parent fragment to the Stack and returns true, or returns false.
protected  long calculateLength(MMObjectNode node)
          Calculate the length of a mediafragment
 boolean equals(MMObjectNode o1, MMObjectNode o2)
          Implements equals for nodes (this is in MMObjectBuilder because you cannot override MMObjectNode) Stack.contains is used, so make sure equal node are equal.
protected  java.lang.Object executeFunction(MMObjectNode node, java.lang.String function, java.util.List args)
          Executes a function on the field of a node, and returns the result.
protected  java.util.List getFilteredURLs(MMObjectNode fragment, java.util.Map info, java.util.Set cacheExpireObjects)
           
protected  java.lang.String getFormat(MMObjectNode fragment, java.util.Map info)
           
 java.lang.String getGUIIndicator(MMObjectNode node)
          Will show the title (clickable if possible)
 java.lang.String getGUIIndicator(java.lang.String field, MMObjectNode node)
          What should a GUI display for this node/field combo.
 java.lang.Object getObjectValue(MMObjectNode node, java.lang.String field)
          Like getValue, but without the 'old' code (short_ html_ etc).
 Parameter[] getParameterDefinition(java.lang.String function)
          perhaps we need something like this
 java.util.Stack getParentFragments(MMObjectNode fragment)
          Returns a Stack with all parent fragments.
 MMObjectNode getRootFragment(MMObjectNode fragment)
          Find the mediafragment of which the given mediafragment is a part.
 java.util.List getSources(MMObjectNode fragment)
          Get all mediasources belonging to this mediafragment (scope should be protected)
protected  java.lang.String getURL(MMObjectNode fragment, java.util.Map info)
          Retrieves the url of the mediasource that matches best.
protected  java.util.List getURLs(MMObjectNode fragment, java.util.Map info, java.util.List urls, java.util.Set cacheExpireObjects)
          Returns a List of all possible (unfiltered) URLComposer's for this Fragment.
 boolean init()
          Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called.
 boolean isSubFragment(MMObjectNode mediafragment)
          If a mediafragment is coupled to another mediafragment instead of being directly coupled to mediasources, the mediafragment is a subfragment.
 void removeSources(MMObjectNode fragment)
          Removes related media sources.
 java.lang.String replace(scanpage sp, java.util.StringTokenizer command)
          Replace all for frontend code Replace commands available are GETURL (gets mediafile url for an objectnumber),
 boolean setValue(MMObjectNode node, java.lang.String fieldname)
          Provides additional functionality when setting field values.
protected static java.util.Map translateURLArguments(java.util.List arguments, java.util.Map info)
          Would something like this be feasible to translate a List to a Map?
 
Methods inherited from class org.mmbase.module.core.MMObjectBuilder
addField, addLocalObserver, addRemoteObserver, buildSet, checkAddTmpField, commit, convertMMNode2SQL, count, count, create, createAlias, delete, deleteNodeCache, drop, equals, executeFunction, fieldLocalChanged, getAge, getAliasedNode, getAncestors, getCacheNumbers, getCacheSize, getCacheSize, getClassName, getConfigFile, getDBByte, getDBKey, getDBState, getDBText, getDBType, getDefaultTeaser, getDefaultUrl, getDescendants, getDescription, getDescription, getDescriptions, getEditFields, getField, getFieldNames, getFields, getFields, getFunctionParameters, getHardNode, getHardNode, getHTML, getInitParameter, getInitParameters, getList, getLocaleGUIIndicator, getLocaleGUIIndicator, getMachineName, getMaintainer, getMMBase, getNewNode, getNewTmpNode, getNextField, getNextField, getNode, getNode, getNode, getNode, getNodes, getNodes, getNodeType, getNumberFromName, getObjectType, getParentBuilder, getPluralName, getPluralName, getPluralNames, getQuery, getQuery, getQuery, getRawNodes, getRelations_main, getSearchAge, getShort, getShortedByte, getShortedText, getSingularName, getSingularName, getSingularNames, getSmartPath, getSortedFields, getSortedListFields, getTmpNode, getURLEncode, getValue, getVersion, getWAP, getXMLPath, hashCode, hostname_function, insert, insert, insertDone, isExtensionOf, isNodeCached, isVirtual, nodeLocalChanged, nodeRemoteChanged, preCommit, preEdit, process, processSearchResults, putTmpNode, readSearchResults, removeField, removeNode, removeRelations, removeSyncNodes, removeTmpNode, safeCache, safeCommit, safeInsert, search, search, search, searchIn, searchIn, searchIn, searchList, searchList, searchNumbers, searchVector, searchVector, searchVector, searchVector, searchVectorIn, searchVectorIn, searchVectorIn, searchVectorIn, searchWithWhere, sendFieldChangeSignal, setDBLayout_xml, setDefaults, setDescription, setDescriptions, setInitParameter, setMaintainer, setMMBase, setParentBuilder, setPluralNames, setSearchAge, setSingularNames, setTableName, setUniqueValue, setUniqueValue, setValue, setVersion, setXMLPath, setXMLValues, signalNewObject, testValidData, toString, toString, toXML, updateFields, waitUntilNodeChanged, wrap
 
Methods inherited from class org.mmbase.module.core.MMTable
created, getFullTableName, getTableName, size
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FUNCTION_URLS

public static final java.lang.String FUNCTION_URLS
See Also:
Constant Field Values

FUNCTION_FILTEREDURLS

public static final java.lang.String FUNCTION_FILTEREDURLS
See Also:
Constant Field Values

FUNCTION_URL

public static final java.lang.String FUNCTION_URL
See Also:
Constant Field Values

FUNCTION_NUDEURL

public static final java.lang.String FUNCTION_NUDEURL
See Also:
Constant Field Values

FUNCTION_PARENTS

public static final java.lang.String FUNCTION_PARENTS
See Also:
Constant Field Values

FUNCTION_ROOT

public static final java.lang.String FUNCTION_ROOT
See Also:
Constant Field Values

FUNCTION_SUBFRAGMENT

public static final java.lang.String FUNCTION_SUBFRAGMENT
See Also:
Constant Field Values

FUNCTION_SUBFRAGMENTS

public static final java.lang.String FUNCTION_SUBFRAGMENTS
See Also:
Constant Field Values

FUNCTION_AVAILABLE

public static final java.lang.String FUNCTION_AVAILABLE
See Also:
Constant Field Values

FUNCTION_FORMAT

public static final java.lang.String FUNCTION_FORMAT
See Also:
Constant Field Values

FUNCTION_DURATION

public static final java.lang.String FUNCTION_DURATION
See Also:
Constant Field Values

URLS_PARAMETERS

public static final Parameter[] URLS_PARAMETERS

FILTEREDURLS_PARAMETERS

public static final Parameter[] FILTEREDURLS_PARAMETERS

URL_PARAMETERS

public static final Parameter[] URL_PARAMETERS

NUDEURL_PARAMETERS

public static final Parameter[] NUDEURL_PARAMETERS

PARENTS_PARAMETERS

public static final Parameter[] PARENTS_PARAMETERS

ROOT_PARAMETERS

public static final Parameter[] ROOT_PARAMETERS

ISSUBFRAGMENT_PARAMETERS

public static final Parameter[] ISSUBFRAGMENT_PARAMETERS

SUBFRAGMENT_SPARAMETERS

public static final Parameter[] SUBFRAGMENT_SPARAMETERS

AVAILABLE_PARAMETERS

public static final Parameter[] AVAILABLE_PARAMETERS

FORMAT_PARAMETERS

public static final Parameter[] FORMAT_PARAMETERS

DURATION_PARAMETERS

public static final Parameter[] DURATION_PARAMETERS
Constructor Detail

MediaFragments

public MediaFragments()
Method Detail

init

public boolean init()
Description copied from class: MMObjectBuilder
Initializes this builder The property 'mmb' needs to be set for the builder before this method can be called. The method retrieves data from the TypeDef builder, or adds data to that builder if the current builder is not yet registered.

Overrides:
init in class MMObjectBuilder
Returns:
true if init was completed, false if uncompleted.
See Also:
MMObjectBuilder.create()

translateURLArguments

protected static java.util.Map translateURLArguments(java.util.List arguments,
                                                     java.util.Map info)
Would something like this be feasible to translate a List to a Map?


getParameterDefinition

public Parameter[] getParameterDefinition(java.lang.String function)
perhaps we need something like this

Overrides:
getParameterDefinition in class MMObjectBuilder

executeFunction

protected java.lang.Object executeFunction(MMObjectNode node,
                                           java.lang.String function,
                                           java.util.List args)
Description copied from class: MMObjectBuilder
Executes a function on the field of a node, and returns the result. This method is called by the builder's MMObjectBuilder.getValue(org.mmbase.module.core.MMObjectNode, java.lang.String) method. Derived builders should override this method to provide additional functions.

Overrides:
executeFunction in class MMObjectBuilder
See Also:
MMObjectBuilder.executeFunction(org.mmbase.module.core.MMObjectNode, java.lang.String, java.util.List)

calculateLength

protected long calculateLength(MMObjectNode node)
Calculate the length of a mediafragment

Parameters:
node - the mediafragment
Returns:
length in milliseconds

getGUIIndicator

public java.lang.String getGUIIndicator(MMObjectNode node)
Will show the title (clickable if possible)

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - the mediafragment node
Returns:
the title of the mediafragment

getGUIIndicator

public java.lang.String getGUIIndicator(java.lang.String field,
                                        MMObjectNode node)
Description copied from class: MMObjectBuilder
What should a GUI display for this node/field combo. Default is null (indicating to display the field as is) Override this to display your own choice.

Overrides:
getGUIIndicator in class MMObjectBuilder
Parameters:
node - The node to display
field - the name field of the field to display
Returns:
the display of the node's field as a String, null if not specified

getURLs

protected java.util.List getURLs(MMObjectNode fragment,
                                 java.util.Map info,
                                 java.util.List urls,
                                 java.util.Set cacheExpireObjects)
Returns a List of all possible (unfiltered) URLComposer's for this Fragment. A list of arguments can be supplied, which is currently unused (but should not be null). It could contain a Map with preferences, or other information about the client.


getFilteredURLs

protected java.util.List getFilteredURLs(MMObjectNode fragment,
                                         java.util.Map info,
                                         java.util.Set cacheExpireObjects)

getURL

protected java.lang.String getURL(MMObjectNode fragment,
                                  java.util.Map info)
Retrieves the url of the mediasource that matches best. (e.g. pnm://www.mmbase.org/music/test.ra)

Parameters:
fragment - the media fragment
info - extra information (i.e. request, wanted bitrate, preferred format)
Returns:
the url of the audio file

getFormat

protected java.lang.String getFormat(MMObjectNode fragment,
                                     java.util.Map info)

isSubFragment

public boolean isSubFragment(MMObjectNode mediafragment)
If a mediafragment is coupled to another mediafragment instead of being directly coupled to mediasources, the mediafragment is a subfragment.

Returns:
true if the mediafragment is coupled to another fragment, false otherwise.

addParentFragment

protected boolean addParentFragment(java.util.Stack fragments)
Adds a parent fragment to the Stack and returns true, or returns false.


getParentFragments

public java.util.Stack getParentFragments(MMObjectNode fragment)
Returns a Stack with all parent fragments. Starts stacking from this, so on top is the mediafragment with the sources, and on the bottom is the fragment itself.


getRootFragment

public MMObjectNode getRootFragment(MMObjectNode fragment)
Find the mediafragment of which the given mediafragment is a part. This fragment is not a subfragment itself, and should be linked to the actual sources.

Parameters:
fragment - sub media fragment
Returns:
The parent media fragment or null if it has not.

getSources

public java.util.List getSources(MMObjectNode fragment)
Get all mediasources belonging to this mediafragment (scope should be protected)

Parameters:
fragment - the mediafragment
Returns:
All mediasources related to given mediafragment

removeSources

public void removeSources(MMObjectNode fragment)
Removes related media sources. This can be used by automatic recording VWMS's.

Parameters:
fragment - The MMObjectNode

replace

public java.lang.String replace(scanpage sp,
                                java.util.StringTokenizer command)
Replace all for frontend code Replace commands available are GETURL (gets mediafile url for an objectnumber),

Overrides:
replace in class MMObjectBuilder
Parameters:
sp - the scanpage
command - the stringtokenizer reference with the replace command.
Returns:
the result value of the replace command or null.

getObjectValue

public java.lang.Object getObjectValue(MMObjectNode node,
                                       java.lang.String field)
Description copied from class: MMObjectBuilder
Like getValue, but without the 'old' code (short_ html_ etc). This is for protected use, when you are sure this is not used, and you can avoid the overhead.

Overrides:
getObjectValue in class MMObjectBuilder
See Also:
MMObjectBuilder.getValue(org.mmbase.module.core.MMObjectNode, java.lang.String)

setValue

public boolean setValue(MMObjectNode node,
                        java.lang.String fieldname)
Description copied from class: MMObjectBuilder
Provides additional functionality when setting field values. This method is called whenever a Node of the builder's type tries to change a value. It allows the system to add functionality such as checking valid data. Derived builders should override this method if they want to add functionality.

Overrides:
setValue in class MMObjectBuilder
Parameters:
node - the node whose fields are changed
Returns:
true if the call was handled.

equals

public boolean equals(MMObjectNode o1,
                      MMObjectNode o2)
Implements equals for nodes (this is in MMObjectBuilder because you cannot override MMObjectNode) Stack.contains is used, so make sure equal node are equal.

Overrides:
equals in class MMObjectBuilder


MMBase build 1.7.4.20050922