use of java.beans.XMLDecoder in project hive by apache.
the class QueryConditionBuilder method createConditionString.
/*
* Walk to Hive AST and translate the hive column names to their equivalent mappings. This is basically a cheat.
*
*/
private String createConditionString(String filterXml, Map<String, String> columnMap) {
if ((filterXml == null) || (filterXml.trim().isEmpty())) {
return EMPTY_STRING;
}
try (XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(filterXml.getBytes("UTF-8")))) {
Object object = decoder.readObject();
if (!(object instanceof ExprNodeDesc)) {
LOGGER.error("Deserialized filter expression is not of the expected type");
throw new RuntimeException("Deserialized filter expression is not of the expected type");
}
ExprNodeDesc conditionNode = (ExprNodeDesc) object;
walkTreeAndTranslateColumnNames(conditionNode, columnMap);
return conditionNode.getExprString();
} catch (Exception e) {
LOGGER.error("Error during condition build", e);
return EMPTY_STRING;
}
}
use of java.beans.XMLDecoder in project jdk8u_jdk by JetBrains.
the class Test6338070 method main.
public static void main(String[] args) {
Test6338070 test = new Test6338070();
InputStream stream = new ByteArrayInputStream(DATA.getBytes());
new XMLDecoder(stream, test).close();
if (test.message == null) {
throw new Error("owner's method is not called");
}
}
use of java.beans.XMLDecoder in project jdk8u_jdk by JetBrains.
the class Test4625418 method test.
private void test(String string) {
try {
File file = new File("4625418." + this.encoding + ".xml");
FileOutputStream output = new FileOutputStream(file);
XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
encoder.setExceptionListener(this);
encoder.writeObject(string);
encoder.close();
FileInputStream input = new FileInputStream(file);
XMLDecoder decoder = new XMLDecoder(input);
decoder.setExceptionListener(this);
Object object = decoder.readObject();
decoder.close();
if (!string.equals(object))
throw new Error(this.encoding + " - can't read properly");
file.delete();
} catch (FileNotFoundException exception) {
throw new Error(this.encoding + " - file not found", exception);
} catch (IllegalCharsetNameException exception) {
throw new Error(this.encoding + " - illegal charset name", exception);
} catch (UnsupportedCharsetException exception) {
throw new Error(this.encoding + " - unsupported charset", exception);
} catch (UnsupportedOperationException exception) {
throw new Error(this.encoding + " - unsupported encoder", exception);
}
}
use of java.beans.XMLDecoder in project jdk8u_jdk by JetBrains.
the class Test6341798 method test.
private static void test(Locale locale, byte[] data) {
Locale.setDefault(locale);
System.out.println("locale = " + locale);
XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));
System.out.println("object = " + decoder.readObject());
decoder.close();
}
use of java.beans.XMLDecoder in project jdk8u_jdk by JetBrains.
the class AbstractTest method test.
/**
* This is entry point to start testing.
*
* @param security use {@code true} to start
* second pass in secure context
*/
final void test(boolean security) {
// NON-NLS: the field name
byte[] array = getFieldValue("XML").getBytes();
ByteArrayInputStream input = new ByteArrayInputStream(array);
XMLDecoder decoder = new XMLDecoder(input);
decoder.setExceptionListener(this);
validate(decoder);
try {
throw new Error("unexpected object" + decoder.readObject());
} catch (ArrayIndexOutOfBoundsException exception) {
// expected exception
}
decoder.close();
if (security) {
System.setSecurityManager(new SecurityManager());
test(false);
}
}
Aggregations