org.eclipse.equinox.p2.ui.importexport_1.0.1.v20120913-155635

ableUnitDescription desc = new MetadataFactory.InstallableUnitDescription();
      desc.setId(values[0]);
      desc.setProperty("org.eclipse.equinox.p2.name", values[1]);
      desc.setVersion(Version.create(values[2]));
      iu = MetadataFactory.createInstallableUnit(desc);
      this.ius = ius;
    }
    
    public void startElement(String name, Attributes attributes)
    {
      if (name.equals("repositories")) {
        repositoriesHandler = new P2FParser.RepositoriesHandler(P2FParser.this, this, attributes);
      }
    }
    
    protected void finished()
    {
      if (isValidXML()) {
        ius.add(new IUDetail(iu, repositoriesHandler.getRepositories()));
      }
    }
  }
  
  protected class IUsHandler
    extends XMLParser.AbstractHandler
  {
    private final List<IUDetail> ius;
    
    public IUsHandler(ContentHandler parentHandler, Attributes attributes)
    {
      super(parentHandler, "ius");
      String size = parseOptionalAttribute(attributes, "size");
      ius = (size != null ? new ArrayList(new Integer(size).intValue()) : new ArrayList());
    }
    
    public void startElement(String name, Attributes attributes)
    {
      if (name.equals("iu")) {
        new P2FParser.IUHandler(P2FParser.this, this, attributes, ius);
      } else {
        invalidElement(name, attributes);
      }
    }
    
    public List<IUDetail> getIUs()
    {
      return ius;
    }
  }
  
  private final class P2FDocHandler
    extends XMLParser.DocHandler
  {
    public P2FDocHandler(String rootName, XMLParser.RootHandler rootHandler)
    {
      super(rootName, rootHandler);
    }
    
    public void processingInstruction(String target, String data)
    {
      if ("p2f".equals(target))
      {
        Version repositoryVersion = extractPIVersion(target, data);
        if (!P2FParser.XML_TOLERANCE.isIncluded(repositoryVersion)) {
          throw new VersionIncompatibleException(NLS.bind(Messages.io_IncompatibleVersion, repositoryVersion, P2FParser.XML_TOLERANCE));
        }
      }
    }
  }
  
  final class P2FHandler
    extends XMLParser.RootHandler
  {
    P2FHandler()
    {
      super();
    }
    
    private final String[] required = new String[0];
    private final String[] optional = new String[0];
    private P2FParser.IUsHandler iusHandler;
    
    protected void handleRootAttributes(Attributes attributes)
    {
      parseAttributes(attributes, required, optional);
    }
    
    public void startElement(String name, Attributes attributes)
    {
      if ("ius".equals(name))
      {
        if (iusHandler == null) {
          iusHandler = new P2FParser.IUsHandler(P2FParser.this, this, attributes);
        } else {
          duplicateElement(this, name, attributes);
        }
      }
      else {
        invalidElement(name, attributes);
      }
    }
    
    protected void finished()
    {
      if ((isValidXML()) && 
        (iusHandler != null)) {
        iusListed = iusHandler.getIUs();
      }
    }
  }
  
  public P2FParser(BundleContext context, String pluginId)
  {
    super(context, pluginId);
  }
  
  public void parse(File file)
    throws IOException
  {
    if (errorContext == null) {
      setErrorContext(file.getAbsolutePath());
    }
    parse(new FileInputStream(file));
  }
  
  /* Error */
  public synchronized void parse(java.io.InputStream stream)
    throws IOException
  {
    // Byte code:
    //   0: aload_0
    //   1: aconst_null
    //   2: putfield 128	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser:status	Lorg/eclipse/core/runtime/MultiStatus;
    //   5: aload_0
    //   6: invokevirtual 139	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser:getParser	()Ljavax/xml/parsers/SAXParser;
    //   9: pop
    //   10: new 64	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser$P2FHandler
    //   13: dup
    //   14: aload_0
    //   15: invokespecial 141	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser$P2FHandler:<init>	(Lorg/eclipse/equinox/internal/p2/importexport/persistence/P2FParser;)V
    //   18: astore_2
    //   19: aload_0
    //   20: getfield 130	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser:xmlReader	Lorg/xml/sax/XMLReader;
    //   23: new 63	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser$P2FDocHandler
    //   26: dup
    //   27: aload_0
    //   28: ldc 1
    //   30: aload_2
    //   31: invokespecial 140	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser$P2FDocHandler:<init>	(Lorg/eclipse/equinox/internal/p2/importexport/persistence/P2FParser;Ljava/lang/String;Lorg/eclipse/equinox/internal/p2/persistence/XMLParser$RootHandler;)V
    //   34: invokeinterface 147 2 0
    //   39: aload_0
    //   40: getfield 130	org/eclipse/equinox/internal/p2/importexport/persistence/P2FParser:xmlReader	Lorg/xml/sax/XMLReader;
    //   43: new 71	org/xml/sax/InputSource
    //   46: dup
    //   47: aload_1
    //   48: invokespecial 145	org/xml/sax/InputSource:<init>	(Ljava/io/InputStream;)V
    //   51: invokeinterface 148 2 0
    //   56: goto +36 -> 92
    //   59: astore_2
    //   60: new 54	java/io/IOException
    //   63: dup
    //   64: aload_2
    //   65: invokevirtual 146	org/xml/sax/SAXException:getMessage	()Ljava/lang/String;
    //   68: invokespecial 133	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   71: athrow
    //   72: astore_2
    //   73: new 54	java/io/IOException
    //   76: dup
    //   77: aload_2
    //   78: invokevirtual 136	javax/xml/parsers/ParserConfigurationException:getMessage	()Ljava/lang/String;
    //   81: invokespecial 133	java/io/IOException:<init>	(Ljava/lang/String;)V
    //   84: athrow
    //   85: astore_3
    //   86: aload_1
    //   87: invokevirtual 134	java/io/InputStream:close	()V
    //   90: aload_3
    //   91: athrow
    //   92: aload_1
    //   93: invokevirtual 134	java/io/InputStream:close	()V
    //   96: return
    // Line number table:
    //   Java source line #205	-> byte code offset #0
    //   Java source line #209	-> byte code offset #5
    //   Java source line #210	-> byte code offset #10
    //   Java source line #211	-> byte code offset #19
    //   Java source line #212	-> byte code offset #39
    //   Java source line #213	-> byte code offset #59
    //   Java source line #214	-> byte code offset #60
    //   Java source line #215	-> byte code offset #72
    //   Java source line #216	-> byte code offset #73
    //   Java source line #217	-> byte code offset #85
    //   Java source line #218	-> byte code offset #86
    //   Java source line #219	-> byte code offset #90
    //   Java source line #218	-> byte code offset #92
    //   Java source line #220	-> byte code offset #96
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	97	0	this	P2FParser
    //   0	97	1	stream	java.io.InputStream
    //   18	13	2	p2fHandler	P2FHandler
    //   59	6	2	e	org.xml.sax.SAXException
    //   72	6	2	e	javax.xml.parsers.ParserConfigurationException
    //   85	6	3	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   5	56	59	org/xml/sax/SAXException
    //   5	56	72	javax/xml/parsers/ParserConfigurationException
    //   5	85	85	finally
  }
  
  public List<IUDetail> getIUs()
  {
    if (iusListed == null) {
      iusListed = new ArrayList();
    }
    return iusListed;
  }
  
  protected Object getRootObject()
  {
    return null;
  }
  
  protected String getErrorMessage()
  {
    return Messages.io_parseError;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.persistence.P2FParser
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.p2.importexport.persistence;

import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.equinox.internal.p2.importexport.IUDetail;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter;
import org.eclipse.equinox.internal.p2.persistence.XMLWriter.ProcessingInstruction;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.Version;

public class P2FWriter
  extends XMLWriter
  implements P2FConstants
{
  public P2FWriter(OutputStream output, XMLWriter.ProcessingInstruction[] piElements)
    throws UnsupportedEncodingException
  {
    super(output, piElements);
  }
  
  public void write(List<IUDetail> features)
  {
    start("p2f");
    attribute("version", CURRENT_VERSION);
    writeFeatures(features);
    end("p2f");
    flush();
  }
  
  private void writeFeatures(List<IUDetail> features)
  {
    start("ius");
    attributeOptional("size", String.valueOf(features.size()));
    for (Iterator localIterator = features.iterator(); localIterator.hasNext();)
    {
      IUDetail feature = (IUDetail)localIterator.next();
      writeFeature(feature);
    }
    end("ius");
  }
  
  private void writeFeature(IUDetail feature)
  {
    IInstallableUnit unit = feature.getIU();
    start("iu");
    attribute("id", unit.getId());
    attribute("name", unit.getProperty("org.eclipse.equinox.p2.name", Locale.getDefault().toString()));
    attribute("version", unit.getVersion().toString());
    start("repositories");
    attribute("size", feature.getReferencedRepositories().size());
    for (Iterator localIterator = feature.getReferencedRepositories().iterator(); localIterator.hasNext();)
    {
      URI uri = (URI)localIterator.next();
      start("repository");
      String unencoded = URIUtil.toUnencodedString(uri);
      attribute("location", unencoded);
      end("repository");
    }
    end("repositories");
    end("iu");
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.p2.importexport.persistence.P2FWriter
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
1 2 3 4 5 6

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-2019. Infinite Loop Ltd