public class Util
extends java.lang.Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkValueList(java.lang.String allowedValues,
java.lang.String value,
java.lang.String name)
Checks if a given value is in a given list of allowed values.
|
static int |
compareAllowingNull(java.lang.String s1,
java.lang.String s2)
Compares two strings allowing them to be null.
|
static java.util.List<java.lang.String> |
createFixedSequences(java.util.List<CTag> list,
boolean errorOnMissingFirstNo)
Creates a list of sequences of code markers that must not be re-ordered
from the list of all code markers in a given source or target content.
|
static boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
Checks if two objects are equal, even if either is null.
|
static boolean |
isModule(java.lang.String nsUri,
java.lang.String moduleSuffix)
Indicates if the given namespace URI is of a given module or not.
|
static boolean |
isNoE(java.lang.String string)
Checks if a string is null or empty.
|
static boolean |
isValidInXML(int cp)
Indicates if a given code point is valid in XML or not.
|
static boolean |
isValidNmtoken(java.lang.String value)
Verifies if a given value is a valid NMTOKEN value.
|
static void |
removeExtensions(java.lang.Object object)
Removes extension attributes and elements from a given object.
|
static void |
removeModules(java.lang.Object object,
java.lang.String moduleSuffix)
Removes modules attributes and elements from a given object.
|
static boolean |
supports(java.lang.String nsUri)
Indicates if a given module is directly supported by this version of the library.
|
static java.lang.String |
toSafeXML(java.lang.String text)
Converts a text to an XML-escaped text and using <cp> elements
for the characters that are invalid in XML.
|
static java.lang.String |
toXML(java.lang.String text,
boolean attribute)
Converts a text to an XML-escaped text.
|
static void |
validateCopyOf(Unit unit)
Verifies the copyOf attributes in a given unit.
|
static java.lang.String |
validateLang(java.lang.String lang)
Verifies the syntax of a language code.
|
static void |
verifyReordering(java.util.List<CTag> original,
java.util.List<CTag> toVerify,
boolean errorOnMissingFirstNo)
Verifies if the sequences of codes that cannot be re-ordered have been preserved.
|
public static boolean isNoE(java.lang.String string)
string - the string to check.public static java.lang.String toXML(java.lang.String text,
boolean attribute)
Use toSafeXML(String) to convert content where <cp> is allowed.
text - the text to convert.attribute - true if the text is to be an XML attribute value.public static java.lang.String toSafeXML(java.lang.String text)
text - the text to convert.public static int compareAllowingNull(java.lang.String s1,
java.lang.String s2)
s1 - the first string.s2 - the second string.public static boolean equals(java.lang.Object o1,
java.lang.Object o2)
o1 - the first object (can be null).o2 - the second object (can be null).public static boolean checkValueList(java.lang.String allowedValues,
java.lang.String value,
java.lang.String name)
allowedValues - list of allowed values (each value must be separated by a semicolon).value - the value to check.name - the name of the object to check (e.g. name of the attribute).InvalidParameterException - if the value is invalid.public static java.util.List<java.lang.String> createFixedSequences(java.util.List<CTag> list, boolean errorOnMissingFirstNo)
list - the list of code markers to build from.errorOnMissingFirstNo - true to throw an exception if a 'no' is detected instead of a 'firstNo'
as a start of a sequence, false to assume it's a firstNo and process without error.Entries in the list are separated by a '|' and are made of a prefix 'c' for closing marker or 'z' for opening or placeholder, followed by the id of the code. the list ends with a '|'.
InvalidParameterException - if errorOnMissingFirstNo is true and a firstNo is missing.public static void verifyReordering(java.util.List<CTag> original, java.util.List<CTag> toVerify, boolean errorOnMissingFirstNo)
Use createFixedSequences(List, boolean) to create the lists to compare.
original - the list of the inline codes of the original state.toVerify - the list of the inline codes of the state to verify.errorOnMissingFirstNo - true to throw an exception if a 'no' is detected instead of a 'firstNo'
as a start of a sequence, false to assume it's a firstNo and process without error.InvalidMarkerOrderException - if one marker of the list to verify is out-of-order.createFixedSequences(List, boolean)public static boolean isValidNmtoken(java.lang.String value)
value - the value to check.public static void removeExtensions(java.lang.Object object)
object - the object from where the extension must be removed.public static void removeModules(java.lang.Object object,
java.lang.String moduleSuffix)
object - the object from where the modules must be removed.moduleSuffix - suffix part of the module's namespace to remove, or null for all modules.public static boolean isModule(java.lang.String nsUri,
java.lang.String moduleSuffix)
nsUri - the full URI for the namespace to test.moduleSuffix - the suffix of the namespace of the given module, use null for all modules.public static boolean isValidInXML(int cp)
cp - the code point to evaluate.public static void validateCopyOf(Unit unit)
unit - the unit to verify.public static java.lang.String validateLang(java.lang.String lang)
lang - the language code to verify.public static boolean supports(java.lang.String nsUri)
nsUri - the namespace URI of the module to query.