org.ofbiz.base.util.collections
Class FlexibleMapAccessor<T>

java.lang.Object
  extended by org.ofbiz.base.util.collections.FlexibleMapAccessor<T>
All Implemented Interfaces:
java.io.Serializable

public class FlexibleMapAccessor<T>
extends java.lang.Object
implements java.io.Serializable

Used to flexibly access Map values, supporting the "." (dot) syntax for accessing sub-map values and the "[]" (square bracket) syntax for accessing list elements. See individual Map operations for more information.

See Also:
Serialized Form

Field Summary
protected  java.lang.String bracketedOriginal
           
protected static UtilCache<java.lang.String,FlexibleMapAccessor<?>> fmaCache
           
protected  FlexibleStringExpander fse
           
protected  boolean isAscending
           
static java.lang.String module
           
protected static FlexibleMapAccessor nullFma
           
protected  java.lang.String original
           
 
Constructor Summary
protected FlexibleMapAccessor(java.lang.String name)
           
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 T get(java.util.Map<java.lang.String,? extends java.lang.Object> base)
          Given the name based information in this accessor, get the value from the passed in Map.
 T get(java.util.Map<java.lang.String,? extends java.lang.Object> base, java.util.Locale locale)
          Given the name based information in this accessor, get the value from the passed in Map.
protected  java.lang.String getExpression(java.util.Map<java.lang.String,? extends java.lang.Object> base)
           
static
<T> FlexibleMapAccessor<T>
getInstance(java.lang.String original)
          Returns a FlexibleMapAccessor instance.
 boolean getIsAscending()
           
 java.lang.String getOriginalName()
           
 int hashCode()
           
 boolean isEmpty()
           
 void put(java.util.Map<java.lang.String,java.lang.Object> base, T value)
          Given the name based information in this accessor, put the value in the passed in Map.
 T remove(java.util.Map<java.lang.String,? extends java.lang.Object> base)
          Given the name based information in this accessor, remove the value from the passed in Map.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

module

public static final java.lang.String module

fmaCache

protected static final UtilCache<java.lang.String,FlexibleMapAccessor<?>> fmaCache

nullFma

protected static final FlexibleMapAccessor nullFma

original

protected final java.lang.String original

bracketedOriginal

protected final java.lang.String bracketedOriginal

fse

protected final FlexibleStringExpander fse

isAscending

protected boolean isAscending
Constructor Detail

FlexibleMapAccessor

protected FlexibleMapAccessor(java.lang.String name)
Method Detail

getInstance

public static <T> FlexibleMapAccessor<T> getInstance(java.lang.String original)
Returns a FlexibleMapAccessor instance.

Parameters:
original - The original String expression
Returns:
A FlexibleMapAccessor instance

getOriginalName

public java.lang.String getOriginalName()

getIsAscending

public boolean getIsAscending()

isEmpty

public boolean isEmpty()

get

public T get(java.util.Map<java.lang.String,? extends java.lang.Object> base)
Given the name based information in this accessor, get the value from the passed in Map. Supports LocalizedMaps by getting a String or Locale object from the base Map with the key "locale", or by explicit locale parameter.

Parameters:
base -
Returns:
the found value

get

public T get(java.util.Map<java.lang.String,? extends java.lang.Object> base,
             java.util.Locale locale)
Given the name based information in this accessor, get the value from the passed in Map. Supports LocalizedMaps by getting a String or Locale object from the base Map with the key "locale", or by explicit locale parameter. Note that the localization functionality is only used when the lowest level sub-map implements the LocalizedMap interface

Parameters:
base - Map to get value from
locale - Optional locale parameter, if null will see if the base Map contains a "locale" key
Returns:
the found value

put

public void put(java.util.Map<java.lang.String,java.lang.Object> base,
                T value)
Given the name based information in this accessor, put the value in the passed in Map. If the brackets for a list are empty the value will be appended to the list, otherwise the value will be set in the position of the number in the brackets. If a "+" (plus sign) is included inside the square brackets before the index number the value will inserted/added at that point instead of set at the point.

Parameters:
base -
value -

remove

public T remove(java.util.Map<java.lang.String,? extends java.lang.Object> base)
Given the name based information in this accessor, remove the value from the passed in Map.

Parameters:
base - the Map to remove from
Returns:
the object removed

getExpression

protected java.lang.String getExpression(java.util.Map<java.lang.String,? extends java.lang.Object> base)

toString

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object