|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object echopoint.util.IdKit
IdKit
provides functionality to
parse an object's identifier and return specific information
from it.
Its is primarily intended to be used with Component.getIndentifier() to allow multiple bits of data to be specified. This is needed because nextapp.echo.Component only has one identifier attribute. You can use this class for more general purposes as well.
If the identifier is a java.lang.String
, then
attribute values are separated by semi-colons.
The attribute values can optionally have attribute names. Leading and trailing white-space is removed from the attribute names and values.
Attribute names and values can be quoted with single or double quotes. Attribute names or values seprated by whitespace will be concatenated together, that is 'abc' 'def' will become 'abcdef'.
The general attributed form is :
[attrname:]attribute;[attrname:]attribute;[attrname:]attribute[;] [attrname=]attribute;[attrname=]attribute;[attrname=]attribute[;]
The ':' and '=' are treated exacly the same, as name / value breakers.
This allows you to have identifiers such as :
"fieldname:suburb; group:input; allowed=true;" "class=redControls; type:friendly; visible=?" "class=;fieldname:surname" "class:;fieldname='surname or lastname'" "readonly; visible; tidy" "'quoted name' = 'quoted value';"
If the identifier is a java.util.Map
or
java.util.Dictionary
, then attributes
values are returned and set via the provided attrName key.
If the identifier is NOT a java.lang.String
,
java.util.Map
or java.util.Dictionary
,
then null will be returned on the get
methods.
The "dual nature" of this kit means you need to be aware of the "set" side effects when working with identifiers and attributes values that are not Strings.
If the identifier is a Map/Dictionary, then the set methods have the usual effects where objects are put under the specified attrName. Objects later retrived will be of their original type. However in order for a value to be stored, you must provide a non-null attribute name.
If the identifier is a String, but the attribute values not not Strings, then these values are first converted (via toString()) and then placed inside the identifier String. If they are later retrieved, they will now be String objects not the orignal type. You can however store attributes without attributes names in a String identifier.
The "dual nature" of this kit allows you to set identifiers in a varienty of styles for example :
Component c = new TextField(); ... IdKit.set(c,"style","dataEntry"); IdKit.set(c,"fieldName","income"); // or c.setIdentifier("style:dataEntry;fieldName:income;");
Method Summary | |
static java.lang.Object |
get(nextapp.echo.Component c,
java.lang.String attrName)
Shortcut synonym for getAttribute(c,attrName) . |
static java.lang.Object |
get(java.lang.Object identifier,
int index)
Shortcut synonym for getAttribute(identifier,index) . |
static java.lang.Object |
get(java.lang.Object identifier,
java.lang.String attrName)
Shortcut synonym for getAttribute(identifier,attrName) . |
static java.lang.Object |
getAttribute(nextapp.echo.Component c,
java.lang.String attrName)
Takes the Component's identifier object and then tries to find the attribute with the specified name. |
static java.lang.Object |
getAttribute(java.lang.Object identifier,
int index)
Finds an attribute, at the specified index, in the specified identifier. |
static java.lang.Object |
getAttribute(java.lang.Object identifier,
java.lang.String attrName)
Finds an attribute in the specified identifier. |
static int |
getAttributeCount(java.lang.Object identifier)
Returns the number of attributes in the identifier. |
static java.lang.String[] |
getAttributeNames(java.lang.Object identifier)
Returns an String[] of attribute names in the identifier. |
static boolean |
getBooleanAttribute(java.lang.Object identifier,
int index)
Returns a true if the attribute in the identifier at the specified index is equal to "true". |
static boolean |
getBooleanAttribute(java.lang.Object identifier,
java.lang.String attrName)
Returns a true if the attribute in the identifier with the specified attribute name is equal to "true". |
static int |
getIntegerAttribute(java.lang.Object identifier,
int index,
int defaultValue)
Returns the integer value of the attribute in the identifier at the specified index, or defaultValue if the
attribute cannot be found or converted to an integer.
|
static int |
getIntegerAttribute(java.lang.Object identifier,
java.lang.String attrName,
int defaultValue)
Returns the integer value of the attribute in the identifier with the specified attribute name, or defaultValue if the
attribute cannot be found or converted to an integer.
|
static void |
set(nextapp.echo.Component c,
java.lang.String attrName,
java.lang.Object attrValue)
Shortcut synonym for setAttribute(c,attrName,attrValue) . |
static java.lang.Object |
set(java.lang.Object identifier,
java.lang.String attrName,
java.lang.Object attrValue)
Shortcut synonym for setAttribute(identifier,attrName,attrValue) . |
static void |
setAttribute(nextapp.echo.Component c,
java.lang.String attrName,
java.lang.Object attrValue)
This method sets the value of an attribute in the Components identifier. |
static java.lang.Object |
setAttribute(java.lang.Object identifier,
java.lang.String attrName,
java.lang.Object attrValue)
This method sets the value of an attribute in an identifier. |
static void |
setBooleanAttribute(nextapp.echo.Component c,
java.lang.String attrName,
boolean attrValue)
This method sets the boolean value of an attribute in the Components identifier. |
static java.lang.Object |
setBooleanAttribute(java.lang.Object identifier,
java.lang.String attrName,
boolean attrValue)
This method sets the boolean value of an attribute in an identifier. |
static void |
setIntegerAttribute(nextapp.echo.Component c,
java.lang.String attrName,
int attrValue)
This method sets the integer value of an attribute in the Components identifier. |
static java.lang.Object |
setIntegerAttribute(java.lang.Object identifier,
java.lang.String attrName,
int attrValue)
This method sets the integer value of an attribute in an identifier. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static int getAttributeCount(java.lang.Object identifier)
identifier
- - the identifier object to use
public static java.lang.String[] getAttributeNames(java.lang.Object identifier)
identifier
- - the identifier object to use
public static java.lang.Object getAttribute(java.lang.Object identifier, java.lang.String attrName)
The identifier can be an instance of java.util.Map
,
or java.util.Dictionary
, in which case
the attrName
is used as a key, or it
can be an instance of java.lang.String
in which
case it should be in the general form :
attrName1:attrValue1;attrName2:attrValue2;...
If its not either of these two types, then null is returned.
identifier
- - the identifier object to useattrName
- - the attribute name to find
public static java.lang.Object get(java.lang.Object identifier, java.lang.String attrName)
getAttribute(identifier,attrName)
.
getAttribute(Object, String)
public static java.lang.Object getAttribute(java.lang.Object identifier, int index)
The identifier can be an instance of java.util.Map
or
java.util.Dictionary
, or it
can be an instance of java.lang.String
in which
case it should be in the general form :
attrName1:attrValue1;attrName2:attrValue2;...
If its not either of these two types, then null is returned.
identifier
- - the identifier object to useindex
- - the index of the attribute to return
public static java.lang.Object get(java.lang.Object identifier, int index)
getAttribute(identifier,index)
.
getAttribute(Object, int)
public static boolean getBooleanAttribute(java.lang.Object identifier, java.lang.String attrName)
identifier
- - the identifier object to useattrName
- - the attribute name to find
getAttribute(Object, String)
public static boolean getBooleanAttribute(java.lang.Object identifier, int index)
identifier
- - the identifier object to useindex
- - the index of the attribute in question
getAttribute(Object, int)
public static int getIntegerAttribute(java.lang.Object identifier, java.lang.String attrName, int defaultValue)
defaultValue
if the
attribute cannot be found or converted to an integer.
identifier
- - the identifier object to useattrName
- - the attribute name to finddefaultValue
- - a default to use
public static int getIntegerAttribute(java.lang.Object identifier, int index, int defaultValue)
defaultValue
if the
attribute cannot be found or converted to an integer.
index
- - the index at which to find the attributeidentifier
- - the identifier object to usedefaultValue
- - a default to use
public static java.lang.Object setAttribute(java.lang.Object identifier, java.lang.String attrName, java.lang.Object attrValue)
The identifier can be an instance of java.util.Map
or
java.util.Dictionary
, in which case the attrName
is used as a key, or it can be an instance of java.lang.String
in which case it should be in the general form :
attrName1:attrValue1;attrName2:attrValue2;...
If the identifier is null, then a new java.lang.String
is
created as the identifier if the attribute value is a String or a
java.util.Map
is created if the attribute
value is not a String.
If the identifier is neither an instance of java.util.Map
,
or an instance of java.util.String
, then nothing will
be set.
If attrName is null, then no attribute name is used when placing the new attribute info the identifier.
If attrValue is null, then any attribute value with the attrName will be removed.
Any trailing and leading white-space around attributes will be normalised out.
identifier
- - The identifier to see the attribute intoattrName
- - the optional name of the attributeattrValue
- the new value of the attribute or null to remove it
public static java.lang.Object set(java.lang.Object identifier, java.lang.String attrName, java.lang.Object attrValue)
setAttribute(identifier,attrName,attrValue)
.
setAttribute(Object, String, Object)
public static java.lang.Object setBooleanAttribute(java.lang.Object identifier, java.lang.String attrName, boolean attrValue)
identifier
- - The identifier to see the attribute intoattrName
- - the optional name of the attributeattrValue
- the new boolean value of the attribute
setAttribute(Object, String, Object)
public static java.lang.Object setIntegerAttribute(java.lang.Object identifier, java.lang.String attrName, int attrValue)
identifier
- - The identifier to see the attribute intoattrName
- - the optional name of the attributeattrValue
- the new integer value of the attribute
setAttribute(Object, String, Object)
public static java.lang.Object getAttribute(nextapp.echo.Component c, java.lang.String attrName)
If the identifier is null, then empty string "" is returned.
c
- - the Component to checkattrName
- - the attribute name to find
getAttribute(Object, String)
public static java.lang.Object get(nextapp.echo.Component c, java.lang.String attrName)
getAttribute(c,attrName)
.
getAttribute(Component, String)
public static void setAttribute(nextapp.echo.Component c, java.lang.String attrName, java.lang.Object attrValue)
c
- - the Component to set the identifier attribute intoattrName
- - the new attribute nameattrValue
- - the new value of the attributepublic static void set(nextapp.echo.Component c, java.lang.String attrName, java.lang.Object attrValue)
setAttribute(c,attrName,attrValue)
.
setAttribute(Component, String, Object)
public static void setBooleanAttribute(nextapp.echo.Component c, java.lang.String attrName, boolean attrValue)
c
- - the Component to set the identifier attribute intoattrName
- - the new attribute nameattrValue
- - the new boolean value of the attributesetAttribute(Object, String, Object)
,
setBooleanAttribute(Object, String, boolean)
public static void setIntegerAttribute(nextapp.echo.Component c, java.lang.String attrName, int attrValue)
c
- - the Component to set the identifier attribute intoattrName
- - the new attribute nameattrValue
- - the new integer value of the attributesetAttribute(Object, String, Object)
,
setIntegerAttribute(Object, String, int)
|
EchoPoint 1.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |