jdom-1.0

16:37:24.913 INFO  jd.cli.Main - Decompiling jdom-1.0.jar
class JDOMAbout$Author
{
  private final JDOMAbout this$0;
  String name;
  String email;
  
  JDOMAbout$Author(JDOMAbout this$0)
  {
    this.this$0 = 
    
      this$0;
  }
}

/* Location:
 * Qualified Name:     JDOMAbout.Author
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

class JDOMAbout$Info
{
  private final JDOMAbout this$0;
  String title;
  String version;
  String copyright;
  String description;
  List authors;
  String license;
  String support;
  String website;
  
  JDOMAbout$Info(JDOMAbout this$0)
    throws Exception
  {
    this.this$0 = 
    
      this$0;
    String INFO_FILENAME = "META-INF/info.xml";
    
    SAXBuilder builder = new SAXBuilder();
    
    JarFile jarFile = null;
    ZipEntry zipEntry = null;
    
    String classpath = System.getProperty("java.class.path");
    StringTokenizer tokenizer = new StringTokenizer(classpath, ";:");
    while ((tokenizer.hasMoreTokens()) && (zipEntry == null))
    {
      String token = tokenizer.nextToken();
      try
      {
        jarFile = new JarFile(token);
        
        zipEntry = jarFile.getEntry("META-INF/info.xml");
      }
      catch (Exception localException) {}
    }
    if (zipEntry == null) {
      throw new FileNotFoundException("META-INF/info.xml not found; it should be within the JDOM JAR but isn't");
    }
    InputStream in = jarFile.getInputStream(zipEntry);
    
    Document doc = builder.build(in);
    Element root = doc.getRootElement();
    
    title = root.getChildTextTrim("title");
    version = root.getChildTextTrim("version");
    copyright = root.getChildTextTrim("copyright");
    description = root.getChildTextTrim("description");
    license = root.getChildTextTrim("license");
    support = root.getChildTextTrim("support");
    website = root.getChildTextTrim("web-site");
    
    List authorElements = root.getChildren("author");
    authors = new LinkedList();
    Iterator it = authorElements.iterator();
    while (it.hasNext())
    {
      Element element = (Element)it.next(); JDOMAbout 
      
        tmp261_260 = this$0;tmp261_260.getClass();JDOMAbout.Author author = new JDOMAbout.Author(tmp261_260);
      name = element.getChildTextTrim("name");
      email = element.getChildTextTrim("e-mail");
      
      authors.add(author);
    }
  }
}

/* Location:
 * Qualified Name:     JDOMAbout.Info
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

public class JDOMAbout
{
  public static void main(String[] args)
    throws Exception
  {
    void tmp11_8 = new JDOMAbout();tmp11_8.getClass();JDOMAbout.Info info = new JDOMAbout.Info(tmp11_8);
    
    String title = title;
    
    System.out.println(title + " version " + version);
    System.out.println("Copyright " + copyright);
    System.out.println();
    
    System.out.println(description);
    System.out.println();
    
    System.out.println("Authors:");
    Iterator it = authors.iterator();
    while (it.hasNext())
    {
      JDOMAbout.Author author = (JDOMAbout.Author)it.next();
      
      System.out.print("  " + name);
      if (email == null) {
        System.out.println();
      } else {
        System.out.println(" <" + email + ">");
      }
    }
    System.out.println();
    
    System.out.println(title + " license:");
    System.out.println(license);
    System.out.println();
    
    System.out.println(title + " support:");
    System.out.println(support);
    System.out.println();
    
    System.out.println(title + " web site: " + website);
    System.out.println();
  }
  
  private class Info
  {
    String title;
    String version;
    String copyright;
    String description;
    List authors;
    String license;
    String support;
    String website;
    
    Info()
      throws Exception
    {
      String INFO_FILENAME = "META-INF/info.xml";
      
      SAXBuilder builder = new SAXBuilder();
      
      JarFile jarFile = null;
      ZipEntry zipEntry = null;
      
      String classpath = System.getProperty("java.class.path");
      StringTokenizer tokenizer = new StringTokenizer(classpath, ";:");
      while ((tokenizer.hasMoreTokens()) && (zipEntry == null))
      {
        String token = tokenizer.nextToken();
        try
        {
          jarFile = new JarFile(token);
          
          zipEntry = jarFile.getEntry("META-INF/info.xml");
        }
        catch (Exception localException) {}
      }
      if (zipEntry == null) {
        throw new FileNotFoundException("META-INF/info.xml not found; it should be within the JDOM JAR but isn't");
      }
      InputStream in = jarFile.getInputStream(zipEntry);
      
      Document doc = builder.build(in);
      Element root = doc.getRootElement();
      
      title = root.getChildTextTrim("title");
      version = root.getChildTextTrim("version");
      copyright = root.getChildTextTrim("copyright");
      description = root.getChildTextTrim("description");
      license = root.getChildTextTrim("license");
      support = root.getChildTextTrim("support");
      website = root.getChildTextTrim("web-site");
      
      List authorElements = root.getChildren("author");
      authors = new LinkedList();
      Iterator it = authorElements.iterator();
      while (it.hasNext())
      {
        Element element = (Element)it.next(); JDOMAbout 
        
          tmp261_260 = JDOMAbout.this;tmp261_260.getClass();JDOMAbout.Author author = new JDOMAbout.Author(tmp261_260);
        name = element.getChildTextTrim("name");
        email = element.getChildTextTrim("e-mail");
        
        authors.add(author);
      }
    }
  }
  
  private class Author
  {
    String name;
    String email;
    
    Author() {}
  }
}

/* Location:
 * Qualified Name:     JDOMAbout
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
import org.jdom.DocType;
import org.jdom.JDOMException;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;

public abstract class AbstractDOMAdapter
  implements DOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: AbstractDOMAdapter.java,v $ $Revision: 1.20 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(File filename, boolean validate)
    throws IOException, JDOMException
  {
    return getDocument(new FileInputStream(filename), validate);
  }
  
  public Document createDocument(DocType doctype)
    throws JDOMException
  {
    if (doctype == null) {
      return createDocument();
    }
    DOMImplementation domImpl = createDocument().getImplementation();
    DocumentType domDocType = domImpl.createDocumentType(
      doctype.getElementName(), 
      doctype.getPublicID(), 
      doctype.getSystemID());
    
    setInternalSubset(domDocType, doctype.getInternalSubset());
    
    return domImpl.createDocument("http://temporary", 
      doctype.getElementName(), 
      domDocType);
  }
  
  protected void setInternalSubset(DocumentType dt, String s)
  {
    if ((dt == null) || (s == null)) {
      return;
    }
    try
    {
      Class dtclass = dt.getClass();
      Method setInternalSubset = dtclass.getMethod(
        "setInternalSubset", new Class[] { String.class });
      setInternalSubset.invoke(dt, new Object[] { s });
    }
    catch (Exception localException) {}
  }
  
  public abstract Document createDocument()
    throws JDOMException;
  
  public abstract Document getDocument(InputStream paramInputStream, boolean paramBoolean)
    throws IOException, JDOMException;
}

/* Location:
 * Qualified Name:     org.jdom.adapters.AbstractDOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class CrimsonDOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: CrimsonDOMAdapter.java,v $ $Revision: 1.16 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class[] parameterTypes = new Class[2];
      parameterTypes[0] = Class.forName("java.io.InputStream");
      parameterTypes[1] = Boolean.TYPE;
      
      Object[] args = new Object[2];
      args[0] = in;
      args[1] = new Boolean(false);
      
      Class parserClass = Class.forName("org.apache.crimson.tree.XmlDocument");
      Method createXmlDocument = 
        parserClass.getMethod("createXmlDocument", parameterTypes);
      return 
        (Document)createXmlDocument.invoke(null, args);
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof SAXParseException))
      {
        SAXParseException parseException = (SAXParseException)targetException;
        throw new JDOMException("Error on line " + parseException.getLineNumber() + 
          " of XML document: " + parseException.getMessage(), parseException);
      }
      if ((targetException instanceof IOException))
      {
        IOException ioException = (IOException)targetException;
        throw ioException;
      }
      throw new JDOMException(targetException.getMessage(), targetException);
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage(), e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      return 
        (Document)Class.forName(
        "org.apache.crimson.tree.XmlDocument")
        .newInstance();
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage() + " when creating document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.CrimsonDOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import org.jdom.DocType;
import org.jdom.JDOMException;
import org.w3c.dom.Document;

public abstract interface DOMAdapter
{
  public abstract Document createDocument()
    throws JDOMException;
  
  public abstract Document createDocument(DocType paramDocType)
    throws JDOMException;
  
  public abstract Document getDocument(File paramFile, boolean paramBoolean)
    throws IOException, JDOMException;
  
  public abstract Document getDocument(InputStream paramInputStream, boolean paramBoolean)
    throws IOException, JDOMException;
}

/* Location:
 * Qualified Name:     org.jdom.adapters.DOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.jdom.input.BuilderErrorHandler;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;

public class JAXPDOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: JAXPDOMAdapter.java,v $ $Revision: 1.12 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class.forName("javax.xml.transform.Transformer");
      
      Class factoryClass = 
        Class.forName("javax.xml.parsers.DocumentBuilderFactory");
      
      Method newParserInstance = 
        factoryClass.getMethod("newInstance", null);
      Object factory = newParserInstance.invoke(null, null);
      
      Method setValidating = 
        factoryClass.getMethod("setValidating", 
        new Class[] { Boolean.TYPE });
      setValidating.invoke(factory, 
        new Object[] { new Boolean(validate) });
      
      Method setNamespaceAware = 
        factoryClass.getMethod("setNamespaceAware", 
        new Class[] { Boolean.TYPE });
      setNamespaceAware.invoke(factory, 
        new Object[] { Boolean.TRUE });
      
      Method newDocBuilder = 
        factoryClass.getMethod("newDocumentBuilder", null);
      Object jaxpParser = newDocBuilder.invoke(factory, null);
      
      Class parserClass = jaxpParser.getClass();
      Method setErrorHandler = 
        parserClass.getMethod("setErrorHandler", 
        new Class[] { ErrorHandler.class });
      setErrorHandler.invoke(jaxpParser, 
        new Object[] { new BuilderErrorHandler() });
      
      Method parse = parserClass.getMethod(
        "parse", new Class[] { InputStream.class });
      return (Document)
        parse.invoke(jaxpParser, new Object[] { in });
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof IOException)) {
        throw ((IOException)targetException);
      }
      throw new JDOMException(targetException.getMessage(), targetException);
    }
    catch (Exception e)
    {
      throw new JDOMException("Reflection failed while parsing a document with JAXP", e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      Class.forName("javax.xml.transform.Transformer");
      
      Class factoryClass = 
        Class.forName("javax.xml.parsers.DocumentBuilderFactory");
      
      Method newParserInstance = 
        factoryClass.getMethod("newInstance", null);
      Object factory = newParserInstance.invoke(null, null);
      
      Method newDocBuilder = 
        factoryClass.getMethod("newDocumentBuilder", null);
      Object jaxpParser = newDocBuilder.invoke(factory, null);
      
      Class parserClass = jaxpParser.getClass();
      Method newDoc = parserClass.getMethod("newDocument", null);
      return 
        (Document)newDoc.invoke(jaxpParser, null);
    }
    catch (Exception e)
    {
      throw new JDOMException("Reflection failed while creating new JAXP document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.JAXPDOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class OracleV1DOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: OracleV1DOMAdapter.java,v $ $Revision: 1.19 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class parserClass = Class.forName("oracle.xml.parser.XMLParser");
      Object parser = parserClass.newInstance();
      
      Method parse = 
        parserClass.getMethod("parse", 
        new Class[] { InputSource.class });
      parse.invoke(parser, new Object[] { new InputSource(in) });
      
      Method getDocument = parserClass.getMethod("getDocument", null);
      return (Document)getDocument.invoke(parser, null);
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof SAXParseException))
      {
        SAXParseException parseException = (SAXParseException)targetException;
        throw new JDOMException("Error on line " + parseException.getLineNumber() + 
          " of XML document: " + parseException.getMessage(), parseException);
      }
      if ((targetException instanceof IOException))
      {
        IOException ioException = (IOException)targetException;
        throw ioException;
      }
      throw new JDOMException(targetException.getMessage(), targetException);
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage(), e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      return 
        (Document)Class.forName(
        "oracle.xml.parser.XMLDocument")
        .newInstance();
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage() + " when creating document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.OracleV1DOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class OracleV2DOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: OracleV2DOMAdapter.java,v $ $Revision: 1.18 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class parserClass = Class.forName("oracle.xml.parser.v2.DOMParser");
      Object parser = parserClass.newInstance();
      
      Method parse = 
        parserClass.getMethod("parse", 
        new Class[] { InputSource.class });
      parse.invoke(parser, new Object[] { new InputSource(in) });
      
      Method getDocument = parserClass.getMethod("getDocument", null);
      return (Document)getDocument.invoke(parser, null);
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof SAXParseException))
      {
        SAXParseException parseException = (SAXParseException)targetException;
        throw new JDOMException("Error on line " + parseException.getLineNumber() + 
          " of XML document: " + parseException.getMessage(), parseException);
      }
      if ((targetException instanceof IOException))
      {
        IOException ioException = (IOException)targetException;
        throw ioException;
      }
      throw new JDOMException(targetException.getMessage(), targetException);
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage(), e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      return 
        (Document)Class.forName(
        "oracle.xml.parser.v2.XMLDocument")
        .newInstance();
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage() + " when creating document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.OracleV2DOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.jdom.input.BuilderErrorHandler;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class XercesDOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: XercesDOMAdapter.java,v $ $Revision: 1.18 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class parserClass = 
        Class.forName("org.apache.xerces.parsers.DOMParser");
      Object parser = parserClass.newInstance();
      
      Method setFeature = parserClass.getMethod(
        "setFeature", 
        new Class[] { String.class, Boolean.TYPE });
      setFeature.invoke(parser, 
        new Object[] { "http://xml.org/sax/features/validation", 
        new Boolean(validate) });
      
      setFeature.invoke(parser, 
        new Object[] { "http://xml.org/sax/features/namespaces", 
        new Boolean(true) });
      if (validate)
      {
        Method setErrorHandler = parserClass.getMethod(
          "setErrorHandler", 
          new Class[] { ErrorHandler.class });
        setErrorHandler.invoke(parser, 
          new Object[] { new BuilderErrorHandler() });
      }
      Method parse = parserClass.getMethod(
        "parse", 
        new Class[] { InputSource.class });
      parse.invoke(parser, new Object[] { new InputSource(in) });
      
      Method getDocument = parserClass.getMethod("getDocument", null);
      return (Document)getDocument.invoke(parser, null);
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof SAXParseException))
      {
        SAXParseException parseException = 
          (SAXParseException)targetException;
        throw new JDOMException("Error on line " + 
          parseException.getLineNumber() + 
          " of XML document: " + 
          parseException.getMessage(), e);
      }
      if ((targetException instanceof IOException))
      {
        IOException ioException = (IOException)targetException;
        throw ioException;
      }
      throw new JDOMException(targetException.getMessage(), e);
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage(), e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      return (Document)Class.forName(
        "org.apache.xerces.dom.DocumentImpl").newInstance();
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage() + " when creating document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.XercesDOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom.adapters;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.jdom.JDOMException;
import org.jdom.input.BuilderErrorHandler;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

public class XML4JDOMAdapter
  extends AbstractDOMAdapter
{
  private static final String CVS_ID = "@(#) $RCSfile: XML4JDOMAdapter.java,v $ $Revision: 1.17 $ $Date: 2004/02/06 09:28:31 $ $Name: jdom_1_0 $";
  
  public Document getDocument(InputStream in, boolean validate)
    throws IOException, JDOMException
  {
    try
    {
      Class parserClass = Class.forName("org.apache.xerces.parsers.DOMParser");
      Object parser = parserClass.newInstance();
      
      Method setFeature = 
        parserClass.getMethod("setFeature", 
        new Class[] { String.class, 
        Boolean.TYPE });
      setFeature.invoke(parser, new Object[] { "http://xml.org/sax/features/validation", 
        new Boolean(validate) });
      
      setFeature.invoke(parser, new Object[] { "http://xml.org/sax/features/namespaces", 
        new Boolean(false) });
      if (validate)
      {
        Method setErrorHandler = 
          parserClass.getMethod("setErrorHandler", 
          new Class[] { ErrorHandler.class });
        setErrorHandler.invoke(parser, new Object[] { new BuilderErrorHandler() });
      }
      Method parse = 
        parserClass.getMethod("parse", 
        new Class[] { InputSource.class });
      parse.invoke(parser, new Object[] { new InputSource(in) });
      
      Method getDocument = parserClass.getMethod("getDocument", null);
      return (Document)getDocument.invoke(parser, null);
    }
    catch (InvocationTargetException e)
    {
      Throwable targetException = e.getTargetException();
      if ((targetException instanceof SAXParseException))
      {
        SAXParseException parseException = (SAXParseException)targetException;
        throw new JDOMException("Error on line " + parseException.getLineNumber() + 
          " of XML document: " + parseException.getMessage(), parseException);
      }
      if ((targetException instanceof IOException))
      {
        IOException ioException = (IOException)targetException;
        throw ioException;
      }
      throw new JDOMException(targetException.getMessage(), targetException);
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage(), e);
    }
  }
  
  public Document createDocument()
    throws JDOMException
  {
    try
    {
      return 
        (Document)Class.forName(
        "org.apache.xerces.dom.DocumentImpl")
        .newInstance();
    }
    catch (Exception e)
    {
      throw new JDOMException(e.getClass().getName() + ": " + 
        e.getMessage() + " while creating document", e);
    }
  }
}

/* Location:
 * Qualified Name:     org.jdom.adapters.XML4JDOMAdapter
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;

public class Attribute
  implements Serializable, Cloneable
{
  private static final String CVS_ID = "@(#) $RCSfile: Attribute.java,v $ $Revision: 1.52 $ $Date: 2004/03/01 23:58:28 $ $Name: jdom_1_0 $";
  public static final int UNDECLARED_TYPE = 0;
  public static final int CDATA_TYPE = 1;
  public static final int ID_TYPE = 2;
  public static final int IDREF_TYPE = 3;
  public static final int IDREFS_TYPE = 4;
  public static final int ENTITY_TYPE = 5;
  public static final int ENTITIES_TYPE = 6;
  public static final int NMTOKEN_TYPE = 7;
  public static final int NMTOKENS_TYPE = 8;
  public static final int NOTATION_TYPE = 9;
  public static final int ENUMERATED_TYPE = 10;
  protected String name;
  protected transient Namespace namespace;
  protected String value;
  protected int type = 0;
  protected Object parent;
  
  public Attribute(String name, String value, Namespace namespace)
  {
    setName(name);
    setValue(value);
    setNamespace(namespace);
  }
  
  public Attribute(String name, String value, int type, Namespace namespace)
  {
    setName(name);
    setValue(value);
    setAttributeType(type);
    setNamespace(namespace);
  }
  
  public Attribute(String name, String value)
  {
    this(name, value, 0, Namespace.NO_NAMESPACE);
  }
  
  public Attribute(String name, String value, int type)
  {
    this(name, value, type, Namespace.NO_NAMESPACE);
  }
  
  public Element getParent()
  {
    return (Element)parent;
  }
  
  public Document getDocument()
  {
    if (parent != null) {
      return ((Element)parent).getDocument();
    }
    return null;
  }
  
  protected Attribute setParent(Element parent)
  {
    this.parent = parent;
    return this;
  }
  
  public Attribute detach()
  {
    Element p = getParent();
    if (p != null) {
      p.removeAttribute(getName(), getNamespace());
    }
    return this;
  }
  
  public String getName()
  {
    return name;
  }
  
  public Attribute setName(String name)
  {
    String reason;
    if ((reason = Verifier.checkAttributeName(name)) != null) {
      throw new IllegalNameException(name, "attribute", reason);
    }
    this.name = name;
    return this;
  }
  
  public String getQualifiedName()
  {
    String prefix = namespace.getPrefix();
    if ((prefix != null) && (!prefix.equals(""))) {
      return 
      
        prefix + ':' + getName();
    }
    return getName();
  }
  
  public String getNamespacePrefix()
  {
    return namespace.getPrefix();
  }
  
  public String getNamespaceURI()
  {
    return namespace.getURI();
  }
  
  public Namespace getNamespace()
  {
    return namespace;
  }
  
  public Attribute setNamespace(Namespace namespace)
  {
    if (namespace == null) {
      namespace = Namespace.NO_NAMESPACE;
    }
    if ((namespace != Namespace.NO_NAMESPACE) && 
      (namespace.getPrefix().equals(""))) {
      throw new IllegalNameException("", "attribute namespace", 
        "An attribute namespace without a prefix can only be the NO_NAMESPACE namespace");
    }
    this.namespace = namespace;
    return this;
  }
  
  public String getValue()
  {
    return value;
  }
  
  public Attribute setValue(String value)
  {
    String reason = null;
    if ((reason = Verifier.checkCharacterData(value)) != null) {
      throw new IllegalDataException(value, "attribute", reason);
    }
    this.value = value;
    return this;
  }
  
  public int getAttributeType()
  {
    return type;
  }
  
  public Attribute setAttributeType(int type)
  {
    if ((type < 0) || (type > 10)) {
      throw new IllegalDataException(String.valueOf(type), 
        "attribute", "Illegal attribute type");
    }
    this.type = type;
    return this;
  }
  
  public String toString()
  {
    return 
    
      "[Attribute: " + getQualifiedName() + "=\"" + value + "\"" + "]";
  }
  
  public final boolean equals(Object ob)
  {
    return ob == this;
  }
  
  public final int hashCode()
  {
    return super.hashCode();
  }
  
  public Object clone()
  {
    Attribute attribute = null;
    try
    {
      attribute = (Attribute)super.clone();
    }
    catch (CloneNotSupportedException localCloneNotSupportedException) {}
    parent = null;
    return attribute;
  }
  
  public int getIntValue()
    throws DataConversionException
  {
    try
    {
      return Integer.parseInt(value.trim());
    }
    catch (NumberFormatException localNumberFormatException)
    {
      throw new DataConversionException(name, "int");
    }
  }
  
  public long getLongValue()
    throws DataConversionException
  {
    try
    {
      return Long.parseLong(value.trim());
    }
    catch (NumberFormatException localNumberFormatException)
    {
      throw new DataConversionException(name, "long");
    }
  }
  
  public float getFloatValue()
    throws DataConversionException
  {
    try
    {
      return Float.valueOf(value.trim()).floatValue();
    }
    catch (NumberFormatException localNumberFormatException)
    {
      throw new DataConversionException(name, "float");
    }
  }
  
  public double getDoubleValue()
    throws DataConversionException
  {
    try
    {
      return Double.valueOf(value.trim()).doubleValue();
    }
    catch (NumberFormatException localNumberFormatException)
    {
      throw new DataConversionException(name, "double");
    }
  }
  
  public boolean getBooleanValue()
    throws DataConversionException
  {
    String valueTrim = value.trim();
    if ((valueTrim.equalsIgnoreCase("true")) || 
      (valueTrim.equalsIgnoreCase("on")) || 
      (valueTrim.equalsIgnoreCase("1")) || 
      (valueTrim.equalsIgnoreCase("yes"))) {
      return true;
    }
    if ((valueTrim.equalsIgnoreCase("false")) || 
      (valueTrim.equalsIgnoreCase("off")) || 
      (valueTrim.equalsIgnoreCase("0")) || 
      (valueTrim.equalsIgnoreCase("no"))) {
      return false;
    }
    throw new DataConversionException(name, "boolean");
  }
  
  private void writeObject(ObjectOutputStream out)
    throws IOException
  {
    out.defaultWriteObject();
    
    out.writeObject(namespace.getPrefix());
    out.writeObject(namespace.getURI());
  }
  
  private void readObject(ObjectInputStream in)
    throws IOException, ClassNotFoundException
  {
    in.defaultReadObject();
    
    namespace = Namespace.getNamespace(
      (String)in.readObject(), (String)in.readObject());
  }
  
  protected Attribute() {}
}

/* Location:
 * Qualified Name:     org.jdom.Attribute
 * Java Class Version: 1.1 (45.3)
 * JD-Core Version:    0.7.1
 */
