Search in sources :

Example 1 with XMLDecoder

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;
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) XMLDecoder(java.beans.XMLDecoder) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc)

Example 2 with XMLDecoder

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");
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) XMLDecoder(java.beans.XMLDecoder)

Example 3 with XMLDecoder

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);
    }
}
Also used : IllegalCharsetNameException(java.nio.charset.IllegalCharsetNameException) XMLEncoder(java.beans.XMLEncoder) UnsupportedCharsetException(java.nio.charset.UnsupportedCharsetException) FileOutputStream(java.io.FileOutputStream) XMLDecoder(java.beans.XMLDecoder) FileNotFoundException(java.io.FileNotFoundException) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 4 with XMLDecoder

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();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) XMLDecoder(java.beans.XMLDecoder)

Example 5 with XMLDecoder

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);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) XMLDecoder(java.beans.XMLDecoder)

Aggregations

XMLDecoder (java.beans.XMLDecoder)54 ByteArrayInputStream (java.io.ByteArrayInputStream)28 IOException (java.io.IOException)19 BufferedInputStream (java.io.BufferedInputStream)18 XMLEncoder (java.beans.XMLEncoder)15 FileInputStream (java.io.FileInputStream)14 LinkedList (java.util.LinkedList)13 ExceptionListener (java.beans.ExceptionListener)12 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 File (java.io.File)8 FileOutputStream (java.io.FileOutputStream)5 InputStream (java.io.InputStream)5 AssertionFailedError (junit.framework.AssertionFailedError)5 Test (org.junit.Test)5 Test (org.junit.jupiter.api.Test)5 FileNotFoundException (java.io.FileNotFoundException)4 List (java.util.List)4 PatternSyntaxException (java.util.regex.PatternSyntaxException)4 BufferedOutputStream (java.io.BufferedOutputStream)3 Serializable (java.io.Serializable)2