org.mmbase.storage.util
Class Scheme
java.lang.Object
java.text.Format
java.text.MessageFormat
org.mmbase.storage.util.Scheme
- All Implemented Interfaces:
- Serializable, Cloneable
public final class Scheme
- extends MessageFormat
This is a specialised version of the MessageFormat class, with some awareness of
MMBase objects. You can pass MMBase objects to Scheme when formatting a pattern.
The Scheme automatically resolves the object to a value it can use in the pattern.
Schemes are used by the storage to create configurable storage instructions (specifically database SQL code).
- Since:
- MMBase-1.7
- Version:
- $Id: Scheme.java 35523 2009-05-29 13:39:38Z michiel $
- Author:
- Pierre van Rooden
- See Also:
- Serialized Form
| Methods inherited from class java.text.MessageFormat |
applyPattern, clone, equals, format, format, format, formatToCharacterIterator, getFormats, getFormatsByArgumentIndex, getLocale, hashCode, parse, parse, parseObject, setFormat, setFormatByArgumentIndex, setFormats, setFormatsByArgumentIndex, setLocale, toPattern |
Scheme
public Scheme(StorageManagerFactory factory,
String pattern)
- Instantiate the Scheme
- Parameters:
factory - The factory this scheme belongs to.pattern - The pattern to use for the scheme
resolveParameter
protected Object resolveParameter(Object param)
throws StorageException
- Resolves an object (passed as a parameter) to a value that can be applied in a pattern.
It returns:
- For MMBase: the object storage element identifier as a String (fully expanded table name)
- For MMObjectBuilder: the builder storage element identifier as a String (fully expanded table name)
- For MMObjectNode: the object number as an Integer
- For CoreField: a storage-compatible field name as a String (if no such name exists a StorageException is thrown)
Other object types are returned as is, leaving them to be handled by MessageFormat's formatting code.
- Parameters:
param - the object to resolve
- Returns:
- the resolved value
- Throws:
StorageException - if the object cannot be resolved- To Do:
- MMBase, MMObjectNode, and MMObjectBuilder should be enriched with a Storable interface, which
can be used instead
format
public String format(Object... params)
throws StorageException
- Applies the parameters to the scheme's pattern.
- Parameters:
params - an array of parameters to apply to the pattern
- Returns:
- the result scheme as a String
- Throws:
StorageException - if one of the passed parameters cannot be resolved
toString
public String toString()
- Overrides:
toString in class Object
MMBase2 Core 2.0-SNAPSHOT - 2013-03-30T06:36