package org.jdom;

import java.io.Serializable;
import java.util.AbstractCollection;
import java.util.AbstractList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

class AttributeList
  extends AbstractList
  implements List, Serializable
{
  private static final String CVS_ID = "@(#) $RCSfile: AttributeList.java,v $ $Revision: 1.23 $ $Date: 2004/02/28 03:30:27 $ $Name: jdom_1_0 $";
  private static final int INITIAL_ARRAY_SIZE = 5;
  private Attribute[] elementData;
  private int size;
  private Element parent;
  
  AttributeList(Element parent)
  {
    this.parent = parent;
  }
  
  final void uncheckedAddAttribute(Attribute a)
  {
    parent = parent;
    ensureCapacity(size + 1);
    elementData[(size++)] = a;
    modCount += 1;
  }
  
  public boolean add(Object obj)
  {
    if ((obj instanceof Attribute))
    {
      Attribute attribute = (Attribute)obj;
      int duplicate = indexOfDuplicate(attribute);
      if (duplicate < 0) {
        add(size(), attribute);
      } else {
        set(duplicate, attribute);
      }
    }
    else
    {
      if (obj == null) {
        throw new IllegalAddException("Cannot add null attribute");
      }
      throw new IllegalAddException("Class " + 
        obj.getClass().getName() + 
        " is not an attribute");
    }
    int duplicate;
    Attribute attribute;
    return true;
  }
  
  public void add(int index, Object obj)
  {
    if ((obj instanceof Attribute))
    {
      Attribute attribute = (Attribute)obj;
      int duplicate = indexOfDuplicate(attribute);
      if (duplicate >= 0) {
        throw new IllegalAddException("Cannot add duplicate attribute");
      }
      add(index, attribute);
    }
    else
    {
      if (obj == null) {
        throw new IllegalAddException("Cannot add null attribute");
      }
      throw new IllegalAddException("Class " + 
        obj.getClass().getName() + 
        " is not an attribute");
    }
    int duplicate;
    Attribute attribute;
    modCount += 1;
  }
  
  void add(int index, Attribute attribute)
  {
    if (attribute.getParent() != null) {
      throw new IllegalAddException(
        "The attribute already has an existing parent \"" + 
        attribute.getParent().getQualifiedName() + "\"");
    }
    String reason = Verifier.checkNamespaceCollision(attribute, parent);
    if (reason != null) {
      throw new IllegalAddException(parent, attribute, reason);
    }
    if ((index < 0) || (index > size)) {
      throw new IndexOutOfBoundsException("Index: " + index + 
        " Size: " + size());
    }
    attribute.setParent(parent);
    
    ensureCapacity(size + 1);
    if (index == size)
    {
      elementData[(size++)] = attribute;
    }
    else
    {
      System.arraycopy(elementData, index, elementData, index + 1, size - index);
      elementData[index] = attribute;
      size += 1;
    }
    modCount += 1;
  }
  
  public boolean addAll(Collection collection)
  {
    return addAll(size(), collection);
  }
  
  public boolean addAll(int index, Collection collection)
  {
    if ((index < 0) || (index > size)) {
      throw new IndexOutOfBoundsException("Index: " + index + 
        " Size: " + size());
    }
    if ((collection == null) || (collection.size() == 0)) {
      return false;
    }
    ensureCapacity(size() + collection.size());
    
    int count = 0;
    try
    {
      Iterator i = collection.iterator();
      while (i.hasNext())
      {
        Object obj = i.next();
        add(index + count, obj);
        count++;
      }
    }
    catch (RuntimeException exception)
    {
      for (int i = 0; i < count; i++) {
        remove(index);
      }
      throw exception;
    }
    Iterator i;
    return true;
  }
  
  public void clear()
  {
    if (elementData != null)
    {
      for (int i = 0; i < size; i++)
      {
        Attribute attribute = elementData[i];
        attribute.setParent(null);
      }
      elementData = null;
      size = 0;
    }
    modCount += 1;
  }
  
  void clearAndSet(Collection collection)
  {
    Attribute[] old = elementData;
    int oldSize = size;
    
    elementData = null;
    size = 0;
    if ((collection != null) && (collection.size() != 0))
    {
      ensureCapacity(collection.size());
      try
      {
        addAll(0, collection);
      }
      catch (RuntimeException exception)
      {
        elementData = old;
        size = oldSize;
        throw exception;
      }
    }
    if (old != null) {
      for (int i = 0; i < oldSize; i++)
      {
        Attribute attribute = old[i];
        attribute.setParent(null);
      }
    }
    modCount += 1;
  }
  
  private void ensureCapacity(int minCapacity)
  {
    if (elementData == null)
    {
      elementData = new Attribute[Math.max(minCapacity, 5)];
    }
    else
    {
      int oldCapacity = elementData.length;
      if (minCapacity > oldCapacity)
      {
        Attribute[] oldData = elementData;
        int newCapacity = oldCapacity * 3 / 2 + 1;
        if (newCapacity < minCapacity) {
          newCapacity = minCapacity;
        }
        elementData = new Attribute[newCapacity];
        System.arraycopy(oldData, 0, elementData, 0, size);
      }
    }
  }
  
  public Object get(int index)
  {
    if ((index < 0) || (index >= size)) {
      throw new IndexOutOfBoundsException("Index: " + index + 
        " Size: " + size());
    }
    return elementData[index];
  }
  
  Object get(String name, Namespace namespace)
  {
    int index = indexOf(name, namespace);
    if (index < 0) {
      return null;
    }
    return elementData[index];
  }
  
  int indexOf(String name, Namespace namespace)
  {
    String uri = namespace.getURI();
    if (elementData != null) {
      for (int i = 0; i < size; i++)
      {
        Attribute old = elementData[i];
        String oldURI = old.getNamespaceURI();
        String oldName = old.getName();
        if ((oldURI.equals(uri)) && (oldName.equals(name))) {
          return i;
        }
      }
    }
    return -1;
  }
  
  public Object remove(int index)
  {
    if ((index < 0) || (index >= size)) {
      throw new IndexOutOfBoundsException("Index: " + index + 
        " Size: " + size());
    }
    Attribute old = elementData[index];
    old.setParent(null);
    int numMoved = size - index - 1;
    if (numMoved > 0) {
      System.arraycopy(elementData, index + 1, elementData, index, numMoved);
    }
    elementData[(--size)] = null;
    modCount += 1;
    return old;
  }
  
  boolean remove(String name, Namespace namespace)
  {
    int index = indexOf(name, namespace);
    if (index < 0) {
      return false;
    }
    remove(index);
    return true;
  }
  
  public Object set(int index, Object obj)
  {
    if ((obj instanceof Attribute))
    {
      Attribute attribute = (Attribute)obj;
      int duplicate = indexOfDuplicate(attribute);
      if ((duplicate >= 0) && (duplicate != index)) {
        throw new IllegalAddException("Cannot set duplicate attribute");
      }
      return set(index, attribute);
    }
    if (obj == nul
1 2 3 4 5 6 7 8 9

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd