Codota Logo
XMLEncoder.setExceptionListener
Code IndexAdd Codota to your IDE (free)

How to use
setExceptionListener
method
in
java.beans.XMLEncoder

Best Java code snippets using java.beans.XMLEncoder.setExceptionListener (Showing top 20 results out of 315)

  • Common ways to obtain XMLEncoder
private void myMethod () {
XMLEncoder x =
  • Codota IconOutputStream out;new XMLEncoder(out)
  • Codota IconFile file;new XMLEncoder(new BufferedOutputStream(new FileOutputStream(file)))
  • Codota IconOutputStream out;new XMLEncoder(new BufferedOutputStream(out))
  • Smart code suggestions by Codota
}
origin: oracle/opengrok

enc.setExceptionListener(listener);
Project p1 = new Project("foo");
enc.writeObject(p1);
origin: oracle/opengrok

enc.setExceptionListener(listener);
Group g1 = new Group();
enc.writeObject(g1);
origin: oracle/opengrok

e.setExceptionListener(listener);
e.writeObject(in);
e.close();
origin: com.miglayout/miglayout-core

/** Writes the object and CLOSES the stream. Uses the persistence delegate registered in this class.
 * @param os The stream to write to. Will be closed.
 * @param o The object to be serialized.
 * @param listener The listener to receive the exceptions if there are any. If <code>null</code> not used.
 */
static void writeXMLObject(OutputStream os, Object o, ExceptionListener listener)
{
  ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
  Thread.currentThread().setContextClassLoader(LayoutUtil.class.getClassLoader());
  XMLEncoder encoder = new XMLEncoder(os);
  if (listener != null)
    encoder.setExceptionListener(listener);
  encoder.writeObject(o);
  encoder.close();    // Must be closed to write.
  Thread.currentThread().setContextClassLoader(oldClassLoader);
}
origin: net.sourceforge.jadex/jadex-platform-base

  /**
   *  Encode data with the codec.
   *  @param val The value.
   *  @return The encoded object.
   */
  public synchronized byte[] encode(Object val, ClassLoader classloader, Map<Class<?>, Object[]> info)
  {
    ByteArrayOutputStream bs = new ByteArrayOutputStream();
    XMLEncoder e = new XMLEncoder(bs);
    e.setExceptionListener(new ExceptionListener()
    {
      public void exceptionThrown(Exception e)
      {
        System.out.println("XML encoding ERROR: ");
        e.printStackTrace();
      }
    });
    Thread.currentThread().setContextClassLoader(classloader);
//        System.err.println("encoding with class loader: "+Thread.currentThread()+", "+Thread.currentThread().getContextClassLoader());
    e.writeObject(val);
    e.close();
    return bs.toByteArray();
  }
 
origin: org.slf4j/slf4j-ext

/**
 * Serialize all the EventData items into an XML representation.
 * 
 * @param map the Map to transform
 * @return an XML String containing all the EventData items.
 */
public static String toXML(Map<String, Object> map) {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  try {
    XMLEncoder encoder = new XMLEncoder(baos);
    encoder.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception exception) {
        exception.printStackTrace();
      }
    });
    encoder.writeObject(map);
    encoder.close();
    return baos.toString();
  } catch (Exception e) {
    e.printStackTrace();
    return null;
  }
}
origin: net.sourceforge.jadex/jadex-platform-base

  /**
   *  Encode an object.
   *  @param obj The object.
   *  @throws IOException
   */
//    public byte[] encode(Object val, ClassLoader classloader)
  public Object encode(Object val, ClassLoader classloader)
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    XMLEncoder enc = new XMLEncoder(baos);
    enc.setExceptionListener(new ExceptionListener()
    {
      public void exceptionThrown(Exception e)
      {
        System.out.println("XML encoding ERROR: ");
        e.printStackTrace();
      }
    });
    enc.writeObject(val);
    enc.close();
    try{baos.close();} catch(Exception e) {}
    return baos.toByteArray();
  }
 
origin: violetumleditor/violetumleditor

/**
 * Creates a new instance of XML Encoder pre-configured for Violet beans serailization
 * 
 * @param out
 * @return configured encoder
 */
private XMLEncoder getXMLEncoder(OutputStream out)
{
  XMLEncoder encoder = new XMLEncoder(out);

  encoder.setExceptionListener(new ExceptionListener()
  {
    public void exceptionThrown(Exception ex)
    {
      ex.printStackTrace();
    }
  });
  configure(encoder);
  return encoder;
}
origin: be.yildiz-games/common-file-xml

/**
 * Write an object into a XML file.
 *
 * @param o Object to persist.
 */
@Override
public void writeToFile(final T o) {
  try (OutputStream fos = Files.newOutputStream(this.file)) {
    try (XMLEncoder encoder = new XMLEncoder(fos)) {
      encoder.setExceptionListener(FileCreationException::new);
      encoder.writeObject(o);
    }
  } catch (IOException e) {
    throw new FileCreationException(e);
  }
}
origin: Unidata/thredds

