home *** CD-ROM | disk | FTP | other *** search
- package java.beans;
-
- import com.sun.beans.ObjectHandler;
- import java.io.IOException;
- import java.io.InputStream;
- import java.lang.ref.Reference;
- import java.lang.ref.WeakReference;
- import javax.xml.parsers.ParserConfigurationException;
- import javax.xml.parsers.SAXParser;
- import javax.xml.parsers.SAXParserFactory;
- import org.xml.sax.SAXException;
-
- public class XMLDecoder {
- // $FF: renamed from: in java.io.InputStream
- private InputStream field_0;
- private Object owner;
- private ExceptionListener exceptionListener;
- private ObjectHandler handler;
- private Reference clref;
-
- public XMLDecoder(InputStream var1) {
- this(var1, (Object)null);
- }
-
- public XMLDecoder(InputStream var1, Object var2) {
- this(var1, var2, (ExceptionListener)null);
- }
-
- public XMLDecoder(InputStream var1, Object var2, ExceptionListener var3) {
- this(var1, var2, var3, (ClassLoader)null);
- }
-
- public XMLDecoder(InputStream var1, Object var2, ExceptionListener var3, ClassLoader var4) {
- this.field_0 = var1;
- this.setOwner(var2);
- this.setExceptionListener(var3);
- this.setClassLoader(var4);
- }
-
- private void setClassLoader(ClassLoader var1) {
- if (var1 != null) {
- this.clref = new WeakReference(var1);
- }
-
- }
-
- private ClassLoader getClassLoader() {
- return this.clref != null ? (ClassLoader)this.clref.get() : null;
- }
-
- public void close() {
- if (this.field_0 != null) {
- this.getHandler();
-
- try {
- this.field_0.close();
- } catch (IOException var2) {
- this.getExceptionListener().exceptionThrown(var2);
- }
- }
-
- }
-
- public void setExceptionListener(ExceptionListener var1) {
- this.exceptionListener = var1;
- }
-
- public ExceptionListener getExceptionListener() {
- return this.exceptionListener != null ? this.exceptionListener : Statement.defaultExceptionListener;
- }
-
- public Object readObject() {
- return this.field_0 == null ? null : this.getHandler().dequeueResult();
- }
-
- public void setOwner(Object var1) {
- this.owner = var1;
- }
-
- public Object getOwner() {
- return this.owner;
- }
-
- private ObjectHandler getHandler() {
- if (this.handler == null) {
- SAXParserFactory var1 = SAXParserFactory.newInstance();
-
- try {
- SAXParser var2 = var1.newSAXParser();
- this.handler = new ObjectHandler(this, this.getClassLoader());
- var2.parse(this.field_0, this.handler);
- } catch (ParserConfigurationException var4) {
- this.getExceptionListener().exceptionThrown(var4);
- } catch (SAXException var5) {
- Object var3 = var5.getException();
- if (var3 == null) {
- var3 = var5;
- }
-
- this.getExceptionListener().exceptionThrown((Exception)var3);
- } catch (IOException var6) {
- this.getExceptionListener().exceptionThrown(var6);
- }
- }
-
- return this.handler;
- }
- }
-