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

StringprintPriceType(Long value)
print Price Type
return (value != null) ? DatatypeConverter.printLong(value) : "x";
StringprintZahl20(BigInteger value)
print Zahl
if (value == null || value.compareTo(BigInteger.ZERO) != 1)
    throw new IllegalArgumentException("Can't print integer value '" + value + "'!");
String val = DatatypeConverter.printInteger(value);
if (val.length() > 20)
    throw new IllegalArgumentException(
            "Can't print integer value '" + value + "'! The value exceeds maximal length of 20 digits.");
return val;
StringprintZahl31(BigDecimal value)
print Zahl
if (value == null || value.compareTo(BigDecimal.ZERO) != 1 || value.compareTo(BigDecimal.TEN.pow(2)) != -1)
    throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
else
    return DatatypeConverter.printDecimal(value.setScale(1, BigDecimal.ROUND_HALF_UP));
StringprintZimmeranzahl(BigDecimal value)
print Zimmeranzahl
BigDecimal min = new BigDecimal("0.5");
BigDecimal max = new BigDecimal("9999");
if (value == null || value.compareTo(min) == -1 || value.compareTo(max) == 1)
    throw new IllegalArgumentException("Can't print decimal value '" + value + "'!");
else
    return printZahl62(value);
PublicKeyreadKey(Reader reader, String algorithm)
Load PEM string from the reader and extract the public key.
@SuppressWarnings("resource")
Scanner scanner = new Scanner(reader);
scanner.useDelimiter("\n");
StringBuilder builder = new StringBuilder();
boolean prefixFound = false;
String line;
while (scanner.hasNext()) {
    line = scanner.next();
...
StringsendJson(URL url, String method, String data, String user, String password)
send Json
final StringBuffer buffer = new StringBuffer();
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
String userpass = user + ":" + password;
String basicAuth = "Basic " + javax.xml.bind.DatatypeConverter.printBase64Binary(userpass.getBytes());
connection.setRequestProperty("Authorization", basicAuth);
connection.setRequestMethod(method);
if (data != null) {
    connection.setDoInput(true);
...
StringserializeLogic(Serializable logic)
serialize Logic
try {
    ByteArrayOutputStream bao = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(bao);
    oos.writeObject(logic);
    oos.flush();
    return DatatypeConverter.printBase64Binary(bao.toByteArray());
} catch (IOException e) {
    throw new RuntimeException(e);
...
StringserializeToString(Object object)
serialize To String
byte[] bytes = serializeToBytes(object);
return DatatypeConverter.printBase64Binary(bytes);
StringserializeURLSafe(String string)
Serialize the given string to the short possible unique URL-safe representation.
if (string == null) {
    return null;
try {
    InputStream raw = new ByteArrayInputStream(string.getBytes("UTF-8"));
    ByteArrayOutputStream deflated = new ByteArrayOutputStream();
    stream(raw, new DeflaterOutputStream(deflated, new Deflater(Deflater.BEST_COMPRESSION)));
    String base64 = DatatypeConverter.printBase64Binary(deflated.toByteArray());
...
CalendarstringToCalendar(String value)
string To Calendar
return DatatypeConverter.parseDateTime(value);