public class Util extends Object
| Constructor and Description |
|---|
Util() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
checkValueList(String allowedValues,
String value,
String name)
Checks if a given value is in a given list of allowed values.
|
static int |
compareAllowingNull(String s1,
String s2)
Compares two strings allowing them to be null.
|
static List<String> |
createFixedSequences(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(Object o1,
Object o2)
Checks if two objects are equal, even if either is null.
|
static boolean |
isModule(String nsUri,
String moduleSuffix)
Indicates if the given namespace URI is of a given module or not.
|
static boolean |
isNoE(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(String value)
Verifies if a given value is a valid NMTOKEN value.
|
static void |
removeExtensions(Object object)
Removes extension attributes and elements from a given object.
|
static void |
removeModules(Object object,
String moduleSuffix)
Removes modules attributes and elements from a given object.
|
static boolean |
supports(String nsUri)
Indicates if a given module is directly supported by this version of the library.
|
static String |
toSafeXML(String text)
Converts a text to an XML-escaped text and using <cp> elements
for the characters that are invalid in XML.
|
static String |
toXML(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 String |
validateLang(String lang)
Verifies the syntax of a language code.
|
static void |
verifyReordering(List<CTag> original,
List<CTag> toVerify,
boolean errorOnMissingFirstNo)
Verifies if the sequences of codes that cannot be re-ordered have been preserved.
|
public static boolean isNoE(String string)
string - the string to check.public static String toXML(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 String toSafeXML(String text)
text - the text to convert.public static int compareAllowingNull(String s1, String s2)
s1 - the first string.s2 - the second string.public static boolean equals(Object o1, Object o2)
o1 - the first object (can be null).o2 - the second object (can be null).public static boolean checkValueList(String allowedValues, String value, 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 List<String> createFixedSequences(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(List<CTag> original, 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(String value)
value - the value to check.public static void removeExtensions(Object object)
object - the object from where the extension must be removed.public static void removeModules(Object object, 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(String nsUri, 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 String validateLang(String lang)
lang - the language code to verify.public static boolean supports(String nsUri)
nsUri - the namespace URI of the module to query.Copyright © 2020. All rights reserved.