home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2009 March / ME_03_2009.iso / Software / Internet / Cyberduck-3.1.2.dmg / Cyberduck.app / Contents / Resources / Java / jdom-1.1.jar / JDOMAbout$Info.class (.txt) < prev   
Encoding:
Java Class File  |  2007-11-14  |  2.4 KB  |  49 lines

  1. import java.io.FileNotFoundException;
  2. import java.io.InputStream;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import org.jdom.Document;
  6. import org.jdom.Element;
  7. import org.jdom.input.SAXBuilder;
  8.  
  9. class JDOMAbout$Info {
  10.    private static final String INFO_FILENAME = "META-INF/jdom-info.xml";
  11.    final String title;
  12.    final String version;
  13.    final String copyright;
  14.    final String description;
  15.    final String license;
  16.    final String support;
  17.    final String website;
  18.    final List authors = new ArrayList();
  19.  
  20.    JDOMAbout$Info() throws Exception {
  21.       InputStream inputStream = this.getInfoFileStream();
  22.       SAXBuilder builder = new SAXBuilder();
  23.       Document doc = builder.build(inputStream);
  24.       Element root = doc.getRootElement();
  25.       this.title = root.getChildTextTrim("title");
  26.       this.version = root.getChildTextTrim("version");
  27.       this.copyright = root.getChildTextTrim("copyright");
  28.       this.description = root.getChildTextTrim("description");
  29.       this.license = root.getChildTextTrim("license");
  30.       this.support = root.getChildTextTrim("support");
  31.       this.website = root.getChildTextTrim("web-site");
  32.  
  33.       for(Element element : root.getChildren("author")) {
  34.          JDOMAbout$Author author = new JDOMAbout$Author(element.getChildTextTrim("name"), element.getChildTextTrim("e-mail"));
  35.          this.authors.add(author);
  36.       }
  37.  
  38.    }
  39.  
  40.    private InputStream getInfoFileStream() throws FileNotFoundException {
  41.       InputStream inputStream = this.getClass().getResourceAsStream("META-INF/jdom-info.xml");
  42.       if (inputStream == null) {
  43.          throw new FileNotFoundException("META-INF/jdom-info.xml not found; it should be within the JDOM JAR but wasn't found on the classpath");
  44.       } else {
  45.          return inputStream;
  46.       }
  47.    }
  48. }
  49.