org.mmbase.storage.util
Class Scheme

Package class diagram package Scheme
java.lang.Object
  extended by java.text.Format
      extended by java.text.MessageFormat
          extended by 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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.text.MessageFormat
MessageFormat.Field
 
Constructor Summary
Scheme(StorageManagerFactory factory, String pattern)
          Instantiate the Scheme
 
Method Summary
 String format(Object... params)
          Applies the parameters to the scheme's pattern.
protected  Object resolveParameter(Object param)
          Resolves an object (passed as a parameter) to a value that can be applied in a pattern.
 String toString()
           
 
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
 
Methods inherited from class java.text.Format
format, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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
Method Detail

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: 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