com.cafesoft.core.util
Class StandardPropertySpec

java.lang.Object
  extended by com.cafesoft.core.util.StandardPropertySpec
All Implemented Interfaces:
PropertySpec

public class StandardPropertySpec
extends Object
implements PropertySpec

StandardPropertySpec implements the PropertySpec interface, which defines how meta data about a runtime-resolvable property may be accessed. Each ProperySpec is composed of property name and a property value specification. The property value specification is composed of either a property value reference or a literal value. If a property value reference, the value name may be qualified with a namespace.

PropertySpec is typically used to provide information on a property name/value pair that will be resolved in an environment-specific way. For example, the following textual representation of PropertySpec:

 propertyspec.my_cookie={http_cookie:MY_COOKIE}
 
may be used to indicate that a web component should create a property named "my_cookie", which is obtained from the current HTTP request using the value of HTTP cookie "MY_COOKIE". PropertySpec instances may also have a specific default value assigned if the referenced value name does not exist. For example, if the HTTP request header "LOGON_USER" does not exist for the following specification:
 propertyspec.logon_user={http_header:LOGON_USER,anonymous}
 
then a property named "login_user" will be created with a default value of "anonymous". PropertySpec values may also be literal like the following:
 propertyspec.agent_signature=abcdefgxyz
 
which indicates that a property named "agent_signature" should be created with literal value "abcdefgxyz".

Since:
12/10/2008

Field Summary
 
Fields inherited from interface com.cafesoft.core.util.PropertySpec
VALUE_TYPE_LITERAL, VALUE_TYPE_REFERENCE, VALUE_TYPE_UNDEFINED
 
Constructor Summary
StandardPropertySpec(String propertyName, int specType, String fqValueRefName, String valueRefNamespace, String valueRefName, String defaultValue)
          Creates a new StandardPropertySpec instance.
 
Method Summary
 String getDefaultValue()
          Get the default property value.
 String getFQValueRefName()
          Get the fully-qualified property value reference name.
 String getPropertyName()
          Get the property name.
 int getPropertyValueSpecType()
          Get the property value specification type.
 String getValueRefName()
          Get the property value reference name.
 String getValueRefNamespace()
          Get the property value reference name space.
static PropertySpec newInstance(String propertyName, String valueSpec)
          Creates a new PropertySpec instance by parsing a value specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardPropertySpec

public StandardPropertySpec(String propertyName,
                            int specType,
                            String fqValueRefName,
                            String valueRefNamespace,
                            String valueRefName,
                            String defaultValue)
Creates a new StandardPropertySpec instance.

Parameters:
propertyName - the property name associated with this PropertySpec.
specType - the PropertyValueSpecType (REFERENCE or LITERAL).
fqValueRefName - the fully qualified value reference name.
valueRefNamespace - the value reference namespace.
valueRefName - the unqualified value reference name.
defaultValue - the default value.
Method Detail

newInstance

public static PropertySpec newInstance(String propertyName,
                                       String valueSpec)
                                throws IllegalArgumentException
Creates a new PropertySpec instance by parsing a value specification.

Parameters:
propertyName - the property name associated with this PropertySpec.
valueSpec - the literal value or value reference. The value specification may use a literal format (e.g. foobar) or a value reference of the general form {[namespace:]valuename[,defaultvalue]} where the square brackets indicate optional components. Examples include:
  • {username} - a value reference with name "username" in the default namespace.
  • {username,anonymous} - a value reference with name "username" in the default namespace with default value "anonymous".
  • {http_request:username} - a value reference named "username" in the "http_request" namespace.
  • {http_request:username,anonymous} - a value reference named "username" in the "http_request" namespace and default value "anonymous"
  • .
Returns:
a new PropertySpec instance with the specified property name parsed from the supplied value specification.
Throws:
IllegalArgumentException - if the property name is null or empty, or the value specification format is invalid.

getPropertyName

public String getPropertyName()
Get the property name.

Specified by:
getPropertyName in interface PropertySpec
Returns:
the property name as a String.

getPropertyValueSpecType

public int getPropertyValueSpecType()
Get the property value specification type.

Specified by:
getPropertyValueSpecType in interface PropertySpec
Returns:
the property value specification type, which may be REFERENCE or LITERAL

getFQValueRefName

public String getFQValueRefName()
Get the fully-qualified property value reference name.

Specified by:
getFQValueRefName in interface PropertySpec
Returns:
the fully qualified property value reference name, which is generally of the form: :. For example: http_header:REMOTE_USER

getValueRefNamespace

public String getValueRefNamespace()
Get the property value reference name space.

Specified by:
getValueRefNamespace in interface PropertySpec
Returns:
the property value reference name space or null if the value type is literal or if the value is in the default namespace.

getValueRefName

public String getValueRefName()
Get the property value reference name.

Specified by:
getValueRefName in interface PropertySpec
Returns:
the property value reference name or null if the value type is literal.

getDefaultValue

public String getDefaultValue()
Get the default property value.

Specified by:
getDefaultValue in interface PropertySpec
Returns:
the property value if the value type is literal or if the referenced property value does not exist (cannot be resolved).


Generated on 10:38:35 AM April 14, 2011, © 1996-2010 Cafésoft LLC. All rights reserved.