ariba.util.fieldvalue
Class FieldPath

java.lang.Object
  extended by ariba.util.fieldvalue.FieldPath

public class FieldPath
extends java.lang.Object

The FieldPath class is an object representation of a dotted fieldPath. A String such as "foo.bar.baz" can be used to access a value on a target object using the FieldValue interface. Such a string might be the equivalent of the following Java code: target.getFoo().getBar().getBaz();. In order to avoid reparsing this string each time its used, the FieldPath object provides a way to store the parsed version of this string as a linked list of three nodes "foo"->"bar"->"baz".

In addition to avoiding the need to reparse the dotted fieldPath each time, we also use the FieldPath object as a place to store the previous FieldValueAccessor to which the node's fieldName resolved. Of course, the class for which the previousAccessor applies my not apply for the next usage, but in the common case it does, and so the performance of the dispatch operation is improved by avoiding a more costly hash lookup. Finally, the underlying Accessor (e.g. ReflectionFieldAccessor or ReflectionMethodAccessor) may itself cache a byte-code compiled accesor for the target, thereby turning field access into a no-lookup, no-reflection direct access.


Field Summary
 java.lang.String _fieldName
           
 FieldPath _nextFieldPath
           
 FieldValueGetter _previousGetter
           
 FieldValueSetter _previousSetter
           
 
Constructor Summary
FieldPath(java.lang.String fieldPathString)
          Constructs a new FieldPath from fieldPathString.
 
Method Summary
 java.lang.String car()
          Returns the fieldName value of the first node of a linked list of FieldPaths.
 FieldPath cdr()
          Returns the remainder of the linked list of FieldPaths.
 java.lang.String fieldPathString()
          Reconstitutes the dotted fieldPath starting at the current node and proceding to the end of the list.
 java.lang.Object getFieldValue(java.lang.Object target)
          Looks up the FieldValue classExtension for target and forwards to the corresponding method in that classExtension.
 void setFieldValue(java.lang.Object target, java.lang.Object value)
          Convenience that avoids the use of the FieldValue class.
static FieldPath sharedFieldPath(java.lang.String fieldPathString)
          Attempts to locate a shared instance of a FieldPath object that corresponds to fieldPathString.
 FieldPath tail()
          Returns the last node in the linked list of FieldPath nodes.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_fieldName

public final java.lang.String _fieldName

_nextFieldPath

public final FieldPath _nextFieldPath

_previousSetter

public FieldValueSetter _previousSetter

_previousGetter

public FieldValueGetter _previousGetter
Constructor Detail

FieldPath

public FieldPath(java.lang.String fieldPathString)
Constructs a new FieldPath from fieldPathString. If fieldPathString is a dotted fieldPath, this becomes a recursive operation and thus will create an entire linked list of FieldPath nodes until there are no more dotted fieldPath components.

Parameters:
fieldPathString - the string which contains a fieldName or series or fieldNames separated by a FieldPathSeparator.
Method Detail

sharedFieldPath

public static FieldPath sharedFieldPath(java.lang.String fieldPathString)
Attempts to locate a shared instance of a FieldPath object that corresponds to fieldPathString. If none is found, a new FieldPath instance is created and cached for the next time this may be called. It is not recommend that this method be called to obtain FieldPath instances if you plan on caching the FieldPath yourself as sharing FieldPaths will result in greater cache invalidation with respect to the previousAccessor cache on each FieldPath node.

Parameters:
fieldPathString - the string which contains a fieldName or series or fieldNames separated by a FieldPathSeparator.
Returns:
a FieldPath object corresponding to fieldPathString. This FieldPath object may have been in use by other clients of this method and, thus, may have previousAccessors established. You must check the validity of any such accessors before using them.

car

public java.lang.String car()
Returns the fieldName value of the first node of a linked list of FieldPaths.

Returns:
the fieldName for the receiving node.

cdr

public FieldPath cdr()
Returns the remainder of the linked list of FieldPaths.

Returns:
the next FieldPath node or null if there is none.

tail

public FieldPath tail()
Returns the last node in the linked list of FieldPath nodes.

Returns:
the last FieldPath node or the receiver if there are no more nodes.

fieldPathString

public java.lang.String fieldPathString()
Reconstitutes the dotted fieldPath starting at the current node and proceding to the end of the list. The result is cached the first time this is called to minimize memory consumption if this is never called.

Returns:
the dotted fieldPath as it appears from the current node to the end of the linked list of FieldPaths.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setFieldValue

public void setFieldValue(java.lang.Object target,
                          java.lang.Object value)
Convenience that avoids the use of the FieldValue class.

Parameters:
target - see the FieldPath version of this method
value - see the FieldPath version of this method

getFieldValue

public java.lang.Object getFieldValue(java.lang.Object target)
Looks up the FieldValue classExtension for target and forwards to the corresponding method in that classExtension.

Parameters:
target - see the FieldPath version of this method
Returns:
see the FieldPath version of this method


AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.