|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.tensegrity.generic.persistence.BuilderUtilities
This class contains utility-methods needed during the creation of objects
by a builder-instance. As true for most classes containing
utility-methods it can not be instantiated, all methods are declared
static.
| Method Summary | |
static void |
assertContains(AttributeCollection attributes,
java.lang.String name)
This method verifies whether a given AttributeCollection
contains an Attribute with the given name. |
static void |
assertContains(AttributeCollection attributes,
java.lang.String[] names)
Method assertContains verifies whether a list of attributes
identified by the list of names are in a given
AttributeCollection. |
static void |
assertContains(AttributeCollection attributes,
java.lang.String[] names,
int atleast)
Method assertContains verifies if an
AttributeCollection contains a certain amount of Attributes
identified by the given list of names. |
static void |
assertContainsMax(AttributeCollection attributes,
java.lang.String[] names,
int max)
Checks whether a given AttributeCollection contains more than max attributes with the specified name. |
static void |
assertNotNull(Attribute attribute,
AttributeCollection attributes,
java.lang.String attributeName)
Method assertNotNull checks whether a given
Attribute is not
null and throws a BuildException with a
detailed error message. |
static void |
assertNotNull(java.lang.Object value,
AttributeCollection attributes,
java.lang.String attributeName)
Method assertNotNull checks whether a given object is not
null and throws a BuildException with a
detailed error message. |
static Attribute |
getAttribute(AttributeList list,
java.lang.String name,
boolean doAssertNotNull)
Method to ease the Attribute retrieval on
AttributeLists. |
static Attribute |
getAttributeMayBeNull(AttributeList list,
java.lang.String name)
Method to ease the Attribute retrieval on
AttributeList instances. |
static java.lang.Object |
getAttributeValue(AttributeList list,
java.lang.String name,
java.lang.Class type)
Method to ease the Attribute value retrieval on AttributeLists. |
static java.lang.Object |
getAttributeValue(AttributeList list,
java.lang.String name,
java.lang.Class type,
boolean doAssertNotNull)
Method to ease the Attribute value retrieval on
AttributeLists. |
static java.lang.String |
getAttributeValueMayBeNull(AttributeList list,
java.lang.String name)
This method uses the getAttributeValueMayBeNull(AttributeList, String, Class)
method but assumes that the retrieve value is of type String. |
static java.lang.Object |
getAttributeValueMayBeNull(AttributeList list,
java.lang.String name,
java.lang.Class type)
Method to ease the Attribute value retrieval on AttributeList
instances. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static final void assertNotNull(java.lang.Object value,
AttributeCollection attributes,
java.lang.String attributeName)
throws BuildException
assertNotNull checks whether a given object is not
null and throws a BuildException with a
detailed error message. This should help to track down syntax errors
within the underlying xml file.
value - the value to check.attributes - the AttributeCollection from which the
value has been read.attributeName - the name of the attribute of which this value has
been read.
BuildException - thrown if the value is null.
public static final void assertNotNull(Attribute attribute,
AttributeCollection attributes,
java.lang.String attributeName)
throws BuildException
assertNotNull checks whether a given
Attribute is not
null and throws a BuildException with a
detailed error message. This should help to track down syntax errors
within the underlying xml file.
attribute - the value to check.attributes - the AttributeCollection from which the
value has been read.attributeName - the name of the attribute of which this value has
been read.
BuildException - thrown if the value is null.
public static final void assertContains(AttributeCollection attributes,
java.lang.String name)
throws BuildException
AttributeCollection
contains an Attribute with the given name. If the
AttributeCollection is empty or no such
Attribute is found a BuildException is thrown.
attributes - the AttributeCollection to look over.name - the name of the attribute to be checked.
BuildException - if no such attribute exists or the list is empty.
public static final void assertContains(AttributeCollection attributes,
java.lang.String[] names)
throws BuildException
assertContains verifies whether a list of attributes
identified by the list of names are in a given
AttributeCollection. If one of these names is not found a
BuildException is thrown.
attributes - the AttributeCollection to check.names - the names of the Attributes.
BuildException - thrown if none of the given names exist.
public static final void assertContains(AttributeCollection attributes,
java.lang.String[] names,
int atleast)
throws BuildException
assertContains verifies if an
AttributeCollection contains a certain amount of Attributes
identified by the given list of names. The given integer specifies how
many names must be found.
AttributeList ( (Age, 43), (Sex, male), (Name, Tom) )
The following call to
assertContains(AttributeList, new String[]{Age, Sex, Occupation, Telephone},3)
would throw an exception, because the AttributeList doesn't contain at
least 3 of the specified Attributes.
This method should be used whenever you encounter a variable
AttributeList which may contain optional elements, but must
contain at least n elements.
attributes - the list of attributes to verify.names - the array of names which should be looked for.atleast - the number of matches we have to find.
BuildException - when the number of hits is smaller then the given
integer at least.
public static final void assertContainsMax(AttributeCollection attributes,
java.lang.String[] names,
int max)
throws BuildException
max attributes with the specified name.
attributes - The Collection to verify.names - the list of names to check.max - the maximum count of appearances of attributes with the
given names.
BuildException - thrown whenever more than max
attributes are found.
public static final Attribute getAttribute(AttributeList list,
java.lang.String name,
boolean doAssertNotNull)
throws BuildException
Attribute retrieval on
AttributeLists. Returns the first
Attribute with the given name. The value will be asserted
through the assertNotNull method of this class.
list - the AttributeList instance of which you want
the Attribute.name - the name of the Attribute you want to receive.doAssertNotNull - if set to true, the
assertNotNull(Attribute, AttributeCollection, String) method
is applied prior the retrieval of the Attribute.
Attribute identified by
name.
BuildException - thrown if the Attribute to retrieve
must be not null but it is not found in the given
AttributeList.
public static final Attribute getAttributeMayBeNull(AttributeList list,
java.lang.String name)
Attribute retrieval on
AttributeList instances. Returns the first attribute with the
given name.
The returned Attribute may be null if it is not found in
the given AttributeList.
list - the AttributeList instance from that you want to
get the Attribute from.name - the name of the Attribute you want to receive.
Attribute identified by
name.
public static final java.lang.Object getAttributeValue(AttributeList list,
java.lang.String name,
java.lang.Class type)
throws BuildException
AttributeLists. Returns the value of the first
Attribute with the given name. The value will be asserted
through the assertNotNull method of this class.
list - the AttributeList instance of which you want
the Attribute.name - the name of the Attribute you want to receive.type - the type of the returned Object.
Attribute identified by
name.
BuildException - thrown if
getAttributeValue(AttributeList, String, Class, boolean)
throws an exception.
public static final java.lang.String getAttributeValueMayBeNull(AttributeList list,
java.lang.String name)
throws BuildException
getAttributeValueMayBeNull(AttributeList, String, Class)
method but assumes that the retrieve value is of type String. Therefore no
cast is required for the caller, nor the type Parameter has
to be passed.
list - the AttributeList instance from that you want to
get the Attribute from.name - the name of the Attribute you want to receive.
Attribute identified by
name as String, or null.
BuildException - delegates the exception of the
getAttributeValue(AttributeList, String, Class) call.
public static final java.lang.Object getAttributeValueMayBeNull(AttributeList list,
java.lang.String name,
java.lang.Class type)
throws BuildException
AttributeList
instances. Returns the value of the first attribute with the given name.
The returned value may be null if it is not found in the attribute list.
list - the AttributeList instance from that you want to
get the Attribute from.name - the name of the Attribute you want to receive.type - the type of the returned Object.
Attribute identified by
name.
BuildException - delegates the exception of the
getAttributeValue(AttributeList, String, Class, boolean) call.
public static final java.lang.Object getAttributeValue(AttributeList list,
java.lang.String name,
java.lang.Class type,
boolean doAssertNotNull)
throws BuildException
Attribute value retrieval on
AttributeLists. Returns the value of the first
Attribute with the given name. The value will be asserted
through the assertNotNull method if the boolean
doAssert is set to true.
list - the AttributeList instance from that you want
to get the Attribute.name - the name of the Attribute you want to receive.type - the Class you expect the value to be.doAssertNotNull - if true, method
assertNotNull() will get called.
Attribute identified by
name.
BuildException - if assertNotNull or
assertType throws such an exception.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||