org.reactive.beans.factory.config
Class DefaultPlaceholderMatcher

java.lang.Object
  extended by org.reactive.beans.factory.config.DefaultPlaceholderMatcher
All Implemented Interfaces:
PlaceholderMatcher

public class DefaultPlaceholderMatcher
extends java.lang.Object
implements PlaceholderMatcher

The default implementation of PlaceholderMatcher that uses the "standard" format of "${valueToBeEveluated}".

The default format can be overwritten by using the setPlaceholderRegex(String) and setPlaceholderSuffix(String) methods.

Since:
16.12.2004
Version:
$Id: DefaultPlaceholderMatcher.java,v 1.1 2004/12/26 23:42:29 dan_washusen Exp $
Author:
Dan Washusen

Field Summary
static java.lang.String DEFAULT_PLACEHOLDER_PREFIX
           
static java.lang.String DEFAULT_PLACEHOLDER_REGEX
          The default regex to determine if the value contains a placeholder.
static java.lang.String DEFAULT_PLACEHOLDER_SUFFIX
           
protected  java.util.regex.Matcher matcher
           
protected  boolean multiplePlaceholdersPresent
          If multple placeholders are present in the value then it must evaluate to a string
protected  java.util.regex.Pattern pattern
           
protected  Placeholder placeholder
           
protected  boolean placeholderPresent
           
protected  java.lang.String placeholderRegex
          The prefix for a placeholder value.
protected  java.lang.String proceedingText
           
protected  int proceedingTextBeginIndex
           
protected  java.lang.String trailingText
           
protected  java.lang.String value
           
 
Constructor Summary
DefaultPlaceholderMatcher()
           
 
Method Summary
 java.lang.String getPlaceholderPrefix()
           
 java.lang.String getPlaceholderRegex()
          Returns the prefix for a placeholder value.
 java.lang.String getPlaceholderSuffix()
           
 java.lang.String getProceedingText()
          Returns the proceeding text of the current Placeholder.
 java.lang.String getTrailingText()
          Returns the trailing text of the current Placeholder.
 java.lang.String getValue()
           
 boolean hasNext()
          Moves to the next placeholder if one is available and returns true, otherwise this method returns false
 void init(java.lang.String value)
          (Re-)Initialise the matcher for a new value.
 boolean isMultiplePlaceholdersPresent()
          A method to determine if the provided value contains multiple placeholders.
 boolean isPlaceholderPresent()
          A method to dermine if the provided key is a placeholder for a configurable value.
 Placeholder next()
          Returns the next placeholder to be evaluated.
 void setPlaceholderPrefix(java.lang.String placeholderPrefix)
           
 void setPlaceholderRegex(java.lang.String placeholderRegex)
          Sets the prefix for a placeholder value.
 void setPlaceholderSuffix(java.lang.String placeholderSuffix)
           
protected  java.lang.String stripPlaceholderWrappers(java.lang.String placeholderText)
          This method returns the placeholder with the prefix and suffix removed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PLACEHOLDER_REGEX

public static final java.lang.String DEFAULT_PLACEHOLDER_REGEX
The default regex to determine if the value contains a placeholder.

See Also:
Constant Field Values

DEFAULT_PLACEHOLDER_PREFIX

public static final java.lang.String DEFAULT_PLACEHOLDER_PREFIX
See Also:
Constant Field Values

DEFAULT_PLACEHOLDER_SUFFIX

public static final java.lang.String DEFAULT_PLACEHOLDER_SUFFIX
See Also:
Constant Field Values

placeholderRegex

protected java.lang.String placeholderRegex
The prefix for a placeholder value.


value

protected java.lang.String value

pattern

protected java.util.regex.Pattern pattern

matcher

protected java.util.regex.Matcher matcher

placeholderPresent

protected boolean placeholderPresent

multiplePlaceholdersPresent

protected boolean multiplePlaceholdersPresent
If multple placeholders are present in the value then it must evaluate to a string


