src/share/classes/java/beans/XMLDecoder.java

Print this page




  43  * <pre>
  44  *       XMLDecoder d = new XMLDecoder(
  45  *                          new BufferedInputStream(
  46  *                              new FileInputStream("Test.xml")));
  47  *       Object result = d.readObject();
  48  *       d.close();
  49  * </pre>
  50  *
  51  *<p>
  52  * For more information you might also want to check out
  53  * <a
  54  href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Long Term Persistence of JavaBeans Components: XML Schema</a>,
  55  * an article in <em>The Swing Connection.</em>
  56  * @see XMLEncoder
  57  * @see java.io.ObjectInputStream
  58  *
  59  * @since 1.4
  60  *
  61  * @author Philip Milne
  62  */
  63 public class XMLDecoder {
  64     private final DocumentHandler handler = new DocumentHandler();
  65     private final InputSource input;
  66     private Object owner;
  67     private Object[] array;
  68     private int index;
  69 
  70     /**
  71      * Creates a new input stream for reading archives
  72      * created by the <code>XMLEncoder</code> class.
  73      *
  74      * @param in The underlying stream.
  75      *
  76      * @see XMLEncoder#XMLEncoder(java.io.OutputStream)
  77      */
  78     public XMLDecoder(InputStream in) {
  79         this(in, null);
  80     }
  81 
  82     /**
  83      * Creates a new input stream for reading archives




  43  * <pre>
  44  *       XMLDecoder d = new XMLDecoder(
  45  *                          new BufferedInputStream(
  46  *                              new FileInputStream("Test.xml")));
  47  *       Object result = d.readObject();
  48  *       d.close();
  49  * </pre>
  50  *
  51  *<p>
  52  * For more information you might also want to check out
  53  * <a
  54  href="http://java.sun.com/products/jfc/tsc/articles/persistence3">Long Term Persistence of JavaBeans Components: XML Schema</a>,
  55  * an article in <em>The Swing Connection.</em>
  56  * @see XMLEncoder
  57  * @see java.io.ObjectInputStream
  58  *
  59  * @since 1.4
  60  *
  61  * @author Philip Milne
  62  */
  63 public class XMLDecoder implements AutoCloseable {
  64     private final DocumentHandler handler = new DocumentHandler();
  65     private final InputSource input;
  66     private Object owner;
  67     private Object[] array;
  68     private int index;
  69 
  70     /**
  71      * Creates a new input stream for reading archives
  72      * created by the <code>XMLEncoder</code> class.
  73      *
  74      * @param in The underlying stream.
  75      *
  76      * @see XMLEncoder#XMLEncoder(java.io.OutputStream)
  77      */
  78     public XMLDecoder(InputStream in) {
  79         this(in, null);
  80     }
  81 
  82     /**
  83      * Creates a new input stream for reading archives