IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
 
[Sommaire]  [Top 50]  [F.A.Q.]  [ Java SE ]  [ Java EE ]  [Javadoc standard]  [Contact]
[ 1.4.2 ]  [ 5.0 ]  [ 6.0
Rechercher   
Dans
Options   sensible à la casse
étendre la recherche aux descriptions
Préférences
fr en 
 
Moteurs de recherche
JavaTM 2 Platform Std. Ed. v1.4.2

java.beans
Class XMLDecoder

java.lang.Object
  extended byjava.beans.XMLDecoder

public class XMLDecoder
extends Object

The XMLDecoder class is used to read XML documents created using the XMLEncoder and is used just like the ObjectInputStream. For example, one can use the following fragment to read the first object defined in an XML document written by the XMLEncoder class:

       XMLDecoder d = new XMLDecoder(
                          new BufferedInputStream(
                              new FileInputStream("Test.xml")));
       Object result = d.readObject();
       d.close();
 

Since:
1.4
See Also:
XMLEncoder, ObjectInputStream

Constructor Summary
XMLDecoder(InputStream in)
          Creates a new input stream for reading archives created by the XMLEncoder class.
XMLDecoder(InputStream in, Object owner)
          Creates a new input stream for reading archives created by the XMLEncoder class.
XMLDecoder(InputStream in, Object owner, ExceptionListener exceptionListener)
          Creates a new input stream for reading archives created by the XMLEncoder class.
 
Method Summary
 void close()
          This method closes the input stream associated with this stream.
 ExceptionListener getExceptionListener()
          Gets the exception handler for this stream.
 Object getOwner()
          Gets the owner of this decoder.
 Object readObject()
          Reads the next object from the underlying input stream.
 void setExceptionListener(ExceptionListener exceptionListener)
          Sets the exception handler for this stream to exceptionListener.
 void setOwner(Object owner)
          Sets the owner of this decoder to owner.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLDecoder

public XMLDecoder(InputStream in)
Creates a new input stream for reading archives created by the XMLEncoder class.

Parameters:
in - The underlying stream.
See Also:
XMLEncoder.XMLEncoder(OutputStream)

XMLDecoder

public XMLDecoder(InputStream in,
                  Object owner)
Creates a new input stream for reading archives created by the XMLEncoder class.

Parameters:
in - The underlying stream.
owner - The owner of this stream.

XMLDecoder

public XMLDecoder(InputStream in,
                  Object owner,
                  ExceptionListener exceptionListener)
Creates a new input stream for reading archives created by the XMLEncoder class.

Parameters:
in - the underlying stream.
owner - the owner of this stream.
Method Detail

close

public void close()
This method closes the input stream associated with this stream.


setExceptionListener

public void setExceptionListener(ExceptionListener exceptionListener)
Sets the exception handler for this stream to exceptionListener. The exception handler is notified when this stream catches recoverable exceptions.

Parameters:
exceptionListener - The exception handler for this stream.
See Also:
getExceptionListener()

getExceptionListener

public ExceptionListener getExceptionListener()
Gets the exception handler for this stream.

Returns:
The exception handler for this stream.
See Also:
setExceptionListener(java.beans.ExceptionListener)

readObject

public Object readObject()
Reads the next object from the underlying input stream.

Returns:
the next object read
Throws:
ArrayIndexOutOfBoundsException - if the stream contains no objects (or no more objects)
See Also:
XMLEncoder.writeObject(java.lang.Object)

setOwner

public void setOwner(Object owner)
Sets the owner of this decoder to owner.

Parameters:
owner - The owner of this decoder.
See Also:
getOwner()

getOwner

public Object getOwner()
Gets the owner of this decoder.

Returns:
The owner of this decoder.
See Also:
setOwner(java.lang.Object)

Copyright 2003 Sun Microsystems, Inc. All rights reserved