|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unitesk.atp.dynattrs.Accessor
public class Accessor
This is a collection of static methods to work with different implementations of attributes.
Constructor Summary | |
---|---|
Accessor()
|
Method Summary | |
---|---|
static String |
capitalize(String s)
Converts the first char of a string to upper case. |
static String |
decapitalize(String s)
Converts the first char of a string to lower case. |
static Object |
getAttribute(Object obj,
String name)
Returns value of attribute of the specified object. |
static Object |
getAttribute(Object obj,
String path,
Attributed variableMap)
Возвращает значение, на которое указывает заданная цепочка атрибутов для данного объекта. |
static Object |
getAttribute(Object obj,
String name,
int index)
Returns element of indexed attribute by index. |
static Set |
getAttributeNames(Object obj)
Returns the set of attribute names the specified object. |
static Set |
getBeanClassPropertyNames(Class cls)
Returns the set of names of bean properties for objects of the specified class. |
static Object |
getBeanProperty(Object bean,
String name)
Returns a value of the specified bean property. |
static Set |
getBeanPropertyNames(Object bean)
Returns the set of names of bean properties of the specified object. |
protected static Method |
getBeanPropertyReadMethod(Object bean,
String name)
Returns read method for the specified property of the specified bean. |
protected static Method |
getBeanPropertyWriteMethod(Object bean,
String name)
Returns write method for the specified property of the specified bean. |
static Object |
getIndexed(Object value,
int index)
Returns element of the specified index value. |
static boolean |
hasAttribute(Object obj,
String name)
Checks existence of an attribute with the specified name of the specified object. |
static boolean |
hasBeanProperty(Object bean,
String name)
Checks existence of bean property of the specified object. |
static boolean |
isBeanPropertyIndexed(Object bean,
String name)
Checks if a value of the bean property can be indexed. |
static boolean |
isBeanPropertyWritable(Object bean,
String name)
Checks writability of bean property of the specified object. |
static boolean |
isID(String name)
Checks whether the given name is a valid identifier. |
static boolean |
isIndexed(Object value)
Checks if value can be indexed. |
static void |
setAttribute(Object obj,
String name,
int index,
Object elem)
Sets the new value of element of indexed attribute by index. |
static void |
setAttribute(Object obj,
String name,
Object value)
Sets the new value of attribute. |
static void |
setBeanProperty(Object bean,
String name,
Object value)
Sets the new value of the specified bean property. |
static void |
setIndexed(Object value,
int index,
Object elem)
Sets the new element's value of indexed value. |
static int |
sizeAttribute(Object obj,
String name)
Returns size of indexed attribute of the specified object. |
static int |
sizeIndexed(Object value)
Returns the size of the indexed value. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Accessor()
Method Detail |
---|
public static String capitalize(String s)
s
- The string to convert.
NullPointerException
- when s == null
.public static String decapitalize(String s)
s
- The string to convert.
NullPointerException
- when s == null
.public static boolean hasBeanProperty(Object bean, String name)
bean
- The specified object.name
- The specified bean property name.
true
if there are bean property read method.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
getBeanPropertyReadMethod(Object,String)
public static boolean isBeanPropertyWritable(Object bean, String name)
bean
- The specified object.name
- The specified bean property name.
true
if there are bean property write method.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
getBeanPropertyWriteMethod(Object,String)
public static Object getBeanProperty(Object bean, String name)
bean
- The specified object.name
- The specified bean property name.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
hasBeanProperty(Object,String)
public static boolean isBeanPropertyIndexed(Object bean, String name)
getBeanProperty(bean,name)
to get property value.
bean
- The specified object.name
- The specified bean property name.
true
if value of bean property is indexed
.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
AttributeException
- If bean property with the specified name doesn't exist (cause == null),
or there was an underlying exception (see cause).public static void setBeanProperty(Object bean, String name, Object value)
bean
- The specified object.name
- The specified bean property name.value
- The new value of bean property.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
public static Set getBeanPropertyNames(Object bean)
bean
- The specified object.
NullPointerException
- If bean is null.public static Set getBeanClassPropertyNames(Class cls)
cls
- The specified class.
NullPointerException
- If cls is null.public static boolean isIndexed(Object value)
List
.
null
is not indexed value.
value
- The specified value.
true
if the specified value is array
or instance of List
.public static int sizeIndexed(Object value)
value
- The specified indexed value.
NullPointerException
- If the specified value is null
.
ClassCastException
- If the specified value is not indexed
.public static Object getIndexed(Object value, int index)
value
- The specified indexed value.index
- The specified index.
NullPointerException
- If the specified value is null
.
ClassCastException
- If the specified value is not indexed
.
IndexOutOfBoundsException
- If the specified index is out of bounds of indexed value.public static void setIndexed(Object value, int index, Object elem)
value
- The specified indexed value.index
- The specified index.elem
- The new value of element.
NullPointerException
- If value
is null
.
ClassCastException
- If the specified value is not indexed
.
IndexOutOfBoundsException
- If the specified index is out of bounds of indexed value.public static boolean hasAttribute(Object obj, String name)
obj
- The specified object.name
- The specified attribute name.
obj
implements Attributed
interface use
its method
to get attribute value.
Otherwise check existence of bean property
.
NullPointerException
- If obj
is null
.
AttributeException
- Some possible reasons:
name == null
public static Object getAttribute(Object obj, String name)
obj
- The specified object.name
- The specified attribute name.
obj
implements Attributed
interface use
its method
to get attribute value.
Otherwise return bean property value
.
NullPointerException
- If obj
is null
.
AttributeException
- Some possible reasons:
name == null
public static int sizeAttribute(Object obj, String name)
obj
- The specified object.name
- The specified attribute name.
obj
implements Attributed
interface use
its method
to get attribute size.
Otherwise get attribute value
and return its size
.
NullPointerException
- If obj
is null
.
AttributeException
- Some possible reasons:
name == null
public static Object getAttribute(Object obj, String name, int index)
obj
- The specified object.name
- The specified attribute name.index
- The specified index.
obj
implements Attributed
interface use
its method
to get
attribute element.
Otherwise get attribute value
and return its element by index
.
NullPointerException
- If obj
is null
.
AttributeException
- Some possible reasons:
name == null
public static void setAttribute(Object obj, String name, Object value)
obj
implements Attributed
interface use
its method
to set
attribute.
Otherwise tries to set bean property
obj
- The specified object.name
- The specified attribute name.value
- The new value of attribute.
AttributeException
- Some possible reasons:
name == null
elem
public static void setAttribute(Object obj, String name, int index, Object elem)
obj
implements Attributed
interface use
its method
to set
attribute element.
Otherwise get attribute value
and set its element by index
.
obj
- The specified object.name
- The specified attribute name.index
- The specified index.elem
- The new value of element.
AttributeException
- Some possible reasons:
name == null
elem
public static Set getAttributeNames(Object obj)
obj
- The specified object.
obj
implements Attributed
interface use
its method
to get attribute names.
Otherwise get bean property names
.public static boolean isID(String name)
Character.isUnicodeIdentifierStart(char)
and Character.isUnicodeIdentifierPart(char)
methods.
name
- the name to check
true
if the given name is a valid identifier,
false
otherwise.public static Object getAttribute(Object obj, String path, Attributed variableMap)
path ::= attribute ( "." attribute )* ;
attribute ::= <attr_name:ID> ( "[" index "]" )? ;
index ::= <index_var:ID> | number ;
number ::= ( "-" )? ( <DIGIT> )+ ;
Каждый элемент цепочки является либо именем атрибута, либо именем списочного атрибута
с указанным в скобках индексом элемента. Индекс может быть задан именем переменной
index_var
, значение которой берется из variable_map
как значение
соответствующего атрибута, или целочисленным литералом number
.
Отрицательному индексу -i соответствует элемент списка с индексом L-i, где L - длина списка.
Значение, на которое указывает цепочка атрибутов, определяется рекурсивно:
obj
- The specified object.path
- The chain of attribute names.variableMap
- Defined variables.
getAttribute(Object,String)
,
getAttribute(Object, String, int)
protected static Method getBeanPropertyReadMethod(Object bean, String name)
bean
- Object to get read method from.name
- Property name.
null
if object has
no property with such name.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
protected static Method getBeanPropertyWriteMethod(Object bean, String name)
bean
- Object to get write method from.name
- Property name.
null
if object has
no property with such name.
NullPointerException
- If bean
is null
.
AttributeException
- Some possible reasons:
name == null
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |