biz.c24.io.api
Class Utils

java.lang.Object
  extended by biz.c24.io.api.Utils

public class Utils
extends Object

Static utilities class for the C24 Integration Objects API.


Field Summary
protected static String C24_HOME_DIR
           
static String CDATA_END
          The end of a CDATA block.
static String CDATA_START
          The start of a CDATA block.
static Logger DEFAULT_LOG
          The default log used by the C24 Integration Objects API.
static boolean IS_JAVA_1_1
          Is true if this is Java version 1.1 (also 1.1.x versions).
static boolean IS_JAVA_1_2
          Is true if this is Java version 1.2 (also 1.2.x versions).
static boolean IS_JAVA_1_3
          Is true if this is Java version 1.3 (also 1.3.x versions).
static boolean IS_JAVA_1_4
          Is true if this is Java version 1.4 (also 1.4.x versions).
static boolean IS_JAVA_1_5
          Is true if this is Java version 1.5 (also 1.5.x versions).
static String JAVA_VERSION
          The java.version System Property.
static float JAVA_VERSION_FLOAT
          Gets the Java version as a float.
static String KEY_CDATA
          A client property key used to specify the content of an element is enclosed in a CDATA section.
static String KEY_DOCTYPE_NAME
          A client property key used to specify the name of the DOCTYPE xml structure.
static String KEY_DOCTYPE_PUBLICID
          A client property key used to specify the public ID of the DOCTYPE xml structure.
static String KEY_DOCTYPE_SYSTEMID
          A client property key used to specify the system ID of the DOCTYPE xml structure.
static String KEY_ENCODING
          Deprecated. Encoding is a presentation property and thus should not be stored as part of the data model.
static String KEY_NO_DEFAULT_NAMESPACE_MAPPING
          A client property used to specify explicitly that the default namespace mapping should not be used.
static String KEY_NO_NAMESPACE_SCHEMA_LOCATION
          A client property key used to locate a schema for elements that are not in any namespace (note: attributes that are not in any namespace are assumed to be declared in the same schema as their parent element).
static String KEY_SCHEMA_LOCATION
          A client property key used to locate a schema for elements and attributes that are in a specified namespace.
static String OEM_CONTACTUS_URL
           
static String OEM_EULA
           
static String OEM_SALES_EMAIL
           
static String OEM_SUPPORT_EMAIL
           
static String OEM_SUPPORT_TELEPHONE
           
static String OEM_SUPPORT_URL
           
static String SYSTEM_PROPERTY_BIC_PLUS_IBAN_DIRECTORY_FILE
          The System property key used to determine the location of the BICPlusIBAN directory file.
static String SYSTEM_PROPERTY_GENERICDATE_TIME_ZONE_AS_ISO8601
          The System property key used to specify the timezone for generic dates when written out as ISO8601 values.
static String SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE
          The System property key used to determine the location of the ISO3166 country code file.
static String SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE
          The System property key used to determine the location of the ISO4217 currency code file.
static String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_COLON
          The System property key used to specify whether ISO8601 values should be written out with a colon delimiting the hour / minute values of their time zone.
static String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_PRESENT
          The System property key used to specify whether ISO8601 values should be written out with a time zone.
static String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_ZERO
          The System property key used to specify whether ISO8601 values with a zero offset timezone should be written out with a time zone of 00:00 rather than Z.
static String SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE
          The System property key used to determine the location of the ISO9362 BIC code file.
static String SYSTEM_PROPERTY_PASS_VALIDATION_WITHOUT_RESOURCE
          The System property key used to determine the behaviour of this class when a required resource is not available.
static String SYSTEM_PROPERTY_SEPA_ROUTING_DIRECTORY_FILE
          The System property key used to determine the location of the ISO9362 BIC code file.
static String SYSTEM_PROPERTY_SUPPRESS_DATABASE_KEY_VALIDATION
          The System property key used to determine whether validation should be carried out on the presence of database key fields.
static String SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS
          The System property key which should be set to the value "true" to supress warnings created when errors occur whilst running validators which require external resources.
static String SYSTEM_PROPERTY_SUPPRESS_SWIFT_WARNINGS
          Deprecated. Use SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS instead.
static String SYSTEM_PROPERTY_SWIFT_BIC_CODE_FILE
          Deprecated. Use SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE instead.
static String SYSTEM_PROPERTY_SWIFT_COUNTRY_CODE_FILE
          Deprecated. Use SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE instead.
static String SYSTEM_PROPERTY_SWIFT_CURRENCY_CODE_FILE
          Deprecated. Use SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE instead.
static String SYSTEM_PROPERTY_SWIFT_DIRECTORY_FILE
          Deprecated. Use SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE instead.
static String SYSTEM_PROPERTY_TARGET2_FILE
          The System property key used to determine the location of the Target2 directory file.
static String SYSTEM_PROPERTY_XPATH_IMPLEMENTATION
          The System property key used to specify the XPath implementation to be used by the IOXPathFactory.
static String XML_SCHEMA_INSTANCE_URI
          The XML schema instance namespace URI, often used with prefix 'xsi'.
 
Constructor Summary
protected Utils()
           
 
Method Summary
static ComplexDataObject[] ancestorArray(ComplexDataObject obj)
          Returns an array of the ancestors of obj.
static ComplexDataObject[] ancestorArrayReversed(ComplexDataObject obj)
          Returns an array of the ancestors of obj.
static StringBuffer arrayToStringBuffer(String[] arr)
          Construct the StringBuffer from an array
static Iterator attrIterator(ComplexDataObject obj)
          Returns an iterator over all of the attributes of obj.
static BigDecimal bigDecimalValueWrapper(Number value)
          Converts number value objects to BigDecimal object.
static BigInteger bigIntegerValueWrapper(Number value)
          Converts integer value objects to BigInteger object.
static boolean booleanSystemProperty(String key, boolean def)
          Returns the value of the specified system proeprty, default to def is the proeprty is not found.
static boolean booleanValue(Object obj)
          Returns a boolean value from the argument.
static boolean[] booleanValueArray(Object obj)
          Returns a boolean value array from the argument.
static byte byteValue(Object obj)
          Returns a byte value from the argument without a loss of precision.
static byte[] byteValueArray(Object obj)
          Returns a byte value array from the argument.
static char charValue(Object obj)
          Returns a char value from the argument.
static char[] charValueArray(Object obj)
          Returns a char value array from the argument.
static void checkLicense()
          Called by various parts of the API to check the presence and validity of a license key.
static void checkUILicense()
          Called by various parts of the API to check the presence and validity of a license key.
static void clearNulls(List l)
          Clears any null values from the supplied list.
static Object[] clearNulls(Object[] arr)
          Clears any null values from the supplied array.
static Object cloneDeep(Object obj, ComplexDataObject parent, String elementDeclName)
          Retruns a deep clone of the supplied object.
static int columnNumber(StringBuffer buffer, int offset, int previousColumnNumber)
          Computes the column number at offset.
static boolean copyFile(String srcName, String destName)
          Copies a file.
static int countElementsFromXPath(List<String> xpath, int index, ComplexDataObject complexDataObject)
           
static int countElementsFromXPath(String xpathString, ComplexDataObject complexDataObject)
           
static Enumeration createEnumeration(ComplexDataObject object, XPathStatement valuesXPath, XPathStatement namesXPath, XPathStatement descriptionsXPath)
          Creates and returns a new enumeration populated from the result of executing the specified XPath expression over the specified object.
