Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Enterprise Scheduler Service
11g Release 1 (11.1.1.6.2)
E26229-03


oracle.as.scheduler.substitution
Class SubstitutorImpl

java.lang.Object
  extended by oracle.as.scheduler.substitution.SubstitutorImpl

All Implemented Interfaces:
Substitutor

public class SubstitutorImpl
extends java.lang.Object
implements Substitutor

Perform token substitutions on a string using a set of SubstitutionHandlers. This class provides much of the functionality needed to create a Substitutor. Substitution tokens can take any of the following forms:

 ${NAME}
 ${ID:NAME}
 ${ID1,ID2:NAME}
 

The NAME portion of the token is passed to SubstitutionHandler.containsKey(String) and SubstitutionHandler.get(String).

The ID portion of the token is matched with the value of SubstitutionHandler.getId(). If no ID is specified, the first handler in the list that responds to NAME is used. If one or more IDs are specified, then only handlers reporting matching IDs will be queried for the given NAME. # see SubstitutionHandler


Constructor Summary
SubstitutorImpl()
           

 

Method Summary
 void close()
          Cleanup substitutor state and release all handlers.
protected  void closeHandlers()
          Call close() on all instantiated handlers, and release the instances.
protected  SubstitutionHandler getMatchingHandler(java.lang.String subId, java.lang.String name)
          Find the first handler in the list that matches on substitution ID and name.
protected  boolean initializeHandler(SubstitutionHandler handler)
          Implementations of SubstitutorImpl may override this method to perform implementation specific initialization for each handler instance.
 void setSubstitutionHandlers(java.util.List<SubstitutionHandler> handlers)
          Set the list of SubstitutionHandlers to use.
 void setSubstitutionHandlers(java.lang.String subsHandlerNames)
          Set the list of SubstitutionHandlers to use.
protected  java.util.List<SubstitutionHandler> stringToHandlers(java.lang.String subsHandlerNames)
          Parse the subsHandlerNames string, instantiate the named SubstitutionHandler classes, and return them in a list.
 java.lang.String substitute(java.lang.String original)
          Recursively replaces all tokens in the string original with the results from matching handlers.
protected  java.lang.String substituteTokens(java.lang.String valueTokens, java.util.List<java.lang.String> tokenHistory)
          Takes a string with tokens and returns the values; called recursively

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

SubstitutorImpl

public SubstitutorImpl()

Method Detail

setSubstitutionHandlers

public void setSubstitutionHandlers(java.lang.String subsHandlerNames)
Set the list of SubstitutionHandlers to use.
Specified by:
setSubstitutionHandlers in interface Substitutor
Parameters:
subsHandlerNames - Comma-separated list of class names that implement SubstitutionHandler

setSubstitutionHandlers

public void setSubstitutionHandlers(java.util.List<SubstitutionHandler> handlers)
Set the list of SubstitutionHandlers to use.
Specified by:
setSubstitutionHandlers in interface Substitutor
Parameters:
handlers - List of SubstitutionHandlers

close

public void close()
Cleanup substitutor state and release all handlers.
Specified by:
close in interface Substitutor

closeHandlers

protected void closeHandlers()
Call close() on all instantiated handlers, and release the instances.

stringToHandlers

protected java.util.List<SubstitutionHandler> stringToHandlers(java.lang.String subsHandlerNames)
Parse the subsHandlerNames string, instantiate the named SubstitutionHandler classes, and return them in a list.

Any names that cannot be instantiated as a valid SubstitutionHandler will be skipped.

Parameters:
subsHandlerNames - Comma-separated list substitution handler class names.
Returns:
List of instantiated handlers

initializeHandler

protected boolean initializeHandler(SubstitutionHandler handler)
Implementations of SubstitutorImpl may override this method to perform implementation specific initialization for each handler instance.
Returns:
True if the initialization was successful, false if the handler should be skipped.

substitute

public java.lang.String substitute(java.lang.String original)
                            throws SubstitutionException
Recursively replaces all tokens in the string original with the results from matching handlers. Any tokens that are not recognized by any handlers will remain in the string.
Specified by:
substitute in interface Substitutor
Parameters:
original -
Returns:
String with substitutions performed.
Throws:
SubstitutionException - if an error occurs during substitution

substituteTokens

protected java.lang.String substituteTokens(java.lang.String valueTokens,
                                            java.util.List<java.lang.String> tokenHistory)
                                     throws SubstitutionException
Takes a string with tokens and returns the values; called recursively
Parameters:
valueTokens - Input string containing zero or more tokens to be replaced
tokenHistory - List of substitutions that got us here; used for circular reference detection. Should be an empty (not null) list on first invocation.
Returns:
All tokens we can handle have been replaced (including recursion).
Throws:
SubstitutionException

getMatchingHandler

protected SubstitutionHandler getMatchingHandler(java.lang.String subId,
                                                 java.lang.String name)
                                          throws SubstitutionException
Find the first handler in the list that matches on substitution ID and name. The handlers are queried in the order they appear in the list of SubstitutionHandlers passed to the Substitutor, and the first match is the one used. The order of the IDs in the token has no effect.
Parameters:
subId - - Comma-separated list of IDs to match. If null, match any handler.
name - - the name of to key to search for.
Returns:
Handler that responds to subId and name.
Throws:
SubstitutionException

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Enterprise Scheduler Service
11g Release 1 (11.1.1.6.2)
E26229-03


Copyright © 2008, 2012 Oracle. All rights reserved.