|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbiz.c24.io.api.Utils
public class Utils
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 |
---|
protected static String C24_HOME_DIR
public static final String OEM_EULA
public static final String OEM_SALES_EMAIL
public static final String OEM_SUPPORT_EMAIL
public static final String OEM_SUPPORT_TELEPHONE
public static final String OEM_SUPPORT_URL
public static final String OEM_CONTACTUS_URL
public static final String SYSTEM_PROPERTY_SUPPRESS_SWIFT_WARNINGS
SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS
instead.public static final String SYSTEM_PROPERTY_SWIFT_BIC_CODE_FILE
SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE
instead.public static final String SYSTEM_PROPERTY_SWIFT_COUNTRY_CODE_FILE
SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE
instead.public static final String SYSTEM_PROPERTY_SWIFT_CURRENCY_CODE_FILE
SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE
instead.public static final String SYSTEM_PROPERTY_TARGET2_FILE
public static final String SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE
public static final String SYSTEM_PROPERTY_BIC_PLUS_IBAN_DIRECTORY_FILE
public static final String SYSTEM_PROPERTY_SEPA_ROUTING_DIRECTORY_FILE
public static final String SYSTEM_PROPERTY_ISO3166_COUNTRY_CODE_FILE
public static final String SYSTEM_PROPERTY_ISO4217_CURRENCY_CODE_FILE
public static final String SYSTEM_PROPERTY_SUPPRESS_EXTERNALIZED_VALIDATION_WARNINGS
public static final String SYSTEM_PROPERTY_SUPPRESS_DATABASE_KEY_VALIDATION
This property would commonly be set to "false" in cases where Hibernate is being used to generate database keys.
public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_PRESENT
public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_ZERO
public static final String SYSTEM_PROPERTY_ISO8601_TIME_ZONE_COLON
public static final String SYSTEM_PROPERTY_GENERICDATE_TIME_ZONE_AS_ISO8601
The Value of this property should be the required timezone ID or 'NULL' to remove timezone information altogether.
public static final String SYSTEM_PROPERTY_SWIFT_DIRECTORY_FILE
SYSTEM_PROPERTY_ISO9362_BIC_CODE_FILE
instead.
public static final String SYSTEM_PROPERTY_XPATH_IMPLEMENTATION
IOXPathFactory
.
The value of this property should be the class name of a subclass of IOXPath
.
public static final String SYSTEM_PROPERTY_PASS_VALIDATION_WITHOUT_RESOURCE
public static final String XML_SCHEMA_INSTANCE_URI
public static final String KEY_NO_NAMESPACE_SCHEMA_LOCATION
public static final String KEY_SCHEMA_LOCATION
public static final String KEY_DOCTYPE_NAME
public static final String KEY_DOCTYPE_PUBLICID
public static final String KEY_DOCTYPE_SYSTEMID
public static final String KEY_CDATA
public static final String KEY_ENCODING
public static final String KEY_NO_DEFAULT_NAMESPACE_MAPPING
Its value should be set to Boolean.TRUE or "true" if required.
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.
public static final float JAVA_VERSION_FLOAT
Gets the Java version as a float
.
Example return values:
1.2f
for JDK 1.2
1.31f
for JDK 1.3.1
The field will return zero if JAVA_VERSION
is null
.
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
.
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
.
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
.
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
.
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
.
public static final String CDATA_START
public static final String CDATA_END
public static final Logger DEFAULT_LOG
Constructor Detail |
---|
protected Utils()
Method Detail |
---|
public static final void checkLicense()
public static final void checkUILicense()
public static final void printLicense()
public static final void printLicense(PrintStream ps, String warning)
ps
- The stream to print the license details to.public static final boolean verifyUILicense(File licenseFile)
Doing so will load a license from licenseFile
and validate it.
licenseFile
- The file representing the license or a directory containing a single valid license file.
verifyLicense(biz.c24.api.License)
public static final boolean verifyLicense(File licenseFile)
Doing so will load a license from licenseFile
and validate it.
licenseFile
- The file representing the license or a directory containing a single valid license file.
verifyLicense(biz.c24.api.License)
public static final boolean verifyLicense(InputStream stream)
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"));
stream
- The stream from which the license can be read.
verifyLicense(biz.c24.api.License)
public static final void verifyLicense(License license)
license
- The license.public static void removeNamespaceMapping(ComplexDataObject obj, String uri, String prefix)
obj
which has the specified uri and prefix values.
obj
- The object to remove the namespace mapping from.uri
- The uri of the namespace.prefix
- The prefix used by the namespace mapping.public static String getURIForPrefix(ComplexDataObject obj, String prefix)
prefix
.
obj
- The object to examine for the namespace.prefix
- The prefix of the namespace mapping to be returned.
public static DataModel getModelForURI(ComplexDataObject obj, String uri)
prefix
.
obj
- The object to examine for the namespace.uri
- The uri to search for.
uri
.public static String getPrefix(Object obj, DataComponent component, ComplexDataObject parent, String uri, boolean notEmpty)
obj
with respect to parent
.
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.
public static String getXsiPrefix(ComplexDataObject object)
object
.
object
- The object to query.
public static String getParentChildElementName(ComplexDataObject obj)
obj
- object
public static String xpath(ComplexDataObject obj, boolean ignoreDocumentNode)
public static String xpath(ComplexDataObject object, boolean ignoreDocumentNode, String elementName)
obj
.
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.
public static String xpath(ComplexDataObject obj)
obj
.
obj
- The object to get the xpath for.
public static boolean isAncestor(ComplexDataObject parent, ComplexDataObject decendant)
parent
- The parent object.decendant
- The proposed descendant
public static ComplexDataObject[] ancestorArray(ComplexDataObject obj)
obj
.obj
and the last will be the root of the hierarchy.
obj
- The object whose ancestors are to be queried.
public static ComplexDataObject[] ancestorArrayReversed(ComplexDataObject obj)
obj
.obj
.
obj
- The object whose ancestors are to be queried.
public static int depth(ComplexDataObject obj)
obj
in it's hierarchy.
obj
- The object to be queried.
public static Iterator parentIterator(ComplexDataObject obj)
obj
.
obj
- The object to be queried.
public static Iterator elementIterator(ComplexDataObject obj)
obj
.
obj
- The object to be queried.
public static Iterator attrIterator(ComplexDataObject obj)
obj
.
obj
- The object to be queried.
public static Enumeration createEnumeration(ComplexDataObject object, XPathStatement valuesXPath, XPathStatement namesXPath, XPathStatement descriptionsXPath) throws IOXPathException
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.
IOXPathException
- If the XPath expression is invalid.
NullPointerException
- If valuesXPath == null
public static Enumeration createEnumeration(ComplexDataObject object, XPathStatement valuesXPath, XPathStatement namesXPath, XPathStatement descriptionsXPath, boolean trimValues) throws IOXPathException
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
IOXPathException
- If the XPath expression is invalid.
NullPointerException
- If valuesXPath == null
public static Enumeration createEnumeration(String[] values, String[] names, String[] descriptions)
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.
NullPointerException
- If values == null
public static boolean startsWith(String path, char ch)
public static boolean endsWith(String path, char ch)
public static BigDecimal divide(BigDecimal bigDecimal1, BigDecimal bigDecimal2)
public static BigDecimal[] divideAndRemainder(BigDecimal bigDecimal1, BigDecimal bigDecimal2)
public static BigInteger pow(BigInteger bigInteger, int exponent)
public static BigDecimal pow(BigDecimal bigDecimal, int exponent)
public static int hashCode(Object obj)
public static boolean isAttribute(IOContext context)
context
- The context.
content
is an attribute.public static boolean isElement(ComplexDataObject obj)
obj
- The object.
obj
is an attribute.public static ComplexDataObject[] locateIdNodes(ComplexDataObject context, String[] ids)
context
whose values are equal to the entries in ids
.
context
- The context to search in.ids
- The ids to search for.
public static ComplexDataObject[] locateIdNodes(ComplexDataObject context, String[] ids, Class returnClass)
context
whose values are equal to the entries in ids
.
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[]
.
public static ComplexDataObject locateIdNode(ComplexDataObject context, String id)
context
whose value is equal to id
.
context
- The context to search in.id
- The id to search for.
public static ComplexDataObject locateIdNode(ComplexDataObject context, String id, Class returnClass)
context
whose value is equal to id
.
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
.
public static String formatObjectContent(DataComponent comp, Object obj)
obj
which should be defined by the element or attribute comp
.This method ignores initiators and terminators.
comp
- The element or attribute defining obj
.obj
- The object to be formatted.
obj
.public static String formatObjectContent(DataComponent comp, Object obj, boolean includeComplexTypeContent)
obj
which should be defined by the element or attribute comp
.This method ignores initiators and terminators.
comp
- The element or attribute defining obj
.obj
- The object to be formatted.includeComplexTypeContent
- Whether to include the textual content of complex objects
obj
.public static Validator loadValidator(String[] classNames, ClassLoader classLoader, Class clazz)
classNames
array.
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.
SimpleValidator
if no valid class
could be loaded from the array.public static ComplexDataType createURType(String name, DataModel model)
name
- The name of the type.model
- The model to which it belongs.
public static String pad(String original, String pad, PadJustificationEnum justification, int amount, int size)
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.
public static String unpad(String original, String pad, PadJustificationEnum justification, int amount, int minSize)
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.
public static String whitespace(String original, WhiteSpaceEnum whitespace)
original
.
original
- The string.whitespace
- The behaviour to apply.
public static boolean isNotEmptyContent(String str)
public static boolean isMethodPresent(Class c, String name, Class[] params)
true
if the named method is present in the supplied class.
c
- The class to test.name
- The name of the method to locate.params
- The method parameters.
public static Boolean valueOf(boolean b)
b
- The boolean value.
public static RegExpEvaluator regex(String regex)
Matcher
.
regex
- The pattern to match.
public static boolean matches(String str, String regex)
Matcher.matches()
.
str
- The string test.regex
- The regular expression to match.
public static String replaceAll(String original, String regex, String replacement)
Matcher.replaceAll(String)
.
original
- The string test.regex
- The regular expression to match.replacement
- The replacement string.
public static String replaceFirst(String original, String regex, String replacement)
Matcher.replaceFirst(String)
.
original
- The string test.regex
- The regular expression to match.replacement
- The replacement string.
public static String[] split(String str, String regex)
Pattern.split(CharSequence)
.
str
- The string test.regex
- The regular expression to match.
public static Iterator emptyIterator()
public static Iterator singletonIterator(Object obj)
obj
- The object to appear in the iterator.
public static boolean empty(String str)
str
is null or empty.
str
- The string to test.
str
is empty.public static boolean equals(Object obj1, Object obj2)
obj1
and obj2
are equal or both null.
obj1
- The first object.obj2
- The second object.
public static int objectHashCode(Object obj)
obj
or 0 if it is null.
obj
- The object.
public static byte byteValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static byte[] byteValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static short shortValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static short[] shortValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static int intValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static int[] intValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static long longValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static long[] longValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static BigInteger integerValue(Object obj)
Byte
, Short
, Integer
, Long
, BigInteger
.
obj
- object to convert
ClassCastException
- for not supported argument typespublic static float floatValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static float[] floatValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static double doubleValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static double[] doubleValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static BigDecimal decimalValue(Object obj)
obj
- The object to query.
ClassCastException
- for not supported argument typespublic static char charValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static char[] charValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static boolean booleanValue(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static boolean[] booleanValueArray(Object obj)
obj
- The object to query.
ClassCastException
- If obj
is not a valid class.public static Object[] objectValueArray(Object obj, Class clazz)
obj
- The object to query.clazz
- The class of the array to be returned.
ClassCastException
- If obj
is not a valid class.public static List listValue(Object obj)
obj
- The content of the list to be returned.
public static String getTab(int length)
length
times.
length
- The length of string to return.
public static void clearNulls(List l)
null
values from the supplied list.
l
- The list to be cleared of null
values.public static Object[] clearNulls(Object[] arr)
null
values from the supplied array.
arr
- The array to be cleared of null
values.
null
values or null
if no non-null values are found.public static ObjectInputStream createObjectInputStream(InputStream is) throws IOException
createObjectOutputStream(java.io.OutputStream)
and that the classes for all serialized objects are
unchanged in all JVMs which will deserialize the object.
is
- The input stream to wrap.
IOException
- If an I/O error occurs while reading the stream header.public static ObjectOutputStream createObjectOutputStream(OutputStream os) throws IOException
createObjectInputStream(java.io.InputStream)
and that the classes for all serialized objects are
unchanged from the sending JVM.
os
- The output stream to wrap.
IOException
- If an I/O error occurs while writing the stream header.public static int lineNumber(StringBuffer buffer, int offset)
offset
.
buffer
- The buffer to search through.offset
- The offset to find.
public static int columnNumber(StringBuffer buffer, int offset, int previousColumnNumber)
offset
.
buffer
- The buffer to search through.offset
- The offset to find.previousColumnNumber
- The index of the last column number.
public static String extractLocationDetails(SAXParseException ex)
ex
- The exception object.
public static File nextFile(DecimalFormat numericIncrementFormat, String fileMask, File dir)
numericIncrementFormat
is used to replace the '%' character in the fileMask
until
a file which does not exist is found.
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.
IllegalArgumentException
- If fileMask
does not contain a '%' character.public static boolean copyFile(String srcName, String destName)
srcName
- The name of the file to be copied.destName
- The name of the file to copy to.
public static String readFile(File file) throws IOException
file
- The file to be read.
IOException
- If their was an error reading the file.public static String readFile(File file, String encoding) throws IOException
file
- The file to be read.encoding
- The encoding used in the file
IOException
- If their was an error reading the file.public static void writeFile(File f, String str) throws IOException
f
- The file to be written.str
- The String to write.
IOException
- If their was an error writting the file.public static void writeFile(File f, String str, String encoding) throws IOException
f
- The file to be written.str
- The String to write.encoding
- The encoding for the file.
IOException
- If their was an error writting the file.public static void writeFile(File f, String str, String encoding, boolean append) throws IOException
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.
IOException
- If their was an error writting the file.public static String getEncodingName(InputStream stream) throws IOException
stream
- The stream to read from.
IOException
- If an I/O error occurs when reading from the stream.public static boolean isTextualSource(Source s)
s
- The source to test.
s
should be text.public static boolean isTextualSink(Sink s)
s
- The sink to test.
s
will be text.public static void initialise(ComplexDataType t)
This method can be used to ensure a type which has been deployed using lazy initialisation is fully initialised.
t
- The type to initialise.public static FileFilter regexFileFilter(String regex)
regex
- The regular expression to match.
public static FileFilter regexFileFilter(String[] regex)
regex
- The regular expressions to match.
public static Object cloneDeep(Object obj, ComplexDataObject parent, String elementDeclName) throws CloneNotSupportedException
obj
- The object to be cloned.parent
- The parent of the object to be cloned.elementDeclName
- The name of the containing element declaration.
CloneNotSupportedException
- If the object is or contains an uncloneable object.public static boolean isJavaVersionAtLeast(float requiredVersion)
Is the Java version at least the requested version.
Example input:
1.2f
to test for JDK 1.21.31f
to test for JDK 1.3.1
requiredVersion
- the required version, for example 1.31f
true
if the actual version is equal or greater
than the required versionpublic static BigInteger bigIntegerValueWrapper(Number value)
Byte
, Short
, Integer
, Long
, BigInteger
.
For null
value returns zero-object.
value
- to convert
IllegalArgumentException
- for not supported argument typespublic static BigDecimal bigDecimalValueWrapper(Number value)
null
value returns zero-object.
value
- to convert
IllegalArgumentException
- for not supported argument typespublic static boolean isBigDecimalOrBigInteger(Number arg)
BigInteger
or BigDecimal
.
arg
- value to check
BigInteger
or BigDecimal
public static boolean isBigDecimalOrBigInteger(Number arg1, Number arg2)
BigInteger
or BigDecimal
.
arg1
- First value to checkarg2
- Second value to check
BigInteger
or BigDecimal
public static boolean isBigInteger(Number arg1, Number arg2)
BigInteger
.
arg1
- 1st value to checkarg2
- 2nd value to check
BigInteger
public static boolean booleanSystemProperty(String key, boolean def)
def
is the proeprty is not found.
key
- The system property key.def
- The default value to be returned if the property can not be found.
public static String stringSystemProperty(String key, String def)
def
is the proeprty is not found.
key
- The system property key.def
- The default value to be returned if the property can not be found.
public static Element deriveElement(String rootClassName, ClassLoader classLoader)
This method will infer an Element from a class name that locates an Element
directly,
a ComplexDataObject
or a ComplexDataType
.
rootClassName
- The class name.classLoader
- The class loader to use to instantiate the element.
public static Object createSimpleValue(DataComponent component, String value) throws ParserException
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
.
component
- The component to parse the value against.value
- The string value to be parsed.
ParserException
- If an error occured whilst parsing the value.public static String[] getDataSourceNames(ComplexDataType type)
type
- The type to be examined.
public static boolean isSuppressExternalizedValidationWarnings()
public static String escape(String str)
str
- The orignal string.
public static String openEditionUIWarning(String name)
public static String openEditionWarning(String name)
public static String getSalesEmailAddress(License license)
public static String getSalesEmailAddress(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
public static String getSupportEmailAddress(License license)
public static String getSupportEmailAddress(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
public static String getSupportTelephoneNumber(License license)
public static String getSupportTelephoneNumber(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
public static String getSupportURL(License license)
public static String getSupportURL(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
public static String getContactUsURL(License license)
public static String getContactUsURL(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
public static String getContactUsForLicenseText(License license)
public static String getContactUsForLicenseText(boolean noLicense, boolean isOemProduct, boolean isOpenEdition)
protected static void initialiseQuietly()
public static void initialise() throws IOException
IOException
public static String getOptionalProperty(String name)
name
- Name of property
public static String getProperty(String name)
name
- Name of property
public static String getMessage(Throwable t)
t
- a throwable to extract message from
protected static Properties getProperties()
protected static void initProperties(Properties newprops)
protected static void setProperties(Properties newProps)
protected static void resetProperties()
public static boolean isMacOS()
public static boolean isEmpty(String text)
text
-
public static boolean eq(String str1, String str2)
str1
- str2
-
public static boolean eq(Object o1, Object o2)
public static List getElementsFromXPath(XPathStatement xPathStatement, ComplexDataObject complexDataObject)
public static List getElementsFromXPath(String xpathString, ComplexDataObject complexDataObject)
public static int countElementsFromXPath(String xpathString, ComplexDataObject complexDataObject)
public static int countElementsFromXPath(List<String> xpath, int index, ComplexDataObject complexDataObject)
public static StringBuffer arrayToStringBuffer(String[] arr)
arr
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |