org.codehaus.plexus.interpolation.object

Class FieldBasedObjectInterpolator

public class FieldBasedObjectInterpolator extends Object implements ObjectInterpolator

Reflectively traverses an object graph and uses an Interpolator instance to resolve any String fields in the graph.

NOTE: This code is based on a reimplementation of ModelInterpolator in maven-project 2.1.0-M1, which became a performance bottleneck when the interpolation process became a hotspot.

Author: jdcasey

Field Summary
static SetDEFAULT_BLACKLISTED_FIELD_NAMES
static SetDEFAULT_BLACKLISTED_PACKAGE_PREFIXES
Constructor Summary
FieldBasedObjectInterpolator()
Use the default settings for blacklisted fields and packages, where fields named 'parent' and classes in packages starting with 'java' will not be interpolated.
FieldBasedObjectInterpolator(Set blacklistedFieldNames, Set blacklistedPackagePrefixes)
Use the given black-lists to limit the interpolation of fields and classes (by package).
Method Summary
static voidclearCaches()
Clear out the Reflection caches kept for the most expensive operations encountered: field lookup and primitive queries for fields.
ListgetWarnings()
Retrieve the List of warnings (ObjectInterpolationWarning instances) generated during the last interpolation execution.
booleanhasWarnings()
Returns true if the last interpolation execution generated warnings.
voidinterpolate(Object target, Interpolator interpolator)
Using reflective field access and mutation, traverse the object graph from the given starting point and interpolate any Strings found in that graph using the given Interpolator.
voidinterpolate(Object target, Interpolator interpolator, RecursionInterceptor recursionInterceptor)
Using reflective field access and mutation, traverse the object graph from the given starting point and interpolate any Strings found in that graph using the given Interpolator.

Field Detail

DEFAULT_BLACKLISTED_FIELD_NAMES

public static final Set DEFAULT_BLACKLISTED_FIELD_NAMES

DEFAULT_BLACKLISTED_PACKAGE_PREFIXES

public static final Set DEFAULT_BLACKLISTED_PACKAGE_PREFIXES

Constructor Detail

FieldBasedObjectInterpolator

public FieldBasedObjectInterpolator()
Use the default settings for blacklisted fields and packages, where fields named 'parent' and classes in packages starting with 'java' will not be interpolated.

FieldBasedObjectInterpolator

public FieldBasedObjectInterpolator(Set blacklistedFieldNames, Set blacklistedPackagePrefixes)
Use the given black-lists to limit the interpolation of fields and classes (by package).

Parameters: blacklistedFieldNames The list of field names to ignore blacklistedPackagePrefixes The list of package prefixes whose classes should be ignored

Method Detail

clearCaches

public static void clearCaches()
Clear out the Reflection caches kept for the most expensive operations encountered: field lookup and primitive queries for fields. These caches are static since they apply at the class level, not the instance level.

getWarnings

public List getWarnings()
Retrieve the List of warnings (ObjectInterpolationWarning instances) generated during the last interpolation execution.

hasWarnings

public boolean hasWarnings()
Returns true if the last interpolation execution generated warnings.

interpolate

public void interpolate(Object target, Interpolator interpolator)
Using reflective field access and mutation, traverse the object graph from the given starting point and interpolate any Strings found in that graph using the given Interpolator. Limits to this process can be managed using the black lists configured in the constructor.

Parameters: target The starting point of the object graph to traverse interpolator The Interpolator used to resolve any Strings encountered during traversal. NOTE: Uses SimpleRecursionInterceptor.

interpolate

public void interpolate(Object target, Interpolator interpolator, RecursionInterceptor recursionInterceptor)
Using reflective field access and mutation, traverse the object graph from the given starting point and interpolate any Strings found in that graph using the given Interpolator. Limits to this process can be managed using the black lists configured in the constructor.

Parameters: target The starting point of the object graph to traverse interpolator The Interpolator used to resolve any Strings encountered during traversal. recursionInterceptor The RecursionInterceptor used to detect cyclical expressions in the graph

Copyright © 2001-2009 Codehaus. All Rights Reserved.