Java Utililty Methods XML Data Type Converter

List of utility methods to do XML Data Type Converter

Description

The list of methods to do XML Data Type Converter are organized into topic(s).

Method

ListgetTextAsJavaByteArrayInitializer(String text, String charsetName, int maxArraySize)
get Text As Java Byte Array Initializer
byte[] bytes = text.getBytes(charsetName);
List<String> arrays = new ArrayList<>();
for (int length = 0; length < bytes.length;) {
    StringBuilder sb = new StringBuilder();
    sb.append("new byte[] { ");
    for (int chunk = 0; length < bytes.length && chunk < maxArraySize; chunk++) {
        byte b = bytes[length];
        if (chunk != 0) {
...
StringgetXMLLong(final long value)
Converts Long into XML-Tag with type xsd:long
return DatatypeConverter.printLong(value);
booleanisValidValue(String value, Class type)
Given a string value and a Java type, returns true if the given value is a legal assignment to an Attribute having the given Java type.
if (null == value || value.length() == 0)
    return true; 
if (String.class == type) {
    return true; 
} else if (Integer.class == type) {
    try {
        DatatypeConverter.parseInteger(value);
        return true;
...
Stringmillis2String(long millis)
millis String
int fixMillis = 0;
String xmlDateTime;
if (millis % 1000 == 0)
    fixMillis = 1;
synchronized (cal) {
    cal.setTimeInMillis(millis + fixMillis);
    xmlDateTime = javax.xml.bind.DatatypeConverter.printDateTime(cal);
if (fixMillis == 1)
    xmlDateTime = xmlDateTime.replace(".001Z", ".000Z");
return xmlDateTime;
voidmixColumns(byte[] input, boolean inv)
mix Columns
byte[] mixed = new byte[16];
byte[] matrix;
if (inv) {
    matrix = galois_matrix_inv;
} else {
    matrix = galois_matrix;
for (int i = 0; i < 16; i++) {
...
voidprintBytes(byte[] data)
print Bytes
byte[] datum = new byte[1];
for (int i = 0; i < data.length; i++) {
    datum[0] = data[i];
    System.out.println(i + " : " + DatatypeConverter.printHexBinary(datum));
StringprintDecimal(BigDecimal value, BigDecimal min, BigDecimal max, int precision, boolean zeroIncluded)
Write a BigDecimal value into XML output.
if (value == null) {
    throw new IllegalArgumentException("The provided double value NULL is invalid!");
value = value.setScale(precision, BigDecimal.ROUND_HALF_UP);
if (min != null && value.compareTo(min) <= 0) {
    if (!zeroIncluded || !BigDecimal.ZERO.equals(value)) {
        throw new IllegalArgumentException(
                "The provided double value " + value + " is too small (minimum is " + min + ")!");
...
StringprintIntToInteger(int value)
print Int To Integer
BigInteger result = BigInteger.valueOf(value);
return DatatypeConverter.printInteger(result);
StringprintLongitude(BigDecimal value)
print Longitude
if (value == null || !isValidLongitude(value))
    throw new IllegalArgumentException("Can't print longitude value!");
else
    return DatatypeConverter.printDecimal(value);
StringprintPositiveDecimal(BigDecimal value)
print Positive Decimal
if (value == null || value.compareTo(BigDecimal.ZERO) < 0)
    throw new IllegalArgumentException("Can't print positive decimal value!");
return printDecimal(value.setScale(2, BigDecimal.ROUND_HALF_UP));