placeholder

protected Placeholder placeholder

proceedingTextBeginIndex

protected int proceedingTextBeginIndex

proceedingText

protected java.lang.String proceedingText

trailingText

protected java.lang.String trailingText
Constructor Detail

DefaultPlaceholderMatcher

public DefaultPlaceholderMatcher()
Method Detail

getPlaceholderRegex

public java.lang.String getPlaceholderRegex()
Returns the prefix for a placeholder value.

Returns:
the prefix for a placeholder value

setPlaceholderRegex

public void setPlaceholderRegex(java.lang.String placeholderRegex)
Sets the prefix for a placeholder value.

Parameters:
placeholderRegex - the prefix for a placeholder value

getPlaceholderPrefix

public java.lang.String getPlaceholderPrefix()

setPlaceholderPrefix

public void setPlaceholderPrefix(java.lang.String placeholderPrefix)

getPlaceholderSuffix

public java.lang.String getPlaceholderSuffix()

setPlaceholderSuffix

public void setPlaceholderSuffix(java.lang.String placeholderSuffix)

getValue

public java.lang.String getValue()

init

public void init(java.lang.String value)
Description copied from interface: PlaceholderMatcher
(Re-)Initialise the matcher for a new value.

Specified by:
init in interface PlaceholderMatcher
Parameters:
value - The value that we are now matching

isPlaceholderPresent

public boolean isPlaceholderPresent()
Description copied from interface: PlaceholderMatcher
A method to dermine if the provided key is a placeholder for a configurable value.

Specified by:
isPlaceholderPresent in interface PlaceholderMatcher
Returns:
true if the key needs to be evaluated, otherwise false

isMultiplePlaceholdersPresent

public boolean isMultiplePlaceholdersPresent()
Description copied from interface: PlaceholderMatcher
A method to determine if the provided value contains multiple placeholders.

Specified by:
isMultiplePlaceholdersPresent in interface PlaceholderMatcher
Returns:
true if multiple placeholders are present, otherwise false

next

public Placeholder next()
Description copied from interface: PlaceholderMatcher
Returns the next placeholder to be evaluated.

Note: much like the iterator class, the PlaceholderMatcher.hasNext() method must be called before this method.

Specified by:
next in interface PlaceholderMatcher
Returns:
The next Placeholder.

hasNext

public boolean hasNext()
Description copied from interface: PlaceholderMatcher
Moves to the next placeholder if one is available and returns true, otherwise this method returns false

Specified by:
hasNext in interface PlaceholderMatcher
Returns:
true if another placeholder is available, otherwise false

stripPlaceholderWrappers

protected java.lang.String stripPlaceholderWrappers(java.lang.String placeholderText)
This method returns the placeholder with the prefix and suffix removed.

e.g. a value of "${placeholder}" would return the value "placeholder".

Parameters:
placeholderText - The placeholder text
Returns:
The placeholder text without the prefix and suffix

getProceedingText

public java.lang.String getProceedingText()
Description copied from interface: PlaceholderMatcher
Returns the proceeding text of the current Placeholder.

e.g. a value of "some proceeding text ${placeholder}" would return "some proceeding next " after the first call to PlaceholderMatcher.hasNext().

Specified by:
getProceedingText in interface PlaceholderMatcher
Returns:
The text proceeding the current placeholder, or null if no proceeding text is available

getTrailingText

public java.lang.String getTrailingText()
Description copied from interface: PlaceholderMatcher
Returns the trailing text of the current Placeholder.

e.g. a value of "some proceeding text ${placeholder} some trailing text" would return " some trailing text" after the first call to PlaceholderMatcher.hasNext().

Note: the trailing text is also the proceeding text of the next placehodler where there are more placeholders.

Specified by:
getTrailingText in interface PlaceholderMatcher
Returns:
The text proceeding the current placeholder, or null if no proceeding text is available


Copyright © 2004-2005 reactive.org. All Rights Reserved.