static Enumeration createEnumeration(ComplexDataObject object, XPathStatement valuesXPath, XPathStatement namesXPath, XPathStatement descriptionsXPath, boolean trimValues)
          Creates and returns a new enumeration populated from the result of executing the specified XPath expression over the specified object.
static Enumeration createEnumeration(String[] values, String[] names, String[] descriptions)
          Creates and returns a new enumeration populated from the specified array of values.
static ObjectInputStream createObjectInputStream(InputStream is)
          Returns a new optimized input stream.
static ObjectOutputStream createObjectOutputStream(OutputStream os)
          Returns a new optimized output stream.
static Object createSimpleValue(DataComponent component, String value)
          Creates a value from the given string representation.
static ComplexDataType createURType(String name, DataModel model)
          Returns a new complex type which is the best possible representation of the UR-type (the base of all complex types).
static BigDecimal decimalValue(Object obj)
          Returns a big decimal value from the argument without a loss of precision.
static int depth(ComplexDataObject obj)
          Returns the depth of obj in it's hierarchy.
static Element deriveElement(String rootClassName, ClassLoader classLoader)
          Derives an Element from the specified class name.
static BigDecimal divide(BigDecimal bigDecimal1, BigDecimal bigDecimal2)
           
static BigDecimal[] divideAndRemainder(BigDecimal bigDecimal1, BigDecimal bigDecimal2)
           
static double doubleValue(Object obj)
          Returns a double value from the argument without a loss of precision.
static double[] doubleValueArray(Object obj)
          Returns a double value array from the argument.
static Iterator elementIterator(ComplexDataObject obj)
          Returns an iterator over all of the elements of obj.
static boolean empty(String str)
          Returns true is str is null or empty.
static Iterator emptyIterator()
          Returns an empty iterator containing no items.
static boolean endsWith(String path, char ch)
           
static boolean eq(Object o1, Object o2)
          compare 2 objects, either of which might be null
static boolean eq(String str1, String str2)
          compare 2 strings, either of which might be null
static boolean equals(Object obj1, Object obj2)
          Returns true if obj1 and obj2 are equal or both null.
static String escape(String str)
          Escapes all new line and tab characters in the specified string.
static String extractLocationDetails(SAXParseException ex)
          Returns a string containing the location details extracted from the supplied exception.
static float floatValue(Object obj)
          Returns a float value from the argument without a loss of precision.
static float[] floatValueArray(Object obj)
          Returns a float value array from the argument.
static String formatObjectContent(DataComponent comp, Object obj)
          Formats the content of obj which should be defined by the element or attribute comp.
static String formatObjectContent(DataComponent comp, Object obj, boolean includeComplexTypeContent)
          Formats the content of obj which should be defined by the element or attribute comp.
