Class ExprProps
- java.lang.Object
-
- java.util.Dictionary<K,V>
-
- java.util.Hashtable<java.lang.Object,java.lang.Object>
-
- java.util.Properties
-
- sunlabs.brazil.properties.ExprProps
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.Map<java.lang.Object,java.lang.Object>
public class ExprProps extends java.util.Properties
ExprProps
is a subclass ofProperties
that is "smart" in the sense that it wraps aCalculator
object, passingget
andgetProperty
keys to theCalculator
for processing.Keys are first searched for in the
Properties
object. If not found, the key is passed to thegetValue
method of the wrappedCalculator
object. TheCalculator
will returnnull
if the key consists of only a name or Brazil token and that name/token evaluates to 0. In this case, a value associated with the key can not be "found" and theget
orgetproperty
method returnsnull
also.Only property names that "look" like expressions (e.g. contain at least one of characters in [&|*+/%=!<>-]) are passed to the calculator.
- Version:
- 2.3, 04/05/24
- Author:
- Steve Drach <drach@sun.com>
- See Also:
Properties
,Calculator
,ExprPropsHandler
, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExprProps()
This constructor creates aCalculator
instance with this instance ofExprProps
as it's symbol table.ExprProps(java.util.Properties defaults)
This constructor creates aCalculator
instance with this instance ofExprProps
as it's symbol table and with theProperties
instance referenced by the parameterdefaults
as it's set of default values.ExprProps(Request request)
This constructor creates aCalculator
instance withrequest.props
as it's symbol table.ExprProps(Request request, java.util.Properties defaults)
This constructor creates aCalculator
instance withrequest.props
as it's symbol table and with theProperties
instance referenced by the parameterdefaults
as it's set of default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
get(java.lang.Object key)
Returns the value to which the specified key is mapped in thisHashtable
.java.lang.String
getProperty(java.lang.String key)
Searches for the property with the specified key in this property list.-
Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, getOrDefault, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
-
-
-
Constructor Detail
-
ExprProps
public ExprProps()
This constructor creates aCalculator
instance with this instance ofExprProps
as it's symbol table.
-
ExprProps
public ExprProps(java.util.Properties defaults)
This constructor creates aCalculator
instance with this instance ofExprProps
as it's symbol table and with theProperties
instance referenced by the parameterdefaults
as it's set of default values.- Parameters:
defaults
- the defaults
-
ExprProps
public ExprProps(Request request)
This constructor creates aCalculator
instance withrequest.props
as it's symbol table.- Parameters:
request
- theRequest
instance
-
ExprProps
public ExprProps(Request request, java.util.Properties defaults)
This constructor creates aCalculator
instance withrequest.props
as it's symbol table and with theProperties
instance referenced by the parameterdefaults
as it's set of default values.- Parameters:
request
- theRequest
instancedefaults
- the defaults
-
-
Method Detail
-
get
public java.lang.Object get(java.lang.Object key)
Returns the value to which the specified key is mapped in thisHashtable
. If the key is not found, then it's value is computed by treating the key as an arithmetic expression or statement.If, during the computation, an
ArithmeticException
is thrown, the keycompute.error
is set in the baseProperties
. The value associated with the key is an error message.- Specified by:
get
in interfacejava.util.Map<java.lang.Object,java.lang.Object>
- Overrides:
get
in classjava.util.Properties
- Parameters:
key
- theHashtable
key- Returns:
- the value in this table with the
specified key or
null
-
getProperty
public java.lang.String getProperty(java.lang.String key)
Searches for the property with the specified key in this property list. If the key is not found in this property list, then it's value is computed by treating the key as an arithmetic expression or statement.If, during the computation, an
ArithmeticException
is thrown, the keycompute.error
is set in the baseProperties
. The value associated with the key is an error message.If the result of the computation is
null
, the default property list, and its defaults, recursively, are then checked. The method returnsnull
if the property is not found.- Overrides:
getProperty
in classjava.util.Properties
- Parameters:
key
- the property key- Returns:
- the value in this property list with the
specified key or
null
- See Also:
Properties.defaults
-
-