Examples of XMLDecoder


Examples of java.beans.XMLDecoder

      bytes = s.getBytes("UTF-8");
    } catch (UnsupportedEncodingException ex) {
      throw new RuntimeException("UTF-8 support required", ex);
    }
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    XMLDecoder decoder = new XMLDecoder(bais, null, null, conf.getClassLoader());
    try {
      ExprNodeDesc expr = (ExprNodeDesc) decoder.readObject();
      return expr;
    } finally {
      decoder.close();
    }
  }
View Full Code Here

Examples of java.beans.XMLDecoder

  /**
   * Deserialize the whole query plan.
   */
  public static QueryPlan deserializeQueryPlan(InputStream in, Configuration conf) {
    XMLDecoder d = new XMLDecoder(in, null, null, conf.getClassLoader());
    QueryPlan ret = (QueryPlan) d.readObject();
    d.close();
    return (ret);
  }
View Full Code Here

Examples of java.beans.XMLDecoder

    e.writeObject(w);
    e.close();
  }

  public static MapredWork deserializeMapRedWork(InputStream in, Configuration conf) {
    XMLDecoder d = new XMLDecoder(in, null, null, conf.getClassLoader());
    MapredWork ret = (MapredWork) d.readObject();
    d.close();
    return (ret);
  }
View Full Code Here

Examples of java.beans.XMLDecoder

  // -------------------------
  // loads JTree


  public static DefaultTreeModel read(final String filename) {
    XMLDecoder decoder = null;
    BufferedInputStream stream = null;
    try {
      final FileInputStream fis = new FileInputStream(filename);
      stream = new BufferedInputStream(fis);
      decoder = new XMLDecoder(stream);
    } catch (final FileNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        assert stream != null;
        stream.close();
      } catch (final IOException e) {
        e.printStackTrace();
      }
    }

    DefaultTreeModel model = null;
    try {
      model = (DefaultTreeModel) decoder.readObject();
    } catch (final Exception e) {
      e.printStackTrace();
    } finally {
      decoder.close();
    }

    return model;
  }
View Full Code Here

Examples of java.beans.XMLDecoder

   
    /*
     * test XMLDecoder constructor with null inputStream argument
     */
    public void test_Constructor_NullInputStream_scenario1() {
        XMLDecoder xmlDecoder = new XMLDecoder(null);
        assertNull(xmlDecoder.readObject());
        assertNull(xmlDecoder.getOwner());
        assertNotNull(xmlDecoder.getExceptionListener());
        xmlDecoder.close();
    }
View Full Code Here

Examples of java.beans.XMLDecoder

    /*
     * test XMLDecoder constructor with null inputStream argument
     */
    public void test_Constructor_NullInputStream_scenario2() {
        XMLDecoder xmlDecoder = new XMLDecoder(null, null);
        assertNull(xmlDecoder.readObject());
        assertNull(xmlDecoder.getOwner());
        assertNotNull(xmlDecoder.getExceptionListener());
        xmlDecoder.close();
    }
View Full Code Here

Examples of java.beans.XMLDecoder

    /*
     * test XMLDecoder constructor with null inputStream argument
     */
    public void test_Constructor_NullInputStream_scenario3() {
        XMLDecoder xmlDecoder = new XMLDecoder(null, null, null);
        assertNull(xmlDecoder.readObject());
        assertNull(xmlDecoder.getOwner());
        assertNotNull(xmlDecoder.getExceptionListener());
        xmlDecoder.close();
    }
View Full Code Here

Examples of java.beans.XMLDecoder

    /*
     * test XMLDecoder constructor with null inputStream argument
     */
    public void test_Constructor_NullInputStream_scenario4() {
        XMLDecoder xmlDecoder = new XMLDecoder(null, null, null, null);
        assertNull(xmlDecoder.readObject());
        assertNull(xmlDecoder.getOwner());
        assertNotNull(xmlDecoder.getExceptionListener());
        xmlDecoder.close();
    }
View Full Code Here

Examples of java.beans.XMLDecoder

   
    /*
     * test XMLDecoder constructor
     */
    public void test_Constructor_Normal() throws Exception {
        XMLDecoder xmlDecoder;
        xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
        assertEquals(null, xmlDecoder.getOwner());
       
        final Vector<Exception> exceptions = new Vector<Exception>();
        ExceptionListener el = new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                exceptions.addElement(e);
            }
        };
       
        xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el);
        assertEquals(el, xmlDecoder.getExceptionListener());
        assertEquals(this, xmlDecoder.getOwner());
    }
View Full Code Here

Examples of java.beans.XMLDecoder

        assertEquals(el, xmlDecoder.getExceptionListener());
        assertEquals(this, xmlDecoder.getOwner());
    }

    public void testConstructor_ClassLoader() {
        XMLDecoder dec;
        final Vector<Exception> exceptions = new Vector<Exception>();

        ExceptionListener el = new ExceptionListener() {
            public void exceptionThrown(Exception e) {
                exceptions.addElement(e);
            }
        };

        dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
                Thread.currentThread().getContextClassLoader());
        assertEquals(Integer.valueOf("1"), dec.readObject());
        assertEquals(0, exceptions.size());
        dec.close();

        dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el,
                new MockClassLoader());
        try {
            dec.readObject();
            assertTrue(exceptions.size() > 0);
        } catch (ArrayIndexOutOfBoundsException e) {
            // also valid
        }
        dec.close();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.