static String getContactUsForLicenseText(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getContactUsForLicenseText(License license)
           
static String getContactUsURL(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getContactUsURL(License license)
           
static String[] getDataSourceNames(ComplexDataType type)
          Returns an array contining the connection names of all database validators used by the specified type.
static List getElementsFromXPath(String xpathString, ComplexDataObject complexDataObject)
           
static List getElementsFromXPath(XPathStatement xPathStatement, ComplexDataObject complexDataObject)
           
static String getEncodingName(InputStream stream)
          Returns the IANA encoding name that is auto-detected from the supplied stream.
static String getMessage(Throwable t)
          Extract localized message from a throwable instance and format it with class name prefix.
static DataModel getModelForURI(ComplexDataObject obj, String uri)
          Retuns the model mapped to by prefix.
static String getOptionalProperty(String name)
          Gets an optional property of the Environment
static String getParentChildElementName(ComplexDataObject obj)
          Retrieve object name that expected while call getParent().getElement() function.
static String getPrefix(Object obj, DataComponent component, ComplexDataObject parent, String uri, boolean notEmpty)
          Returns the prefix which should be used for obj with respect to parent.
protected static Properties getProperties()
          Gets all the properties of the environment Gets the properties of the Environment
static String getProperty(String name)
          Gets a property of the Environment
static String getSalesEmailAddress(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getSalesEmailAddress(License license)
           
static String getSupportEmailAddress(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getSupportEmailAddress(License license)
           
static String getSupportTelephoneNumber(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getSupportTelephoneNumber(License license)
           
static String getSupportURL(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
           
static String getSupportURL(License license)
           
static String getTab(int length)
          Returns a string of 3 spaces repeated length times.
static String getURIForPrefix(ComplexDataObject obj, String prefix)
          Returns the namespace URI mapped to by prefix.
static String getXsiPrefix(ComplexDataObject object)
          Returns the XSI prefix mapped to by object.
static int hashCode(Object obj)
           
static void initialise()
           
static void initialise(ComplexDataType t)
          Initialises a type hierarchy.
protected static void initialiseQuietly()
          Initialises properties
protected static void initProperties(Properties newprops)
          Sets the content of Environment without reading from a properties file
static BigInteger integerValue(Object obj)
          Returns a big integer value from the argument without a loss of precision.
static int intValue(Object obj)
          Returns an int value from the argument without a loss of precision.
static int[] intValueArray(Object obj)
          Returns a int value array from the argument.
static boolean isAncestor(ComplexDataObject parent, ComplexDataObject decendant)
          Returns whether the first argument is a descendant of the second.
static boolean isAttribute(IOContext context)
          Returns whether the supplied object represents an attribute.
static boolean isBigDecimalOrBigInteger(Number arg)
          Checks whether arg is an instance of BigInteger or BigDecimal.
static boolean isBigDecimalOrBigInteger(Number arg1, Number arg2)
          Checks whether arg1 or arg2 is an instance of BigInteger or BigDecimal.
static boolean isBigInteger(Number arg1, Number arg2)
          Checks whether arg1 or arg2 is an instance of BigInteger.
static boolean isElement(ComplexDataObject obj)
          Returns whether the supplied object represents an attribute.
static boolean isEmpty(String text)
          check if a string is null or empty.
static boolean isJavaVersionAtLeast(float requiredVersion)
          Is the Java version at least the requested version.
static boolean isMacOS()
           
static boolean isMethodPresent(Class c, String name, Class[] params)
          Returns true if the named method is present in the supplied class.
static boolean isNotEmptyContent(String str)
           
static boolean isSuppressExternalizedValidationWarnings()
           
static boolean isTextualSink(Sink s)
          Returns whether the specified sink provides textual data as output.
static boolean isTextualSource(Source s)
          Returns whether the specified source takes textual data as input.
static int lineNumber(StringBuffer buffer, int offset)
          Computes the line number at offset.
static List listValue(Object obj)
          Returns a list derived from the argument.
static Validator loadValidator(String[] classNames, ClassLoader classLoader, Class clazz)
          Loads a validator instance by examing the classNames array.
static ComplexDataObject locateIdNode(ComplexDataObject context, String id)
          Searches for an ID element or attribute within context whose value is equal to id.
static ComplexDataObject locateIdNode(ComplexDataObject context, String id, Class returnClass)
          Searches for an ID element or attribute within context whose value is equal to id.
static ComplexDataObject[] locateIdNodes(ComplexDataObject context, String[] ids)
          Searches for ID elements or attributes within context whose values are equal to the entries in ids.
static ComplexDataObject[] locateIdNodes(ComplexDataObject context, String[] ids, Class returnClass)
          Searches for ID elements or attributes within context whose values are equal to the entries in ids.
static long longValue(Object obj)
          Returns a long value from the argument without a loss of precision.
static long[] longValueArray(Object obj)
          Returns a long value array from the argument.
static boolean matches(String str, String regex)
          JDK independent helper method for Matcher.matches().
static File nextFile(DecimalFormat numericIncrementFormat, String fileMask, File dir)
          Returns a file which does not exist in the specified directory.
static int objectHashCode(Object obj)
          Returns the hashcode of obj or 0 if it is null.
static Object[] objectValueArray(Object obj, Class clazz)
          Returns an Object value array from the argument.
static String openEditionUIWarning(String name)
           
static String openEditionWarning(String name)
           
static String pad(String original, String pad, PadJustificationEnum justification, int amount, int size)
          Pads the supplied string.
static Iterator parentIterator(ComplexDataObject obj)
          Returns an iterator over all of the parents of obj.
static BigDecimal pow(BigDecimal bigDecimal, int exponent)
           
static BigInteger pow(BigInteger bigInteger, int exponent)
           
static void printLicense()
          Prints the license details to System.out
static void printLicense(PrintStream ps, String warning)
          Prints the license to the specified stream.
static String readFile(File file)
          Reads the specified file into a String using the UTF-8 encoding.
static String readFile(File file, String encoding)
          Reads the specified file into a String using the specified encoding.
static RegExpEvaluator regex(String regex)
          JDK independent helper method to return an equivalent to Matcher.
static FileFilter regexFileFilter(String regex)
          Returns a file filter which will accept files matching the regex argument.
static FileFilter regexFileFilter(String[] regex)
          Returns a file filter which will accept files matching an entry in the regex argument.
static void removeNamespaceMapping(ComplexDataObject obj, String uri, String prefix)
          Removes the namespace mapping object from obj which has the specified uri and prefix values.
static String replaceAll(String original, String regex, String replacement)
          JDK independent helper method for Matcher.replaceAll(String).
static String replaceFirst(String original, String regex, String replacement)
          JDK independent helper method for Matcher.replaceFirst(String).
protected static void resetProperties()
           
protected static void setProperties(Properties newProps)
          Sets the content of Environment
static short shortValue(Object obj)
          Returns a short value from the argument without a loss of precision.
static short[] shortValueArray(Object obj)
          Returns a short value array from the argument.
static Iterator singletonIterator(Object obj)
          Returns an iterator containing only the specified item.
static String[] split(String str, String regex)
          JDK independent helper method for Pattern.split(CharSequence).
static boolean startsWith(String path, char ch)
           
static String stringSystemProperty(String key, String def)
          Returns the value of the specified system proeprty, default to def is the proeprty is not found.
static String unpad(String original, String pad, PadJustificationEnum justification, int amount, int minSize)
          Unpads the supplied string.
static Boolean valueOf(boolean b)
          Returns the object wrapper value of the supplied argument.
static boolean verifyLicense(File licenseFile)
          Client code should call this method before invoking any other part of the C24 Integration Objects API.
static boolean verifyLicense(InputStream stream)
          Client code should call this method before invoking any other part of the C24 Integration Objects API.
static void verifyLicense(License license)
          Client code should call this method before invoking any other part of the C24 Integration Objects API.
static boolean verifyUILicense(File licenseFile)
          Client code should call this method before invoking any other part of the C24 Integration Objects API.
static String whitespace(String original, WhiteSpaceEnum whitespace)
          Performs the specified whitespace behaviour to original.
static void writeFile(File f, String str)
          Writes the specified String into a file using the UTF-8 encoding.
static void writeFile(File f, String str, String encoding)
          Writes the specified String into a file using the specified encoding.
static void writeFile(File f, String str, String encoding, boolean append)
          Writes the specified String into a file using the UTF-8 encoding.
static String xpath(ComplexDataObject obj)
          Returns the xpath string which can be used to access obj.
static String xpath(ComplexDataObject obj, boolean ignoreDocumentNode)
           
static String xpath(ComplexDataObject object, boolean ignoreDocumentNode, String elementName)
          Returns the xpath string which can be used to access obj.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

C24_HOME_DIR

protected static String C24_HOME_DIR

OEM_EULA

public static final String OEM_EULA
See Also:
Constant Field Values

OEM_SALES_EMAIL

public static final String OEM_SALES_EMAIL
See Also:
Constant Field Values

OEM_SUPPORT_EMAIL

public static final String OEM_SUPPORT_EMAIL
See Also:
Constant Field Values

OEM_SUPPORT_TELEPHONE

public static final String OEM_SUPPORT_TELEPHONE
See Also:
Constant Field Values

OEM_SUPPORT_URL

public static final String OEM_SUPPORT_URL
See Also:
Constant Field Values

OEM_CONTACTUS_URL

public static final String OEM_CONTACTUS_URL
See Also:
Constant Field Values

SYSTEM_PROPERTY_SUPPRESS_SWIFT_WARNINGS

public static final String SYSTEM_PROPERTY_SUPPRESS_SWIFT_WARNINGS
Deprecated. Use SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS instead.
See Also:
Constant Field Values

SYSTEM_PROPERTY_SWIFT_BIC_CODE_FILE

public static final String SYSTEM_PROPERTY_SWIFT_BIC_CODE_FILE
Deprecated. Use SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE instead.
See Also:
Constant Field Values

SYSTEM_PROPERTY_SWIFT_COUNTRY_CODE_FILE

public static final String SYSTEM_PROPERTY_SWIFT_COUNTRY_CODE_FILE
Deprecated. Use SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE instead.
See Also:
Constant Field Values

SYSTEM_PROPERTY_SWIFT_CURRENCY_CODE_FILE

public static final String SYSTEM_PROPERTY_SWIFT_CURRENCY_CODE_FILE
Deprecated. Use SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE instead.
See Also:
Constant Field Values

SYSTEM_PROPERTY_TARGET2_FILE

public static final String SYSTEM_PROPERTY_TARGET2_FILE
The System property key used to determine the location of the Target2 directory file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE

public static final String SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE
The System property key used to determine the location of the ISO9362 BIC code file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_BIC_PLUS_IBAN_DIRECTORY_FILE

public static final String SYSTEM_PROPERTY_BIC_PLUS_IBAN_DIRECTORY_FILE
The System property key used to determine the location of the BICPlusIBAN directory file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_SEPA_ROUTING_DIRECTORY_FILE

public static final String SYSTEM_PROPERTY_SEPA_ROUTING_DIRECTORY_FILE
The System property key used to determine the location of the ISO9362 BIC code file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE

public static final String SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE
The System property key used to determine the location of the ISO3166 country code file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE

public static final String SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE
The System property key used to determine the location of the ISO4217 currency code file.

See Also:
Constant Field Values

SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS

public static final String SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS
The System property key which should be set to the value "true" to supress warnings created when errors occur whilst running validators which require external resources.

See Also:
Constant Field Values

SYSTEM_PROPERTY_SUPPRESS_DATABASE_KEY_VALIDATION

public static final String SYSTEM_PROPERTY_SUPPRESS_DATABASE_KEY_VALIDATION
The System property key used to determine whether validation should be carried out on the presence of database key fields.

This property would commonly be set to "false" in cases where Hibernate is being used to generate database keys.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO8601_TIME_ZONE_PRESENT

public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_PRESENT
The System property key used to specify whether ISO8601 values should be written out with a time zone.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO8601_TIME_ZONE_ZERO

public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_ZERO
The System property key used to specify whether ISO8601 values with a zero offset timezone should be written out with a time zone of 00:00 rather than Z.

See Also:
Constant Field Values

SYSTEM_PROPERTY_ISO8601_TIME_ZONE_COLON

public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_COLON
The System property key used to specify whether ISO8601 values should be written out with a colon delimiting the hour / minute values of their time zone.

See Also:
Constant Field Values

SYSTEM_PROPERTY_GENERICDATE_TIME_ZONE_AS_ISO8601

public static final String SYSTEM_PROPERTY_GENERICDATE_TIME_ZONE_AS_ISO8601
The System property key used to specify the timezone for generic dates when written out as ISO8601 values.

The Value of this property should be the required timezone ID or 'NULL' to remove timezone information altogether.

See Also:
Constant Field Values

SYSTEM_PROPERTY_SWIFT_DIRECTORY_FILE

public static final String SYSTEM_PROPERTY_SWIFT_DIRECTORY_FILE
Deprecated. Use SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE instead.
The System property key used to specify path to SWIFT Directory.

See Also:
Constant Field Values

SYSTEM_PROPERTY_XPATH_IMPLEMENTATION

public static final String SYSTEM_PROPERTY_XPATH_IMPLEMENTATION
The System property key used to specify the XPath implementation to be used by the IOXPathFactory.

The value of this property should be the class name of a subclass of IOXPath.

See Also:
Constant Field Values

SYSTEM_PROPERTY_PASS_VALIDATION_WITHOUT_RESOURCE

public static final String SYSTEM_PROPERTY_PASS_VALIDATION_WITHOUT_RESOURCE
The System property key used to determine the behaviour of this class when a required resource is not available. When present and equal to "true" this class will successsfully validate all objects, otherwise all validate calls will fail.

See Also:
Constant Field Values

XML_SCHEMA_INSTANCE_URI

public static final String XML_SCHEMA_INSTANCE_URI
The XML schema instance namespace URI, often used with prefix 'xsi'.

See Also:
Constant Field Values

KEY_NO_NAMESPACE_SCHEMA_LOCATION

public static final String KEY_NO_NAMESPACE_SCHEMA_LOCATION
A client property key used to locate a schema for elements that are not in any namespace (note: attributes that are not in any namespace are assumed to be declared in the same schema as their parent element). The value of this properties should be a relative or absolute URL defining where the schema document can be found.

See Also:
Constant Field Values

KEY_SCHEMA_LOCATION

public static final String KEY_SCHEMA_LOCATION
A client property key used to locate a schema for elements and attributes that are in a specified namespace. The value of this property should be a namespace URI followed by a space and then the relative or absolute URL defining where the schema document for that namespace can be found.

See Also:
Constant Field Values

KEY_DOCTYPE_NAME

public static final String KEY_DOCTYPE_NAME
A client property key used to specify the name of the DOCTYPE xml structure.

See Also:
Constant Field Values

KEY_DOCTYPE_PUBLICID

public static final String KEY_DOCTYPE_PUBLICID
A client property key used to specify the public ID of the DOCTYPE xml structure.

See Also:
Constant Field Values

KEY_DOCTYPE_SYSTEMID

public static final String KEY_DOCTYPE_SYSTEMID
A client property key used to specify the system ID of the DOCTYPE xml structure.

See Also:
Constant Field Values

KEY_CDATA

public static final String KEY_CDATA
A client property key used to specify the content of an element is enclosed in a CDATA section.

See Also:
Constant Field Values

KEY_ENCODING

public static final String KEY_ENCODING
Deprecated. Encoding is a presentation property and thus should not be stored as part of the data model.
A client property key used to specify the encoding of an instance document.

See Also:
Constant Field Values

KEY_NO_DEFAULT_NAMESPACE_MAPPING

public static final String KEY_NO_DEFAULT_NAMESPACE_MAPPING
A client property used to specify explicitly that the default namespace mapping should not be used.

Its value should be set to Boolean.TRUE or "true" if required.

See Also:
Constant Field Values

JAVA_VERSION

public static final String JAVA_VERSION

The java.version System Property. Java version number.

Defaults to null if the runtime does not have security access to read this property or the property does not exist.

Since:
Java 1.1

JAVA_VERSION_FLOAT

public static final float JAVA_VERSION_FLOAT

Gets the Java version as a float.

Example return values:

The field will return zero if JAVA_VERSION is null.

Since:
2.0

IS_JAVA_1_1

public static final boolean IS_JAVA_1_1

Is true if this is Java version 1.1 (also 1.1.x versions).

The field will return false if JAVA_VERSION is null.


IS_JAVA_1_2

public static final boolean IS_JAVA_1_2

Is true if this is Java version 1.2 (also 1.2.x versions).

The field will return false if JAVA_VERSION is null.


IS_JAVA_1_3

public static final boolean IS_JAVA_1_3

Is true if this is Java version 1.3 (also 1.3.x versions).

The field will return false if JAVA_VERSION is null.


IS_JAVA_1_4

public static final boolean IS_JAVA_1_4

Is true if this is Java version 1.4 (also 1.4.x versions).

The field will false false if JAVA_VERSION is null.


IS_JAVA_1_5

public static final boolean IS_JAVA_1_5

Is true if this is Java version 1.5 (also 1.5.x versions).

The field will return false if JAVA_VERSION is null.


CDATA_START

public static final String CDATA_START
The start of a CDATA block.

See Also:
Constant Field Values

CDATA_END

public static final String CDATA_END
The end of a CDATA block.

See Also:
Constant Field Values

DEFAULT_LOG

public static final Logger DEFAULT_LOG
The default log used by the C24 Integration Objects API.

Constructor Detail

Utils

protected Utils()
Method Detail

checkLicense

public static final void checkLicense()
Called by various parts of the API to check the presence and validity of a license key.


checkUILicense

public static final void checkUILicense()
Called by various parts of the API to check the presence and validity of a license key.


printLicense

public static final void printLicense()
Prints the license details to System.out


printLicense

public static final void printLicense(PrintStream ps,
                                      String warning)
Prints the license to the specified stream.

Parameters:
ps - The stream to print the license details to.

verifyUILicense

public static final boolean verifyUILicense(File licenseFile)
Client code should call this method before invoking any other part of the C24 Integration Objects API.

Doing so will load a license from licenseFile and validate it.

Parameters:
licenseFile - The file representing the license or a directory containing a single valid license file.
Returns:
Whether the license was successfully loaded.
See Also:
verifyLicense(biz.c24.api.License)

verifyLicense

public static final boolean verifyLicense(File licenseFile)
Client code should call this method before invoking any other part of the C24 Integration Objects API.

Doing so will load a license from licenseFile and validate it.

Parameters:
licenseFile - The file representing the license or a directory containing a single valid license file.
Returns:
Whether the license was successfully loaded.
See Also:
verifyLicense(biz.c24.api.License)

verifyLicense

public static final boolean verifyLicense(InputStream stream)
Client code should call this method before invoking any other part of the C24 Integration Objects API.

Doing so will load a license from stream and validate it.

Packaging the license file in a JAR and accessing it as a resource will provide better stability. This can be done as follows:
Utils.verifyLicense(MyClass.getClass().getClassLoader().getResourceAsStream("license-yyyy-MM-dd-My License.dat"));

Parameters:
stream - The stream from which the license can be read.
Returns:
Whether the license was successfully loaded.
See Also:
verifyLicense(biz.c24.api.License)

verifyLicense

public static final void verifyLicense(License license)
Client code should call this method before invoking any other part of the C24 Integration Objects API.

Parameters:
license - The license.

removeNamespaceMapping

public static void removeNamespaceMapping(ComplexDataObject obj,
                                          String uri,
                                          String prefix)
Removes the namespace mapping object from obj which has the specified uri and prefix values.

Parameters:
obj - The object to remove the namespace mapping from.
uri - The uri of the namespace.
prefix - The prefix used by the namespace mapping.

getURIForPrefix

public static String getURIForPrefix(ComplexDataObject obj,
                                     String prefix)
Returns the namespace URI mapped to by prefix.

Parameters:
obj - The object to examine for the namespace.
prefix - The prefix of the namespace mapping to be returned.
Returns:
The namespace URI if found otherwise null.

getModelForURI

public static DataModel getModelForURI(ComplexDataObject obj,
                                       String uri)
Retuns the model mapped to by prefix.

Parameters:
obj - The object to examine for the namespace.
uri - The uri to search for.
Returns:
The model whose target namespace is uri.

getPrefix

public static String getPrefix(Object obj,
                               DataComponent component,
                               ComplexDataObject parent,
                               String uri,
                               boolean notEmpty)
Returns the prefix which should be used for obj with respect to parent.

Parameters:
obj - The object whose name requires prefixing.
component - The element or attribute defining obj.
parent - The parent of obj.
uri - The namespace URI.
notEmpty - Whether to return a non empty prefix if none can be found.
Returns:
The prefix.

getXsiPrefix

public static String getXsiPrefix(ComplexDataObject object)
Returns the XSI prefix mapped to by object.

Parameters:
object - The object to query.
Returns:
The prefix used for the XSI namespace.

getParentChildElementName

public static String getParentChildElementName(ComplexDataObject obj)
Retrieve object name that expected while call getParent().getElement() function.

Parameters:
obj - object
Returns:
type name

xpath

public static String xpath(ComplexDataObject obj,
                           boolean ignoreDocumentNode)

xpath

public static String xpath(ComplexDataObject object,
                           boolean ignoreDocumentNode,
                           String elementName)
Returns the xpath string which can be used to access obj.

Parameters:
object - The object to get the xpath for.
ignoreDocumentNode - specify either Document Node should be ignored or not.
elementName - The element name of object to get the xpath for.
Returns:
The xpath string.

xpath

public static String xpath(ComplexDataObject obj)
Returns the xpath string which can be used to access obj.

Parameters:
obj - The object to get the xpath for.
Returns:
The xpath string.

isAncestor

public static boolean isAncestor(ComplexDataObject parent,
                                 ComplexDataObject decendant)
Returns whether the first argument is a descendant of the second.

Parameters:
parent - The parent object.
decendant - The proposed descendant
Returns:
The result.

ancestorArray

public static ComplexDataObject[] ancestorArray(ComplexDataObject obj)
Returns an array of the ancestors of obj.
The first item in the array will be the parent of obj and the last will be the root of the hierarchy.

Parameters:
obj - The object whose ancestors are to be queried.
Returns:
An array of ancestors.

ancestorArrayReversed

public static ComplexDataObject[] ancestorArrayReversed(ComplexDataObject obj)
Returns an array of the ancestors of obj.
The first item in the array will be the root of the hierarchy and the last will be the parent of obj.

Parameters:
obj - The object whose ancestors are to be queried.
Returns:
An array of ancestors.

depth

public static int depth(ComplexDataObject obj)
Returns the depth of obj in it's hierarchy.
The root will have a depth of 0.

Parameters:
obj - The object to be queried.
Returns:
The depth

parentIterator

public static Iterator parentIterator(ComplexDataObject obj)
Returns an iterator over all of the parents of obj.

Parameters:
obj - The object to be queried.
Returns:
The iterator.

elementIterator

public static Iterator elementIterator(ComplexDataObject obj)
Returns an iterator over all of the elements of obj.

Parameters:
obj - The object to be queried.
Returns:
The iterator.

attrIterator

public static Iterator attrIterator(ComplexDataObject obj)
Returns an iterator over all of the attributes of obj.

Parameters:
obj - The object to be queried.
Returns:
The iterator.

createEnumeration

public static Enumeration createEnumeration(ComplexDataObject object,
                                            XPathStatement valuesXPath,
                                            XPathStatement namesXPath,
                                            XPathStatement descriptionsXPath)
                                     throws IOXPathException
Creates and returns a new enumeration populated from the result of executing the specified XPath expression over the specified object.

Parameters:
object - The object over which to execute the XPath.
valuesXPath - The XPath statement to select the values.
namesXPath - The possibly null XPath statement to select the names.
descriptionsXPath - The possibly null XPath statement to select the descriptions.
Returns:
The newly created enumeration.
Throws:
IOXPathException - If the XPath expression is invalid.
NullPointerException - If valuesXPath == null

createEnumeration

public static Enumeration createEnumeration(ComplexDataObject object,
                                            XPathStatement valuesXPath,
                                            XPathStatement namesXPath,
                                            XPathStatement descriptionsXPath,
                                            boolean trimValues)
                                     throws IOXPathException
Creates and returns a new enumeration populated from the result of executing the specified XPath expression over the specified object.

Parameters:
object - The object over which to execute the XPath.
valuesXPath - The XPath statement to select the values.
namesXPath - The possibly null XPath statement to select the names.
descriptionsXPath - The possibly null XPath statement to select the descriptions.
trimValues - allows the retrieved values to be trimmed
Returns:
The newly created enumeration.
Throws:
IOXPathException - If the XPath expression is invalid.
NullPointerException - If valuesXPath == null

createEnumeration

public static Enumeration createEnumeration(String[] values,
                                            String[] names,
                                            String[] descriptions)
Creates and returns a new enumeration populated from the specified array of values.

Parameters:
values - The string values to populate the enumeration with.
names - The possibly null array of names associated with the value.
descriptions - The possibly null array of descriptions associated with the value.
Returns:
The newly created enumeration.
Throws:
NullPointerException - If values == null

startsWith

public static boolean startsWith(String path,
                                 char ch)

endsWith

public static boolean endsWith(String path,
                               char ch)

divide

public static BigDecimal divide(BigDecimal bigDecimal1,
                                BigDecimal bigDecimal2)

divideAndRemainder

public static BigDecimal[] divideAndRemainder(BigDecimal bigDecimal1,
                                              BigDecimal bigDecimal2)

pow

public static BigInteger pow(BigInteger bigInteger,
                             int exponent)

pow

public static BigDecimal pow(BigDecimal bigDecimal,
                             int exponent)

hashCode

public static int hashCode(Object obj)

isAttribute

public static boolean isAttribute(IOContext context)
Returns whether the supplied object represents an attribute. DO NOT USE - this method will be changed in a future release.

Parameters:
context - The context.
Returns:
Whether content is an attribute.

isElement

public static boolean isElement(ComplexDataObject obj)
Returns whether the supplied object represents an attribute. DO NOT USE - this method will be changed in a future release.

Parameters:
obj - The object.
Returns:
Whether obj is an attribute.

locateIdNodes

public static ComplexDataObject[] locateIdNodes(ComplexDataObject context,
                                                String[] ids)
Searches for ID elements or attributes within context whose values are equal to the entries in ids.

Parameters:
context - The context to search in.
ids - The ids to search for.
Returns:
The objects containing the ID components with null entries for any that could not be found.

locateIdNodes

public static ComplexDataObject[] locateIdNodes(ComplexDataObject context,
                                                String[] ids,
                                                Class returnClass)
Searches for ID elements or attributes within context whose values are equal to the entries in ids.

Parameters:
context - The context to search in.
ids - The ids to search for.
returnClass - The class of the array to be returned or null to return the result as a ComplexDataObject[].
Returns:
The objects containing the ID components with null entries for any that could not be found.

locateIdNode

public static ComplexDataObject locateIdNode(ComplexDataObject context,
                                             String id)
Searches for an ID element or attribute within context whose value is equal to id.

Parameters:
context - The context to search in.
id - The id to search for.
Returns:
The object containing the ID component or null if none could be found.

locateIdNode

public static ComplexDataObject locateIdNode(ComplexDataObject context,
                                             String id,
                                             Class returnClass)
Searches for an ID element or attribute within context whose value is equal to id.

Parameters:
context - The context to search in.
id - The id to search for.
returnClass - The class to be returned or null to return the result as ComplexDataObject.
Returns:
The object containing the ID component or null if none could be found.

formatObjectContent

public static String formatObjectContent(DataComponent comp,
                                         Object obj)
Formats the content of obj which should be defined by the element or attribute comp.

This method ignores initiators and terminators.

Parameters:
comp - The element or attribute defining obj.
obj - The object to be formatted.
Returns:
A string representation of the content of obj.

formatObjectContent

public static String formatObjectContent(DataComponent comp,
                                         Object obj,
                                         boolean includeComplexTypeContent)
Formats the content of obj which should be defined by the element or attribute comp.

This method ignores initiators and terminators.

Parameters:
comp - The element or attribute defining obj.
obj - The object to be formatted.
includeComplexTypeContent - Whether to include the textual content of complex objects
Returns:
A string representation of the content of obj.

loadValidator

public static Validator loadValidator(String[] classNames,
                                      ClassLoader classLoader,
                                      Class clazz)
Loads a validator instance by examing the classNames array.

Parameters:
classNames - The array of class names to attempt to load a validator from.
classLoader - The class loader to be used to load the Validator.
clazz - The clazz of Validator allowed to be returned.
Returns:
The loaded validator or an instance of the SimpleValidator if no valid class could be loaded from the array.

createURType

public static ComplexDataType createURType(String name,
                                           DataModel model)
Returns a new complex type which is the best possible representation of the UR-type (the base of all complex types).

Parameters:
name - The name of the type.
model - The model to which it belongs.
Returns:
The new UR-type.

pad

public static String pad(String original,
                         String pad,
                         PadJustificationEnum justification,
                         int amount,
                         int size)
Pads the supplied string.

Parameters:
original - The string to be padded.
pad - The padding string.
justification - The position of the padding.
amount - The amount to pad.
size - The minimum size of the resulting string.
Returns:
The resulting string.

unpad

public static String unpad(String original,
                           String pad,
                           PadJustificationEnum justification,
                           int amount,
                           int minSize)
Unpads the supplied string.

Parameters:
original - The string to be unpadded.
pad - The padding string.
justification - The position of the padding.
amount - The amount to unpad.
minSize - The minimum size of the resulting string.
Returns:
The resulting string.

whitespace

public static String whitespace(String original,
                                WhiteSpaceEnum whitespace)
Performs the specified whitespace behaviour to original.

Parameters:
original - The string.
whitespace - The behaviour to apply.
Returns:
The input string after the whitespace has been adjusted.

isNotEmptyContent

public static boolean isNotEmptyContent(String str)

isMethodPresent

public static boolean isMethodPresent(Class c,
                                      String name,
                                      Class[] params)
Returns true if the named method is present in the supplied class.

Parameters:
c - The class to test.
name - The name of the method to locate.
params - The method parameters.
Returns:
Whether the method is present.

valueOf

public static Boolean valueOf(boolean b)
Returns the object wrapper value of the supplied argument.

Parameters:
b - The boolean value.
Returns:
The equivalent wrapper object.

regex

public static RegExpEvaluator regex(String regex)
JDK independent helper method to return an equivalent to Matcher.

Parameters:
regex - The pattern to match.
Returns:
The matcher object.

matches

public static boolean matches(String str,
                              String regex)
JDK independent helper method for Matcher.matches().

Parameters:
str - The string test.
regex - The regular expression to match.
Returns:
The resulting string.

replaceAll

public static String replaceAll(String original,
                                String regex,
                                String replacement)
JDK independent helper method for Matcher.replaceAll(String).

Parameters:
original - The string test.
regex - The regular expression to match.
replacement - The replacement string.
Returns:
The resulting string.

replaceFirst

public static String replaceFirst(String original,
                                  String regex,
                                  String replacement)
JDK independent helper method for Matcher.replaceFirst(String).

Parameters:
original - The string test.
regex - The regular expression to match.
replacement - The replacement string.
Returns:
The resulting string.

split

public static String[] split(String str,
                             String regex)
JDK independent helper method for Pattern.split(CharSequence).

Parameters:
str - The string test.
regex - The regular expression to match.
Returns:
The resulting string array.

emptyIterator

public static Iterator emptyIterator()
Returns an empty iterator containing no items.

Returns:
An empty iterator.

singletonIterator

public static Iterator singletonIterator(Object obj)
Returns an iterator containing only the specified item.

Parameters:
obj - The object to appear in the iterator.
Returns:
A singleton iterator.

empty

public static boolean empty(String str)
Returns true is str is null or empty.

Parameters:
str - The string to test.
Returns:
Whether str is empty.

equals

public static boolean equals(Object obj1,
                             Object obj2)
Returns true if obj1 and obj2 are equal or both null.
This method handles the case where the arguments are null.

Parameters:
obj1 - The first object.
obj2 - The second object.
Returns:
Whether the arguments are equal or both null

objectHashCode

public static int objectHashCode(Object obj)
Returns the hashcode of obj or 0 if it is null.

Parameters:
obj - The object.
Returns:
The hashcode.

byteValue

public static byte byteValue(Object obj)
Returns a byte value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

byteValueArray

public static byte[] byteValueArray(Object obj)
Returns a byte value array from the argument.

Parameters:
obj - The object to query.
Returns:
The byte value array.
Throws:
ClassCastException - If obj is not a valid class.

shortValue

public static short shortValue(Object obj)
Returns a short value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

shortValueArray

public static short[] shortValueArray(Object obj)
Returns a short value array from the argument.

Parameters:
obj - The object to query.
Returns:
The short value array.
Throws:
ClassCastException - If obj is not a valid class.

intValue

public static int intValue(Object obj)
Returns an int value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

intValueArray

public static int[] intValueArray(Object obj)
Returns a int value array from the argument.

Parameters:
obj - The object to query.
Returns:
The int value array.
Throws:
ClassCastException - If obj is not a valid class.

longValue

public static long longValue(Object obj)
Returns a long value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

longValueArray

public static long[] longValueArray(Object obj)
Returns a long value array from the argument.

Parameters:
obj - The object to query.
Returns:
The long value array.
Throws:
ClassCastException - If obj is not a valid class.

integerValue

public static BigInteger integerValue(Object obj)
Returns a big integer value from the argument without a loss of precision. Accepts: Byte, Short, Integer, Long, BigInteger.

Parameters:
obj - object to convert
Returns:
The byte value.
Throws:
ClassCastException - for not supported argument types

floatValue

public static float floatValue(Object obj)
Returns a float value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

floatValueArray

public static float[] floatValueArray(Object obj)
Returns a float value array from the argument.

Parameters:
obj - The object to query.
Returns:
The float value array.
Throws:
ClassCastException - If obj is not a valid class.

doubleValue

public static double doubleValue(Object obj)
Returns a double value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - If obj is not a valid class.

doubleValueArray

public static double[] doubleValueArray(Object obj)
Returns a double value array from the argument.

Parameters:
obj - The object to query.
Returns:
The double value array.
Throws:
ClassCastException - If obj is not a valid class.

decimalValue

public static BigDecimal decimalValue(Object obj)
Returns a big decimal value from the argument without a loss of precision.

Parameters:
obj - The object to query.
Returns:
The byte value.
Throws:
ClassCastException - for not supported argument types

charValue

public static char charValue(Object obj)
Returns a char value from the argument.

Parameters:
obj - The object to query.
Returns:
The char value.
Throws:
ClassCastException - If obj is not a valid class.

charValueArray

public static char[] charValueArray(Object obj)
Returns a char value array from the argument.

Parameters:
obj - The object to query.
Returns:
The char value array.
Throws:
ClassCastException - If obj is not a valid class.

booleanValue

public static boolean booleanValue(Object obj)
Returns a boolean value from the argument.

Parameters:
obj - The object to query.
Returns:
The boolean value.
Throws:
ClassCastException - If obj is not a valid class.

booleanValueArray

public static boolean[] booleanValueArray(Object obj)
Returns a boolean value array from the argument.

Parameters:
obj - The object to query.
Returns:
The boolean value array.
Throws:
ClassCastException - If obj is not a valid class.

objectValueArray

public static Object[] objectValueArray(Object obj,
                                        Class clazz)
Returns an Object value array from the argument.

Parameters:
obj - The object to query.
clazz - The class of the array to be returned.
Returns:
The Object value array.
Throws:
ClassCastException - If obj is not a valid class.

listValue

public static List listValue(Object obj)
Returns a list derived from the argument.

Parameters:
obj - The content of the list to be returned.
Returns:
The list.

getTab

public static String getTab(int length)
Returns a string of 3 spaces repeated length times.

Parameters:
length - The length of string to return.
Returns:
The string of spaces.

clearNulls

public static void clearNulls(List l)
Clears any null values from the supplied list.

Parameters:
l - The list to be cleared of null values.

clearNulls

public static Object[] clearNulls(Object[] arr)
Clears any null values from the supplied array.

Parameters:
arr - The array to be cleared of null values.
Returns:
A (possibly new) array with no null values or null if no non-null values are found.

createObjectInputStream

public static ObjectInputStream createObjectInputStream(InputStream is)
                                                 throws IOException
Returns a new optimized input stream.

The returned implementation relies on the fact that the receiving OuputStream is created by createObjectOutputStream(java.io.OutputStream) and that the classes for all serialized objects are unchanged in all JVMs which will deserialize the object.

Parameters:
is - The input stream to wrap.
Returns:
The new stream.
Throws:
IOException - If an I/O error occurs while reading the stream header.

createObjectOutputStream

public static ObjectOutputStream createObjectOutputStream(OutputStream os)
                                                   throws IOException
Returns a new optimized output stream.

The returned implementation relies on the fact that the sending InputStream is created by createObjectInputStream(java.io.InputStream) and that the classes for all serialized objects are unchanged from the sending JVM.

Parameters:
os - The output stream to wrap.
Returns:
The new stream.
Throws:
IOException - If an I/O error occurs while writing the stream header.

lineNumber

public static int lineNumber(StringBuffer buffer,
                             int offset)
Computes the line number at offset.

Parameters:
buffer - The buffer to search through.
offset - The offset to find.
Returns:
The line number.

columnNumber

public static int columnNumber(StringBuffer buffer,
                               int offset,
                               int previousColumnNumber)
Computes the column number at offset.

Parameters:
buffer - The buffer to search through.
offset - The offset to find.
previousColumnNumber - The index of the last column number.
Returns:
The column number.

extractLocationDetails

public static String extractLocationDetails(SAXParseException ex)
Returns a string containing the location details extracted from the supplied exception.

Parameters:
ex - The exception object.
Returns:
The location string.

nextFile

public static File nextFile(DecimalFormat numericIncrementFormat,
                            String fileMask,
                            File dir)
Returns a file which does not exist in the specified directory.

The numericIncrementFormat is used to replace the '%' character in the fileMask until a file which does not exist is found.

Parameters:
numericIncrementFormat - The format of the string replacement of the '%' character in the fileMask
fileMask - The name of the file (containing a '%' character).
dir - The directory to search in.
Returns:
The new file.
Throws:
IllegalArgumentException - If fileMask does not contain a '%' character.

copyFile

public static boolean copyFile(String srcName,
                               String destName)
Copies a file.

Parameters:
srcName - The name of the file to be copied.
destName - The name of the file to copy to.
Returns:
Whether the copy was successful.

readFile

public static String readFile(File file)
                       throws IOException
Reads the specified file into a String using the UTF-8 encoding.

Parameters:
file - The file to be read.
Returns:
The content of the file.
Throws:
IOException - If their was an error reading the file.

readFile

public static String readFile(File file,
                              String encoding)
                       throws IOException
Reads the specified file into a String using the specified encoding.

Parameters:
file - The file to be read.
encoding - The encoding used in the file
Returns:
The content of the file.
Throws:
IOException - If their was an error reading the file.

writeFile

public static void writeFile(File f,
                             String str)
                      throws IOException
Writes the specified String into a file using the UTF-8 encoding.

Parameters:
f - The file to be written.
str - The String to write.
Throws:
IOException - If their was an error writting the file.

writeFile

public static void writeFile(File f,
                             String str,
                             String encoding)
                      throws IOException
Writes the specified String into a file using the specified encoding.

Parameters:
f - The file to be written.
str - The String to write.
encoding - The encoding for the file.
Throws:
IOException - If their was an error writting the file.

writeFile

public static void writeFile(File f,
                             String str,
                             String encoding,
                             boolean append)
                      throws IOException
Writes the specified String into a file using the UTF-8 encoding.

Parameters:
f - The file to be written.
str - The String to write.
encoding - The encoding for the file.
append - Whether to append to the file or overwrite.
Throws:
IOException - If their was an error writting the file.

getEncodingName

public static String getEncodingName(InputStream stream)
                              throws IOException
Returns the IANA encoding name that is auto-detected from the supplied stream.

Parameters:
stream - The stream to read from.
Returns:
the IANA encoding string.
Throws:
IOException - If an I/O error occurs when reading from the stream.

isTextualSource

public static boolean isTextualSource(Source s)
Returns whether the specified source takes textual data as input.

Parameters:
s - The source to test.
Returns:
Whether the input from s should be text.

isTextualSink

public static boolean isTextualSink(Sink s)
Returns whether the specified sink provides textual data as output.

Parameters:
s - The sink to test.
Returns:
Whether the output from s will be text.

initialise

public static void initialise(ComplexDataType t)
Initialises a type hierarchy.

This method can be used to ensure a type which has been deployed using lazy initialisation is fully initialised.

Parameters:
t - The type to initialise.

regexFileFilter

public static FileFilter regexFileFilter(String regex)
Returns a file filter which will accept files matching the regex argument.

Parameters:
regex - The regular expression to match.
Returns:
The filter.

regexFileFilter

public static FileFilter regexFileFilter(String[] regex)
Returns a file filter which will accept files matching an entry in the regex argument.

Parameters:
regex - The regular expressions to match.
Returns:
The filter.

cloneDeep

public static Object cloneDeep(Object obj,
                               ComplexDataObject parent,
                               String elementDeclName)
                        throws CloneNotSupportedException
Retruns a deep clone of the supplied object.

Parameters:
obj - The object to be cloned.
parent - The parent of the object to be cloned.
elementDeclName - The name of the containing element declaration.
Returns:
The clone.
Throws:
CloneNotSupportedException - If the object is or contains an uncloneable object.

isJavaVersionAtLeast

public static boolean isJavaVersionAtLeast(float requiredVersion)

Is the Java version at least the requested version.

Example input:

Parameters:
requiredVersion - the required version, for example 1.31f
Returns:
true if the actual version is equal or greater than the required version

bigIntegerValueWrapper

public static BigInteger bigIntegerValueWrapper(Number value)
Converts integer value objects to BigInteger object. Accepts: Byte, Short, Integer, Long, BigInteger. For null value returns zero-object.

Parameters:
value - to convert
Returns:
value converted to BigInteger object
Throws:
IllegalArgumentException - for not supported argument types

bigDecimalValueWrapper

public static BigDecimal bigDecimalValueWrapper(Number value)
Converts number value objects to BigDecimal object. For null value returns zero-object.

Parameters:
value - to convert
Returns:
value converted to BigDecimal object
Throws:
IllegalArgumentException - for not supported argument types

isBigDecimalOrBigInteger

public static boolean isBigDecimalOrBigInteger(Number arg)
Checks whether arg is an instance of BigInteger or BigDecimal.

Parameters:
arg - value to check
Returns:
true if arg is an instance of BigInteger or BigDecimal

isBigDecimalOrBigInteger

public static boolean isBigDecimalOrBigInteger(Number arg1,
                                               Number arg2)
Checks whether arg1 or arg2 is an instance of BigInteger or BigDecimal.

Parameters:
arg1 - First value to check
arg2 - Second value to check
Returns:
true if arg1 or artg2 is an instance of BigInteger or BigDecimal

isBigInteger

public static boolean isBigInteger(Number arg1,
                                   Number arg2)
Checks whether arg1 or arg2 is an instance of BigInteger.

Parameters:
arg1 - 1st value to check
arg2 - 2nd value to check
Returns:
true if arg1 or arg2 is an instance of BigInteger

booleanSystemProperty

public static boolean booleanSystemProperty(String key,
                                            boolean def)
Returns the value of the specified system proeprty, default to def is the proeprty is not found.

Parameters:
key - The system property key.
def - The default value to be returned if the property can not be found.
Returns:
The value.

stringSystemProperty

public static String stringSystemProperty(String key,
                                          String def)
Returns the value of the specified system proeprty, default to def is the proeprty is not found.

Parameters:
key - The system property key.
def - The default value to be returned if the property can not be found.
Returns:
The value.

deriveElement

public static Element deriveElement(String rootClassName,
                                    ClassLoader classLoader)
Derives an Element from the specified class name.

This method will infer an Element from a class name that locates an Element directly, a ComplexDataObject or a ComplexDataType.

Parameters:
rootClassName - The class name.
classLoader - The class loader to use to instantiate the element.
Returns:
The Element.

createSimpleValue

public static Object createSimpleValue(DataComponent component,
                                       String value)
                                throws ParserException
Creates a value from the given string representation.
This method differs from DataComponent.parseObject(String) because if the DataComponent being parsed against has a complex type, it will parse the value as the content of the complex type (if present) and return that content wrapped in appropriate ComplexDataObject.

Parameters:
component - The component to parse the value against.
value - The string value to be parsed.
Returns:
The parsed simple value (e.g. String, Integer, Date etc.) or a ComplexDataObject with content.
Throws:
ParserException - If an error occured whilst parsing the value.

getDataSourceNames

public static String[] getDataSourceNames(ComplexDataType type)
Returns an array contining the connection names of all database validators used by the specified type. NOTE: Please ensure that the Hibernate & required 3rd party libraries added to your classpath (hibernate3.jar etc.). For more information about the Hibernate please visit: http://www.hibernate.org/

Parameters:
type - The type to be examined.
Returns:
The database connection names.

isSuppressExternalizedValidationWarnings

public static boolean isSuppressExternalizedValidationWarnings()

escape

public static String escape(String str)
Escapes all new line and tab characters in the specified string.

Parameters:
str - The orignal string.
Returns:
The escaped string.

openEditionUIWarning

public static String openEditionUIWarning(String name)

openEditionWarning

public static String openEditionWarning(String name)

getSalesEmailAddress

public static String getSalesEmailAddress(License license)

getSalesEmailAddress

public static String getSalesEmailAddress(boolean noLicense,
                                          boolean isOemProduct,
                                          boolean isOpenEdition)

getSupportEmailAddress

public static String getSupportEmailAddress(License license)

getSupportEmailAddress

public static String getSupportEmailAddress(boolean noLicense,
                                            boolean isOemProduct,
                                            boolean isOpenEdition)

getSupportTelephoneNumber

public static String getSupportTelephoneNumber(License license)

getSupportTelephoneNumber

public static String getSupportTelephoneNumber(boolean noLicense,
                                               boolean isOemProduct,
                                               boolean isOpenEdition)

getSupportURL

public static String getSupportURL(License license)

getSupportURL

public static String getSupportURL(boolean noLicense,
                                   boolean isOemProduct,
                                   boolean isOpenEdition)

getContactUsURL

public static String getContactUsURL(License license)

getContactUsURL

public static String getContactUsURL(boolean noLicense,
                                     boolean isOemProduct,
                                     boolean isOpenEdition)

getContactUsForLicenseText

public static String getContactUsForLicenseText(License license)

getContactUsForLicenseText

public static String getContactUsForLicenseText(boolean noLicense,
                                                boolean isOemProduct,
                                                boolean isOpenEdition)

initialiseQuietly

protected static void initialiseQuietly()
Initialises properties


initialise

public static void initialise()
                       throws IOException
Throws:
IOException

getOptionalProperty

public static String getOptionalProperty(String name)
Gets an optional property of the Environment

Parameters:
name - Name of property
Returns:
Value of property

getProperty

public static String getProperty(String name)
Gets a property of the Environment

Parameters:
name - Name of property
Returns:
Value of property

getMessage

public static String getMessage(Throwable t)
Extract localized message from a throwable instance and format it with class name prefix.

Parameters:
t - a throwable to extract message from
Returns:
the formatted message string

getProperties

protected static Properties getProperties()
Gets all the properties of the environment Gets the properties of the Environment

Returns:
Environment properties

initProperties

protected static void initProperties(Properties newprops)
Sets the content of Environment without reading from a properties file


setProperties

protected static void setProperties(Properties newProps)
Sets the content of Environment


resetProperties

protected static void resetProperties()

isMacOS

public static boolean isMacOS()

isEmpty

public static boolean isEmpty(String text)
check if a string is null or empty.

Parameters:
text -
Returns:
true if null or empty.

eq

public static boolean eq(String str1,
                         String str2)
compare 2 strings, either of which might be null

Parameters:
str1 -
str2 -
Returns:
true if they are equal (or both null).

eq

public static boolean eq(Object o1,
                         Object o2)
compare 2 objects, either of which might be null


getElementsFromXPath

public static List getElementsFromXPath(XPathStatement xPathStatement,
                                        ComplexDataObject complexDataObject)

getElementsFromXPath

public static List getElementsFromXPath(String xpathString,
                                        ComplexDataObject complexDataObject)

countElementsFromXPath

public static int countElementsFromXPath(String xpathString,
                                         ComplexDataObject complexDataObject)

countElementsFromXPath

public static int countElementsFromXPath(List<String> xpath,
                                         int index,
                                         ComplexDataObject complexDataObject)

arrayToStringBuffer

public static StringBuffer arrayToStringBuffer(String[] arr)
Construct the StringBuffer from an array

Parameters:
arr -
Returns:
StringBuffer


C24 Technologies © 2002-2012: All Rights Reserved.