ch.elca.el4j.services.i18n
Class RewritingUtilities

java.lang.Object
  extended by ch.elca.el4j.services.i18n.RewritingUtilities
All Implemented Interfaces:
MessageRewriter.Rule

public class RewritingUtilities
extends Object
implements MessageRewriter.Rule

A rewriting rule providing a set of utility functions. The keys accepted by this rule are of the form

namespace function . argument 

Author:
Adrian Moos (AMS)
File-location:
RewritingUtilities
Last check-in date:
2009-08-04 15:35:01 +0200 (Di, 04. Aug 2009) by swismer for revision 3883

Nested Class Summary
protected static class RewritingUtilities.Function
          A utility function.
 
Field Summary
protected  Map<String,RewritingUtilities.Function> m_functions
          the functions provided by this instance, keyed by function.m_name.
protected  String m_requiredPrefix
          The package-like prefix to function names.
 
Constructor Summary
RewritingUtilities()
          Creates a utility function package called Utils and adds default utility functions.
RewritingUtilities(String packageName)
          Constructor.
 
Method Summary
 void add(RewritingUtilities.Function f)
          Adds a function, replacing any previous function with the same name.
 void remove(String functionName)
          removes a function.
 StringBuffer rewrite(String key, Object[] arguments, StringBuffer target)
          Attempts to rewrite the key with this rule and the provided user arguments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_requiredPrefix

protected String m_requiredPrefix
The package-like prefix to function names. Includes delimiter.


m_functions

protected Map<String,RewritingUtilities.Function> m_functions
the functions provided by this instance, keyed by function.m_name.

Constructor Detail

RewritingUtilities

public RewritingUtilities()
Creates a utility function package called Utils and adds default utility functions.


RewritingUtilities

public RewritingUtilities(String packageName)
Constructor. Adds default utility functions.

Parameters:
packageName - the package name as used to form keys.
Method Detail

add

public void add(RewritingUtilities.Function f)
Adds a function, replacing any previous function with the same name.


remove

public void remove(String functionName)
removes a function. No effect if no matching function is present.

Parameters:
functionName - the name of the function to be removed

rewrite

public StringBuffer rewrite(String key,
                            Object[] arguments,
                            StringBuffer target)
Attempts to rewrite the key with this rule and the provided user arguments. If successful, the resolved message is appended to target, which is then returned. If unsuccessful, this method does not incur observable side effects and returns null.

Specified by:
rewrite in interface MessageRewriter.Rule
Parameters:
key - the key to rewrite
arguments - the user arguments (used to replace {0}, {1}, ...)
target - the StringBuffer to append to
Returns:
target if successful, null otherwise


Copyright © 2005-2011 ELCA. All Rights Reserved.