Package java.beans

Examples of java.beans.XMLEncoder$Record


  /**
   * Serialize a single Task.
   */
  public static void serializeTasks(Task<? extends Serializable> t, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    // workaround for java 1.5
    e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
    e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
    e.setPersistenceDelegate(Operator.ProgressCounter.class, new EnumDelegate());

    e.writeObject(t);
    e.close();
  }
View Full Code Here


  /**
   * Serialize the whole query plan.
   */
  public static void serializeQueryPlan(QueryPlan plan, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    e.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception e) {
        LOG.warn(org.apache.hadoop.util.StringUtils.stringifyException(e));
        throw new RuntimeException("Cannot serialize the query plan", e);
      }
    });
    // workaround for java 1.5
    e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
    e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
    e.setPersistenceDelegate(Operator.ProgressCounter.class, new EnumDelegate());

    e.setPersistenceDelegate(org.datanucleus.sco.backed.Map.class, new MapDelegate());
    e.setPersistenceDelegate(org.datanucleus.sco.backed.List.class, new ListDelegate());

    e.writeObject(plan);
    e.close();
  }
View Full Code Here

  /**
   * Serialize the mapredWork object to an output stream. DO NOT use this to write to standard
   * output since it closes the output stream. DO USE mapredWork.toXML() instead.
   */
  public static void serializeMapRedWork(MapredWork w, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    // workaround for java 1.5
    e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
    e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
    e.writeObject(w);
    e.close();
  }
View Full Code Here

  /**
   * Serialize the mapredLocalWork object to an output stream. DO NOT use this to write to standard
   * output since it closes the output stream. DO USE mapredWork.toXML() instead.
   */
  public static void serializeMapRedLocalWork(MapredLocalWork w, OutputStream out) {
    XMLEncoder e = new XMLEncoder(out);
    // workaround for java 1.5
    e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
    e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
    e.writeObject(w);
    e.close();
  }
View Full Code Here

*/
@SuppressWarnings("CallToPrintStackTrace")
class TreeXmlSerializer {

  public static void write(final DefaultTreeModel model, final String filename) {
    XMLEncoder encoder = null;
    FileOutputStream fileOutputStream = null;
    BufferedOutputStream stream = null;

    try {
      fileOutputStream = new FileOutputStream(filename);
      stream = new BufferedOutputStream(fileOutputStream);
      encoder = new XMLEncoder(stream);
      encoder.writeObject(model);
    } catch (final FileNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        if (fileOutputStream != null) {
          fileOutputStream.close();
        }
        if (stream != null) {
          stream.close();
        }
      } catch (final IOException e) {
        e.printStackTrace();
      }
      if (encoder != null) {
        encoder.close();
      }
    }
  }
View Full Code Here

    CRError e = new CRError(ex);
    if (!isDebug) {
      e.setStringStackTrace(null);
    }

    XMLEncoder enc = new XMLEncoder(new BufferedOutputStream(stream));

    enc.writeObject(e);

    enc.close();

  }
View Full Code Here

    if (this.resolvableColl.isEmpty()) {
      //No Data Found
      throw new CRException("NoDataFound", "Data could not be found.", CRException.ERRORTYPE.NO_DATA_FOUND);
    } else {
      //Elements found/status ok
      XMLEncoder e = new XMLEncoder(new BufferedOutputStream(stream));
      String[] options = this.getOptionsArray();
      if (options != null) {
        ArrayList<String> optArr = new ArrayList<String>(Arrays.asList(options));

        if (optArr.contains("nobytearray")) {
          this.preprocessingNoByteArray(this.resolvableColl);
        }
      }

      e.writeObject(this.resolvableColl);
      e.close();
    }

  }
View Full Code Here

    /**
     * Regression test for HARMONY-1890
     */
    public void testDecodeEmptyStringArray1890() {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLEncoder encoder = new XMLEncoder(out);
        XMLDecoder decoder;
        Object obj;

        encoder.writeObject(new String[10]);
        encoder.close();

        decoder = new XMLDecoder(new ByteArrayInputStream(out.toByteArray()));
        obj = decoder.readObject();
        decoder.close();
       
View Full Code Here

            // Expected
        }
    }

    public void testWriteExpression_Scenario2() {
        XMLEncoder xmlEncoder = new XMLEncoder(new ByteArrayOutputStream());
        try {
            xmlEncoder.writeExpression((Expression) null);
            fail("should throw NullPointerException");
        } catch (NullPointerException e) {
            // Expected
        }
    }
View Full Code Here

    public void testWriteStatement() {
        // covered by testWriteStatement

         //Regression for HARMONY-1521
         //no exception expected
         new XMLEncoder(new ByteArrayOutputStream()).writeStatement(null);
    }
View Full Code Here

TOP

Related Classes of java.beans.XMLEncoder$Record

Copyright © 2018 www.massapicom. 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.