org.mmbase.storage.util
Class Scheme

java.lang.Object
  extended byjava.text.Format
      extended byjava.text.MessageFormat
          extended byorg.mmbase.storage.util.Scheme
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public final class Scheme
extends java.text.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).

Version:
$Id: Scheme.java,v 1.2 2003/08/29 12:12:26 keesj Exp $
Author:
Pierre van Rooden
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.text.MessageFormat
java.text.MessageFormat.Field
 
Constructor Summary
Scheme(StorageManagerFactory factory, java.lang.String pattern)
          Instantiate the Scheme
 
Method Summary
 java.lang.String format(java.lang.Object[] params)
          Applies the parameters to the scheme's pattern.
protected  java.lang.Object resolveParameter(java.lang.Object param)
          Resolves an object (passed as a parameter) to a value that can be applied in a pattern.
 java.lang.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,
              java.lang.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 java.lang.Object resolveParameter(java.lang.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, FieldDefs, MMObjectNode, and MMObjectBuilder should be enriched with a Storable interface, which can be used instead

format

public java.lang.String format(java.lang.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 java.lang.String toString()


MMBase build 1.7.4.20050922