beanEncoder.setExceptionListener(new ExceptionListener() {
 public void exceptionThrown(Exception exception) {
  System.out.println("XMLStore.save() got Exception: abort saving the preferences!");
origin: edu.ucar/netcdf

beanEncoder.setExceptionListener(new ExceptionListener() {
 public void exceptionThrown(Exception exception) {
  System.out.println("XMLStore.save() got Exception: abort saving the preferences!");
origin: com.jalalkiswani/jk-util

/**
 * To xml.
 *
 * @param obj
 *            the obj
 * @return the string
 */
// ////////////////////////////////////////////////////////////////////
public static String toXml(final Object obj) {
  final ByteArrayOutputStream out = new ByteArrayOutputStream();
  // XStream x = createXStream();
  // String xml = x.toXML(obj);
  // return xml;
  final XMLEncoder e = new XMLEncoder(out);
  e.setExceptionListener(new XmlEncoderExceptionListener());
  // e.setPersistenceDelegate(Object.class, new MyPersistenceDelegate());
  e.writeObject(obj);
  e.close();
  return out.toString();
  // return null;
}
origin: org.nuiton/nuiton-widgets

  e = new XMLEncoder(bst);
  e.setPersistenceDelegate(Rectangle.class, new RectanglePD());
  e.setExceptionListener(el);
  e.writeObject(states);
} finally {
origin: net.sf.jstuff/jstuff-core

/**
* @see XMLEncoder
*/
@SuppressWarnings("resource")
public static String bean2xml(final Object javaBean) throws SerializationException {
 Args.notNull("javaBean", javaBean);
 final ArrayList<Exception> exList = new ArrayList<Exception>(2);
 final FastByteArrayOutputStream bos = new FastByteArrayOutputStream();
 final XMLEncoder encoder = new XMLEncoder(bos);
 encoder.setExceptionListener(new ExceptionListener() {
   public void exceptionThrown(final Exception ex) {
    exList.add(ex);
   }
 });
 encoder.writeObject(javaBean);
 encoder.close();
 if (exList.size() > 0)
   throw new SerializationException("An error occured during XML serialization", exList.get(0));
 return bos.toString();
}
origin: com.facebook.presto.hive/hive-apache

public static void serialize(OutputStream out, Object o)
{
 XMLEncoder e = new XMLEncoder(out);
 e.setExceptionListener(new EL());
 PTFUtils.addPersistenceDelegates(e);
 e.writeObject(o);
 e.close();
}
origin: net.java.dev.appframework/appframework

    persistenceDelegatesInitialized = true;
e.setExceptionListener(el);
e.writeObject(bean);
origin: jboss-switchyard/core

/**
 * {@inheritDoc}
 */
@Override
public <T> int serialize(T obj, Class<T> type, OutputStream out) throws IOException {
  out = new CountingOutputStream(new BufferedOutputStream(out, getBufferSize()));
  EL el = new EL();
  XMLEncoder enc = new XMLEncoder(out);
  try {
    enc.setExceptionListener(el);
    enc.writeObject(obj);
    enc.flush();
  } finally {
    if (isCloseEnabled()) {
      enc.close();
    }
  }
  IOException ioe = el.getIOException();
  if (ioe != null) {
    throw ioe;
  }
  return ((CountingOutputStream)out).getCount();
}
origin: de.schlichtherle.truezip/truezip-file

enc.setExceptionListener(listener);
enc.writeObject(original);
enc.close();
origin: org.apache.hadoop.hive/hive-exec

/**
 * 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();
}
origin: com.facebook.presto.hive/hive-apache

/**
 * Serialize the object. This helper function mainly makes sure that enums,
 * counters, etc are handled properly.
 */
private static void serializeObjectByJavaXML(Object plan, OutputStream out) {
 XMLEncoder e = new XMLEncoder(out);
 e.setExceptionListener(new ExceptionListener() {
  @Override
  public void exceptionThrown(Exception e) {
   LOG.warn(org.apache.hadoop.util.StringUtils.stringifyException(e));
   throw new RuntimeException("Cannot serialize object", e);
  }
 });
 // workaround for java 1.5
 e.setPersistenceDelegate(ExpressionTypes.class, new EnumDelegate());
 e.setPersistenceDelegate(GroupByDesc.Mode.class, new EnumDelegate());
 e.setPersistenceDelegate(java.sql.Date.class, new DatePersistenceDelegate());
 e.setPersistenceDelegate(Timestamp.class, new TimestampPersistenceDelegate());
 e.setPersistenceDelegate(org.datanucleus.store.types.backed.Map.class, new MapDelegate());
 e.setPersistenceDelegate(org.datanucleus.store.types.backed.List.class, new ListDelegate());
 e.setPersistenceDelegate(CommonToken.class, new CommonTokenDelegate());
 e.setPersistenceDelegate(Path.class, new PathDelegate());
 e.writeObject(plan);
 e.close();
}
java.beansXMLEncodersetExceptionListener

Popular methods of XMLEncoder

  • <init>
  • writeObject
  • close
  • flush
  • setPersistenceDelegate
  • getOwner
  • setOwner
  • getPersistenceDelegate

Popular in Java

  • Reactive rest calls using spring rest template
  • getSystemService (Context)
  • onRequestPermissionsResult (Fragment)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Proxy (java.net)
    This class represents proxy server settings. A created instance of Proxy stores a type and an addres
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Timer (java.util)
    A facility for threads to schedule tasks for future execution in a background thread. Tasks may be s
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now