org.eclipse.pde.core_3.7.1.v20120103_r372

 129: invokestatic 294	org/eclipse/pde/internal/core/PDECore:log	(Ljava/lang/Throwable;)V
    //   132: return
    // Line number table:
    //   Java source line #240	-> byte code offset #0
    //   Java source line #241	-> byte code offset #10
    //   Java source line #243	-> byte code offset #13
    //   Java source line #244	-> byte code offset #29
    //   Java source line #245	-> byte code offset #33
    //   Java source line #247	-> byte code offset #45
    //   Java source line #248	-> byte code offset #57
    //   Java source line #249	-> byte code offset #59
    //   Java source line #252	-> byte code offset #64
    //   Java source line #253	-> byte code offset #69
    //   Java source line #254	-> byte code offset #77
    //   Java source line #255	-> byte code offset #79
    //   Java source line #250	-> byte code offset #87
    //   Java source line #252	-> byte code offset #89
    //   Java source line #253	-> byte code offset #94
    //   Java source line #254	-> byte code offset #102
    //   Java source line #255	-> byte code offset #104
    //   Java source line #257	-> byte code offset #109
    //   Java source line #252	-> byte code offset #112
    //   Java source line #253	-> byte code offset #117
    //   Java source line #254	-> byte code offset #125
    //   Java source line #255	-> byte code offset #127
    //   Java source line #258	-> byte code offset #132
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	133	0	this	WorkspaceModelManager
    //   0	133	1	model	IModel
    //   0	133	2	reload	boolean
    //   9	9	3	file	IFile
    //   11	107	4	stream	java.io.InputStream
    //   57	3	5	e	CoreException
    //   87	23	6	localObject	Object
    //   77	3	7	e	java.io.IOException
    //   102	3	7	e	java.io.IOException
    //   125	3	7	e	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   13	54	57	org/eclipse/core/runtime/CoreException
    //   64	74	77	java/io/IOException
    //   13	64	87	finally
    //   89	99	102	java/io/IOException
    //   112	122	125	java/io/IOException
  }
  
  protected void createAndFireEvent(String eventId, int type, Collection added, Collection removed, Collection changed)
  {
    if (eventId.equals("org.eclipse.pde.core.IModelProviderEvent"))
    {
      ModelProviderEvent event = new ModelProviderEvent(this, type, (IModel[])added.toArray(new IModel[added.size()]), (IModel[])removed.toArray(new IModel[removed.size()]), (IModel[])changed.toArray(new IModel[changed.size()]));
      fireModelProviderEvent(event);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.WorkspaceModelManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.ListIterator;
import java.util.Map;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.ISharedExtensionsModel;
import org.eclipse.pde.internal.core.builders.SchemaTransformer;
import org.eclipse.pde.internal.core.bundle.BundleFragmentModel;
import org.eclipse.pde.internal.core.bundle.BundlePluginModel;
import org.eclipse.pde.internal.core.bundle.WorkspaceBundleModel;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
import org.eclipse.pde.internal.core.ischema.ISchema;
import org.eclipse.pde.internal.core.ischema.ISchemaDescriptor;
import org.eclipse.pde.internal.core.plugin.WorkspaceExtensionsModel;
import org.eclipse.pde.internal.core.plugin.WorkspaceFragmentModel;
import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.core.schema.SchemaDescriptor;

public class WorkspacePluginModelManager
  extends WorkspaceModelManager
{
  private ArrayList fExtensionListeners = new ArrayList();
  private ArrayList fChangedExtensions = null;
  
  protected boolean isInterestingProject(IProject project)
  {
    return isPluginProject(project);
  }
  
  protected void createModel(IProject project, boolean notify)
  {
    IPluginModelBase model = null;
    IFile manifest = PDEProject.getManifest(project);
    IFile pluginXml = PDEProject.getPluginXml(project);
    IFile fragmentXml = PDEProject.getFragmentXml(project);
    if (manifest.exists())
    {
      WorkspaceBundleModel bmodel = new WorkspaceBundleModel(manifest);
      loadModel(bmodel, false);
      if (bmodel.isFragmentModel()) {
        model = new BundleFragmentModel();
      } else {
        model = new BundlePluginModel();
      }
      model.setEnabled(true);
      bmodel.setEditable(false);
      ((IBundlePluginModelBase)model).setBundleModel(bmodel);
      
      IFile efile = bmodel.isFragmentModel() ? fragmentXml : pluginXml;
      if (efile.exists())
      {
        WorkspaceExtensionsModel extModel = new WorkspaceExtensionsModel(efile);
        extModel.setEditable(false);
        loadModel(extModel, false);
        ((IBundlePluginModelBase)model).setExtensionsModel(extModel);
        extModel.setBundleModel((IBundlePluginModelBase)model);
      }
    }
    else if (pluginXml.exists())
    {
      model = new WorkspacePluginModel(pluginXml, true);
      loadModel(model, false);
    }
    else if (fragmentXml.exists())
    {
      model = new WorkspaceFragmentModel(fragmentXml, true);
      loadModel(model, false);
    }
    if (PDEProject.getOptionsFile(project).exists()) {
      PDECore.getDefault().getTracingOptionsManager().reset();
    }
    if (model != null)
    {
      if (fModels == null) {
        fModels = new HashMap();
      }
      fModels.put(project, model);
      if (notify) {
        addChange(model, 1);
      }
    }
  }
  
  protected void handleFileDelta(IResourceDelta delta)
  {
    IFile file = (IFile)delta.getResource();
    IProject project = file.getProject();
    String filename = file.getName();
    if (file.equals(PDEProject.getOptionsFile(project)))
    {
      PDECore.getDefault().getTracingOptionsManager().reset();
    }
    else if (file.equals(PDEProject.getBuildProperties(project)))
    {
      Object model = getModel(project);
      if (model != null) {
        addChange(model, 4);
      }
    }
    else if (file.equals(PDEProject.getLocalizationFile(project)))
    {
      IPluginModelBase model = getPluginModel(project);
      if (model != null) {
        ((AbstractNLModel)model).resetNLResourceHelper();
      }
    }
    else if (filename.endsWith(".exsd"))
    {
      handleEclipseSchemaDelta(file, delta);
    }
    else if ((file.equals(PDEProject.getPluginXml(project))) || (file.equals(PDEProject.getFragmentXml(project))))
    {
      handleExtensionFileDelta(file, delta);
    }
    else if (file.equals(PDEProject.getManifest(project)))
    {
      handleBundleManifestDelta(file, delta);
    }
  }
  
  private void handleEclipseSchemaDelta(IFile schemaFile, IResourceDelta delta)
  {
    int kind = delta.getKind();
    if (kind != 4) {
      return;
    }
    if ((0x100 & delta.getFlags()) == 0) {
      return;
    }
    Object property = null;
    try
    {
      property = schemaFile.getSessionProperty(PDECore.SCHEMA_PREVIEW_FILE);
    }
    catch (CoreException localCoreException)
    {
      return;
    }
    if (property == null) {
      return;
    }
    if (!(property instanceof File)) {
      return;
    }
    File schemaPreviewFile = (File)property;
    if (!schemaPreviewFile.exists()) {
      return;
    }
    if (!schemaPreviewFile.isFile()) {
      return;
    }
    if (!schemaPreviewFile.canWrite()) {
      return;
    }
    ISchemaDescriptor descriptor = new SchemaDescriptor(schemaFile, false);
    ISchema schema = descriptor.getSchema(false);
    try
    {
      recreateSchemaPreviewFileContents(schemaPreviewFile, schema);
    }
    catch (IOException localIOException) {}
  }
  
  private void recreateSchemaPreviewFileContents(File schemaPreviewFile, ISchema schema)
    throws IOException
  {
    SchemaTransformer transformer = new SchemaTransformer();
    OutputStream os = new FileOutputStream(schemaPreviewFile);
    PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(os, "UTF-8"), true);
    transformer.transform(schema, printWriter);
    os.flush();
    os.close();
  }
  
  private void handleExtensionFileDelta(IFile file, IResourceDelta delta)
  {
    int kind = delta.getKind();
    IPluginModelBase model = (IPluginModelBase)getModel(file.getProject());
    if (kind == 2)
    {
      if ((model instanceof IBundlePluginModelBase))
      {
        ((IBundlePluginModelBase)model).setExtensionsModel(null);
        addExtensionChange(model, 2);
      }
      else
      {
        removeModel(file.getProject());
      }
    }
    else if (kind == 1)
    {
      if ((model instanceof IBundlePluginModelBase))
      {
        WorkspaceExtensionsModel extensions = new WorkspaceExtensionsModel(file);
        extensions.setEditable(false);
        ((IBundlePluginModelBase)model).setExtensionsModel(extensions);
        extensions.setBundleModel((IBundlePluginModelBase)model);
        loadModel(extensions, false);
        addExtensionChange(model, 1);
      }
      else
      {
        createModel(file.getProject(), true);
      }
    }
    else if ((kind == 4) && ((0x100 & delta.getFlags()) != 0))
    {
      if ((model instanceof IBundlePluginModelBase))
      {
        ISharedExtensionsModel extensions = ((IBundlePluginModelBase)model).getExtensionsModel();
        boolean reload = extensions != null;
        if (extensions == null)
        {
          extensions = new WorkspaceExtensionsModel(file);
          ((WorkspaceExtensionsModel)extensions).setEditable(false);
          ((IBundlePluginModelBase)model).setExtensionsModel(extensions);
          ((WorkspaceExtensionsModel)extensions).setBundleModel((IBundlePluginModelBase)model);
        }
        loadModel(extensions, reload);
      }
      else if (model != null)
      {
        loadModel(model, true);
        addChange(model, 4);
      }
      addExtensionChange(model, 4);
    }
  }
  
  private void handleBundleManifestDelta(IFile file, IResourceDelta delta)
  {
    int kind = delta.getKind();
    IProject project = file.getProject();
    Object model = getModel(project);
    if ((kind == 2) && (model != null))
    {
      removeModel(project);
      
      createModel(project, true);
    }
    else if ((kind == 1) || (model == null))
    {
      createModel(project, true);
    }
    else if ((kind == 4) && ((0x100 & delta.getFlags()) != 0) && 
      ((model instanceof IBundlePluginModelBase)))
    {
      String oldLocalization = ((IBundlePluginModelBase)model).getBundleLocalization();
      IBundleModel bmodel = ((IBundlePluginModelBase)model).getBundleModel();
      boolean wasFragment = bmodel.isFragmentModel();
      loadModel(bmodel, true);
      String newLocalization = ((IBundlePluginModelBase)model).getBundleLocalization();
      if (wasFragment != bmodel.isFragmentModel())
      {
        removeModel(project);
        createModel(project, true);
      }
      else
      {
        if ((((model instanceof AbstractNLModel)) && (oldLocalization != null) && ((newLocalization == null) || (!oldLocalization.equals(newLocalization)))) || ((newLocalization != null) && ((oldLocalization == null) || (!newLocalization.equals(oldLocalization))))) {
          ((AbstractNLModel)model).resetNLResourceHelper();
        }
        addChange(model, 4);
      }
    }
  }
  
  protected Object removeModel(IProject project)
  {
    Object model = super.removeModel(project);
    if ((model != null) && (PDEProject.getOptionsFile(project).exists())) {
      PDECore.getDefault().getTracingOptionsManager().reset();
    }
    if ((model instanceof IPluginModelBase)) {
      addExtensionChange((IPluginModelBase)model, 2);
    }
    return model;
  }
  
  protected IPluginModelBase getPluginModel(IProject project)
  {
    return (IPluginModelBase)getModel(project);
  }
  
  protected IPluginModelBase[] getPluginModels()
  {
    initialize();
    return (IPluginModelBase[])fModels.values().toArray(new IPluginModelBase[fModels.size()]);
  }
  
  protected void addListeners()
  {
    IWorkspace workspace = PDECore.getWorkspace();
    workspace.addResourceChangeListener(this, 2);
    
    JavaCore.addPreProcessingResourceChangedListener(this, 1);
  }
  
  protected void removeListeners()
  {
    PDECore.getWorkspace().removeResourceChangeListener(this);
    JavaCore.removePreProcessingResourceChangedListener(this);
    if (fExtensionListeners.size() > 0) {
      fExtensionListeners.clear();
    }
    super.removeListeners();
  }
  
  protected boolean isInterestingFolder(IFolder folder)
  {
    IContainer root = PDEProject.getBundleRoot(folder.getProject());
    if (folder.getProjectRelativePath().isPrefixOf(root.getProjectRelativePath())) {
      return true;
    }
    String folderName = folder.getName();
    if ((("META-INF".equals(folderName)) || ("OSGI-INF".equals(folderName)) || ("schema".equals(folderName))) && (folder.getParent().equals(root))) {
      return true;
    }
    if ("OSGI-INF/l10n".equals(folder.getProjectRelativePath().toString())) {
      return true;
    }
    return false;
  }
  
  protected void initializeModels(IPluginModelBase[] models)
  {
    fModels = Collections.synchronizedMap(new HashMap());
    for (int i = 0; i < models.length; i++)
    {
      IProject project = models[i].getUnderlyingResource().getProject();
      fModels.put(project, models[i]);
    }
    IProject[] projects = PDECore.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
      if ((!fModels.containsKey(projects[i])) && (isInterestingProject(projects[i]))) {
        createModel(projects[i], false);
      }
    }
    addListeners();
  }
  
  protected URL[] getPluginPaths()
  {
    ArrayList list = new ArrayList();
    IProject[] projects = PDECore.getWorkspace().getRoot().getProjects();
    for (int i = 0; i < projects.length; i++) {
      if (isPluginProject(projects[i])) {
        try
        {
          IPath path = projects[i].getLocation();
          if (path != null) {
            list.add(path.toFile().toURL());
          }
        }
        catch (MalformedURLException localMalformedURLException) {}
      }
    }
    return (URL[])list.toArray(new URL[list.size()]);
  }
  
  void addExtensionDeltaListener(IExtensionDeltaListener listener)
  {
    if (!fExtensionListeners.contains(listener)) {
      fExtensionListeners.add(listener);
    }
  }
  
  void removeExtensionDeltaListener(IExtensionDeltaListener listener)
  {
    fExtensionListeners.remove(listener);
  }
  
  public void fireExtensionDeltaEvent(IExtensionDeltaEvent event)
  {
    for (ListIterator li = fExtensionListeners.listIterator(); li.hasNext();) {
      ((IExtensionDeltaListener)li.next()).extensionsChanged(event);
    }
  }
  
  protected void processModelChanges()
  {
    super.processModelChanges();
    processModelChanges("org.eclipse.pde.internal.core.IExtensionDeltaEvent", fChangedExtensions);
    fChangedExtensions = null;
  }
  
  protected void createAndFireEvent(String eventId, int type, Collection added, Collection removed, Collection changed)
  {
    if (eventId.equals("org.eclipse.pde.internal.core.IExtensionDeltaEvent"))
    {
      IExtensionDeltaEvent event = new ExtensionDeltaEvent(type, (IPluginModelBase[])added.toArray(new IPluginModelBase[added.size()]), (IPluginModelBase[])removed.toArray(new IPluginModelBase[removed.size()]), (IPluginModelBase[])changed.toArray(new IPluginModelBase[changed.size()]));
      fireExtensionDeltaEvent(event);
    }
    else
    {
      super.createAndFireEvent(eventId, type, added, removed, changed);
    }
  }
  
  protected void addExtensionChange(IPluginModelBase plugin, int type)
  {
    if (fChangedExtensions == null) {
      fChangedExtensions = new ArrayList();
    }
    WorkspaceModelManager.ModelChange change = new WorkspaceModelManager.ModelChange(this, plugin, type);
    fChangedExtensions.add(change);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.WorkspacePluginModelManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.util.Stack;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;

public class XMLCopyrightHandler
  implements LexicalHandler
{
  private String fCopyright = null;
  private XMLDefaultHandler fHandler = null;
  
  public XMLCopyrightHandler(XMLDefaultHandler handler)
  {
    fHandler = handler;
  }
  
  public void comment(char[] ch, int start, int length)
    throws SAXException
  {
    if ((fHandler != null) && (fCopyright == null) && (fHandler.fElementStack.isEmpty())) {
      fCopyright = new String(ch, start, length);
    }
  }
  
  public void endCDATA()
    throws SAXException
  {}
  
  public void endDTD()
    throws SAXException
  {}
  
  public void endEntity(String name)
    throws SAXException
  {}
  
  public void startCDATA()
    throws SAXException
  {}
  
  public void startDTD(String name, String publicId, String systemId)
    throws SAXException
  {}
  
  public void startEntity(String name)
    throws SAXException
  {}
  
  public String getCopyright()
  {
    return fCopyright;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.XMLCopyrightHandler
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.StringReader;
import java.util.Stack;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

public class XMLDefaultHandler
  extends DefaultHandler
{
  private Document fDocument;
  private Element fRootElement;
  protected Stack fElementStack = new Stack();
  protected boolean fAbbreviated;
  
  public XMLDefaultHandler() {}
  
  public XMLDefaultHandler(boolean abbreviated)
  {
    fAbbreviated = abbreviated;
  }
  
  public void startElement(String uri, String localName, String qName, Attributes attributes)
    throws SAXException
  {
    if (!isPrepared()) {
      return;
    }
    Element element = fDocument.createElement(qName);
    for (int i = 0; i < attributes.getLength(); i++) {
      element.setAttribute(attributes.getQName(i), attributes.getValue(i));
    }
    if (fRootElement == null) {
      fRootElement = element;
    } else {
      ((Element)fElementStack.peek()).appendChild(element);
    }
    fElementStack.push(element);
  }
  
  public void endElement(String uri, String localName, String qName)
    throws SAXException
  {
    if ((isPrepared()) && (!fElementStack.isEmpty())) {
      fElementStack.pop();
    }
  }
  
  public void setDocumentLocator(Locator locator) {}
  
  public void startDocument()
    throws SAXException
  {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    try
    {
      fDocument = factory.newDocumentBuilder().newDocument();
    }
    catch (ParserConfigurationException localParserConfigurationException) {}
  }
  
  public void endDocument()
    throws SAXException
  {
    if (isPrepared()) {
      fDocument.appendChild(fRootElement);
    }
  }
  
  public void processingInstruction(String target, String data)
    throws SAXException
  {
    if (isPrepared()) {
      fDocument.appendChild(fDocument.createProcessingInstruction(target, data));
    }
  }
  
  public void characters(char[] characters, int start, int length)
    throws SAXException
  {
    if ((fAbbreviated) || (!isPrepared())) {
      return;
    }
    StringBuffer buff = new StringBuffer();
    for (int i = 0; i < length; i++) {
      buff.append(characters[(start + i)]);
    }
    Text text = fDocument.createTextNode(buff.toString());
    if (fRootElement == null) {
      fDocument.appendChild(text);
    } else {
      ((Element)fElementStack.peek()).appendChild(text);
    }
  }
  
  public Node getDocumentElement()
  {
    if (!isPrepared()) {
      return null;
    }
    normalizeDocumentElement();
    return fDocument.getDocumentElement();
  }
  
  public Document getDocument()
  {
    if (!isPrepared()) {
      return null;
    }
    normalizeDocumentElement();
    return fDocument;
  }
  
  public boolean isPrepared()
  {
    return fDocument != null;
  }
  
  private void normalizeDocumentElement()
  {
    if (fDocument.getDocumentElement() != null) {
      fDocument.getDocumentElement().normalize();
    }
  }
  
  public InputSource resolveEntity(String publicId, String systemId)
    throws SAXException
  {
    return new InputSource(new StringReader(""));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.XMLDefaultHandler
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core;

import java.io.IOException;
import java.io.Writer;
import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class XMLPrintHandler
{
  public static final String XML_COMMENT_END_TAG = "-->";
  public static final String XML_COMMENT_BEGIN_TAG = "<!--";
  public static final String XML_HEAD = "<?xml version=\"1.0\" encoding=\"";
  public static final String XML_HEAD_END_TAG = "?>";
  public static final String XML_DBL_QUOTES = "\"";
  public static final String XML_SPACE = " ";
  public static final String XML_BEGIN_TAG = "<";
  public static final String XML_END_TAG = ">";
  public static final String XML_EQUAL = "=";
  public static final String XML_SLASH = "/";
  public static final String XML_INDENT = "   ";
  
  public static String generateIndent(int level)
  {
    StringBuffer buffer = new StringBuffer();
    for (int i = 0; i < level; i++) {
      buffer.append("   ");
    }
    return buffer.toString();
  }
  
  public static void printBeginElement(Writer xmlWriter, String elementString, String indent, boolean terminate)
    throws IOException
  {
    StringBuffer temp = new StringBuffer(indent);
    temp.append("<");
    temp.append(elementString);
    if (terminate) {
      temp.append("/");
    }
    temp.append(">");
    temp.append("\n");
    xmlWriter.write(temp.toString());
  }
  
  public static void printEndElement(Writer xmlWriter, String elementString, String indent)
    throws IOException
  {
    StringBuffer temp = new StringBuffer(indent);
    temp.append("<");
    temp.append("/").append(elementString).append(">").append("\n");
    xmlWriter.write(temp.toString());
  }
  
  public static void printText(Writer xmlWriter, String text, String indent)
    throws IOException
  {
    StringBuffer temp = new StringBuffer(indent);
    temp.append(encode(text).toString());
    temp.append("\n");
    xmlWriter.write(temp.toString());
  }
  
  public static void printComment(Writer xmlWriter, String comment, String indent)
    throws IOException
  {
    StringBuffer temp = new StringBuffer("\n");
    temp.append(indent);
    temp.append("<!--");
    temp.append(encode(comment).toString()).append("-->").append("\n\n");
    xmlWriter.write(temp.toString());
  }
  
  public static void printHead(Writer xmlWriter, String encoding)
    throws IOException
  {
    StringBuffer temp = new StringBuffer("<?xml version=\"1.0\" encoding=\"");
    temp.append(encoding).append("\"").append("?>").append("\n");
    xmlWriter.write(temp.toString());
  }
  
  public static String wrapAttributeForPrint(String attribute, String value)
    throws IOException
  {
    StringBuffer temp = new StringBuffer(" ");
    temp.append(attribute).append("=").append("\"").append(encode(value).toString()).append("\"");
    return temp.toString();
  }
  
  public static String wrapAttribute(String attribute, String value)
  {
    StringBuffer buffer = new StringBuffer(" ");
    buffer.append(attribute);
    buffer.append("=");
    buffer.append("\"");
    buffer.append(value);
    buffer.append("\"");
    return buffer.toString();
  }
  
  public static void printNode(Writer xmlWriter, Node node, String encoding, String indent)
    throws IOException
  {
    if (node == null) {
      return;
    }
    switch (node.getNodeType())
    {
    case 9: 
      printHead(xmlWriter, encoding);
      printNode(xmlWriter, ((Document)node).getDocumentElement(), encoding, indent);
      break;
    case 1: 
      StringBuffer tempElementString = new StringBuffer(node.getNodeName());
      NamedNodeMap attributeList = node.getAttributes();
      if (attributeList != null) {
        for (int i = 0; i < attributeList.getLength(); i++)
        {
          Node attribute = attributeList.item(i);
          tempElementString.append(wrapAttributeForPrint(attribute.getNodeName(), attribute.getNodeValue()));
        }
      }
      NodeList childNodes = node.getChildNodes();
      int length = childNodes.getLength();
      printBeginElement(xmlWriter, tempElementString.toString(), indent, length == 0);
      for (int i = 0; i < length; i++) {
        printNode(xmlWriter, childNodes.item(i), encoding, indent + "\t");
      }
      if (length > 0) {
        printEndElement(xmlWriter, node.getNodeName(), indent);
      }
      break;
    case 3: 
      xmlWriter.write(encode(node.getNodeValue()).toString());
      break;
    default: 
      throw new UnsupportedOperationException("Unsupported XML Node Type.");
    }
  }
  
  public static StringBuffer encode(String value)
  {
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < value.length(); i++)
    {
      char c = value.charAt(i);
      switch (c)
      {
      case '&': 
        buf.append("&amp;");
        break;
      case '<': 
        buf.append("&lt;");
        break;
      case '>': 
        buf.append("&gt;");
        break;
      case '\'': 
        buf.append("&apos;");
        break;
      case '"': 
        buf.append("&quot;");
        break;
      default: 
        buf.append(c);
      }
    }
    return buf;
  }
  
  /* Error */
  public static void writeFile(Document doc, java.io.File file)
    throws IOException
  {
    // Byte code:
    //   0: aconst_null
    //   1: astore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: new 128	java/io/FileOutputStream
    //   7: dup
    //   8: aload_1
    //   9: invokespecial 196	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   12: astore_3
    //   13: new 131	java/io/OutputStreamWriter
    //   16: dup
    //   17: aload_3
    //   18: ldc 21
    //   20: invokespecial 198	java/io/OutputStreamWriter:<init>	(Ljava/io/OutputStream;Ljava/lang/String;)V
    //   23: astore_2
    //   24: aload_2
    //   25: aload_0
    //   26: ldc 21
    //   28: ldc 1
    //   30: invokestatic 216	org/eclipse/pde/internal/core/XMLPrintHandler:printNode	(Ljava/io/Writer;Lorg/w3c/dom/Node;Ljava/lang/String;Ljava/lang/String;)V
    //   33: goto +32 -> 65
    //   36: astore 4
    //   38: aload_2
    //   39: ifnull +11 -> 50
    //   42: aload_2
    //   43: invokevirtual 199	java/io/Writer:close	()V
    //   46: goto +4 -> 50
    //   49: pop
    //   50: aload_3
    //   51: ifnull +11 -> 62
    //   54: aload_3
    //   55: invokevirtual 197	java/io/OutputStream:close	()V
    //   58: goto +4 -> 62
    //   61: pop
    //   62: aload 4
    //   64: athrow
    //   65: aload_2
    //   66: ifnull +11 -> 77
    //   69: aload_2
    //   70: invokevirtual 199	java/io/Writer:close	()V
    //   73: goto +4 -> 77
    //   76: pop
    //   77: aload_3
    //   78: ifnull +11 -> 89
    //   81: aload_3
    //   82: invokevirtual 197	java/io/OutputStream:close	()V
    //   85: goto +4 -> 89
    //   88: pop
    //   89: return
    // Line number table:
    //   Java source line #184	-> byte code offset #0
    //   Java source line #185	-> byte code offset #2
    //   Java source line #187	-> byte code offset #4
    //   Java source line #188	-> byte code offset #13
    //   Java source line #189	-> byte code offset #24
    //   Java source line #190	-> byte code offset #36
    //   Java source line #192	-> byte code offset #38
    //   Java source line #193	-> byte code offset #42
    //   Java source line #194	-> byte code offset #49
    //   Java source line #197	-> byte code offset #50
    //   Java source line #198	-> byte code offset #54
    //   Java source line #199	-> byte code offset #61
    //   Java source line #201	-> byte code offset #62
    //   Java source line #192	-> byte code offset #65
    //   Java source line #193	-> byte code offset #69
    //   Java source line #194	-> byte code offset #76
    //   Java source line #197	-> byte code offset #77
    //   Java source line #198	-> byte code offset #81
    //   Java source line #199	-> byte code offset #88
    //   Java source line #202	-> byte code offset #89
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	90	0	doc	Document
    //   0	90	1	file	java.io.File
    //   1	69	2	writer	Writer
    //   3	79	3	out	java.io.OutputStream
    //   36	27	4	localObject	Object
    //   49	1	5	localIOException1	IOException
    //   61	1	6	localIOException2	IOException
    //   76	1	7	localIOException3	IOException
    //   88	1	8	localIOException4	IOException
    // Exception table:
    //   from	to	target	type
    //   4	36	36	finally
    //   38	46	49	java/io/IOException
    //   50	58	61	java/io/IOException
    //   65	73	76	java/io/IOException
    //   77	85	88	java/io/IOException
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.XMLPrintHandler
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.build;

import java.io.PrintWriter;
import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.core.ModelChangedEvent;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.build.IBuildModelFactory;

public class Build
  extends BuildObject
  implements IBuild
{
  protected ArrayList fEntries = new ArrayList();
  
  public void add(IBuildEntry entry)
    throws CoreException
  {
    ensureModelEditable();
    fEntries.add(entry);
    ((BuildEntry)entry).setInTheModel(true);
    getModel().fireModelChanged(new ModelChangedEvent(getModel(), 1, new Object[] { entry }, null));
  }
  
  public IBuildEntry[] getBuildEntries()
  {
    return (IBuildEntry[])fEntries.toArray(new IBuildEntry[fEntries.size()]);
  }
  
  public IBuildEntry getEntry(String name)
  {
    for (int i = 0; i < fEntries.size(); i++)
    {
      IBuildEntry entry = (IBuildEntry)fEntries.get(i);
      if (entry.getName().equals(name)) {
        return entry;
      }
    }
    return null;
  }
  
  public void processEntry(String name, String value)
  {
    BuildEntry entry = (BuildEntry)getModel().getFactory().createEntry(name);
    fEntries.add(entry);
    entry.processEntry(value);
  }
  
  public void remove(IBuildEntry entry)
    throws CoreException
  {
    ensureModelEditable();
    fEntries.remove(entry);
    getModel().fireModelChanged(new ModelChangedEvent(getModel(), 2, new Object[] { entry }, null));
  }
  
  public void reset()
  {
    fEntries.clear();
  }
  
  public void write(String indent, PrintWriter writer)
  {
    for (int i = 0; i < fEntries.size(); i++)
    {
      IBuildEntry entry = (IBuildEntry)fEntries.get(i);
      entry.write("", writer);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.build.Build
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.build;

import java.io.PrintWriter;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.util.Vector;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.pde.core.ModelChangedEvent;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.internal.core.project.PDEProject;
import org.eclipse.pde.internal.core.util.PropertiesUtil;

public class BuildEntry
  extends BuildObject
  implements IBuildEntry
{
  private Vector tokens = new Vector();
  private String name;
  
  public BuildEntry(String name)
  {
    this.name = name;
  }
  
  public void addToken(String token)
    throws CoreException
  {
    ensureModelEditable();
    tokens.add(token);
    getModel().fireModelChanged(new ModelChangedEvent(getModel(), 1, new Object[] { token }, null));
  }
  
  public String getName()
  {
    return name;
  }
  
  public String[] getTokens()
  {
    String[] result = new String[tokens.size()];
    tokens.copyInto(result);
    return result;
  }
  
  public boolean contains(String token)
  {
    return tokens.contains(token);
  }
  
  void processEntry(String value)
  {
    IPath rootPath = getRootPath();
    StringTokenizer stok = new StringTokenizer(value, ",");
    while (stok.hasMoreTokens())
    {
      String token = stok.nextToken();
      token = token.trim();
      token = fromRelative(token, rootPath);
      tokens.add(token);
    }
  }
  
  public void removeToken(String token)
    throws CoreException
  {
    ensureModelEditable();
    tokens.remove(token);
    getModel().fireModelChanged(new ModelChangedEvent(getModel(), 2, new Object[] { token }, null));
  }
  
  public void renameToken(String oldName, String newName)
    throws CoreException
  {
    ensureModelEditable();
    for (int i = 0; i < tokens.size(); i++) {
      if (tokens.elementAt(i).toString().equals(oldName))
      {
        tokens.setElementAt(newName, i);
        break;
      }
    }
    getModel().fireModelChanged(new ModelChangedEvent(getModel(), 3, new Object[] { oldName }, null));
  }
  
  public void setName(String name)
    throws CoreException
  {
    ensureModelEditable();
    String oldValue = this.name;
    this.name = name;
    getModel().fireModelObjectChanged(this, "name", oldValue, name);
  }
  
  public String toString()
  {
    return name + " = " + tokens;
  }
  
  public void write(String indent, PrintWriter writer)
  {
    Enumeration elements = tokens.elements();
    IPath rootPath = getRootPath();
    if (rootPath != null)
    {
      Vector vector = new Vector();
      while (elements.hasMoreElements())
      {
        String e = (String)elements.nextElement();
        vector.add(toRelative(e, rootPath));
      }
      elements = vector.elements();
    }
    PropertiesUtil.writeKeyValuePair(indent, name, elements, writer);
  }
  
  public void restoreProperty(String name, Object oldValue, Object newValue)
    throws CoreException
  {
    if (name.equals("name")) {
      setName(newValue != null ? newValue.toString() : null);
    }
  }
  
  IPath getRootPath()
  {
    if ((name.startsWith("source.")) || (name.startsWith("output.")))
    {
      IResource resource = getModel().getUnderlyingResource();
      if (resource != null)
      {
        IProject project = resource.getProject();
        if (project != null)
        {
          IContainer root = PDEProject.getBundleRoot(project);
          if ((root != null) && (!root.equals(project))) {
            return root.getProjectRelativePath();
          }
        }
      }
    }
    return null;
  }
  
  String toRelative(String token, IPath root)
  {
    if (root == null) {
      return token;
    }
    return new Path(token).makeRelativeTo(root).toPortableString();
  }
  
  String fromRelative(String token, IPath root)
  {
    if (root == null) {
      return token;
    }
    return root.append(new Path(token)).toPortableString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.build.BuildEntry
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.build;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.Properties;
import org.eclipse.pde.core.ModelChangedEvent;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.build.IBuildModelFactory;
import org.eclipse.pde.internal.core.AbstractModel;
import org.eclipse.pde.internal.core.PDECore;

public abstract class BuildModel
  extends AbstractModel
  implements IBuildModel
{
  private static final long serialVersionUID = 1L;
  protected Build fBuild;
  private BuildModelFactory fFactory;
  
  public IBuild getBuild()
  {
    if (!isLoaded()) {
      load();
    }
    return fBuild;
  }
  
  public IBuild getBuild(boolean createIfMissing)
  {
    if ((fBuild == null) && (createIfMissing))
    {
      fBuild = new Build();
      fBuild.setModel(this);
      setLoaded(true);
    }
    return getBuild();
  }
  
  public IBuildModelFactory getFactory()
  {
    if (fFactory == null) {
      fFactory = new BuildModelFactory(this);
    }
    return fFactory;
  }
  
  public abstract void load();
  
  public void load(InputStream source, boolean outOfSync)
  {
    Properties properties = new Properties();
    try
    {
      properties.load(source);
      if (!outOfSync) {
        updateTimeStamp();
      }
    }
    catch (IOException e)
    {
      PDECore.logException(e);
      return;
    }
    fBuild = new Build();
    fBuild.setModel(this);
    for (Enumeration names = properties.propertyNames(); names.hasMoreElements();)
    {
      String name = names.nextElement().toString();
      fBuild.processEntry(name, (String)properties.get(name));
    }
    setLoaded(true);
  }
  
  public void reload(InputStream source, boolean outOfSync)
  {
    if (fBuild != null)
    {
      fBuild.reset();
    }
    else
    {
      fBuild = new Build();
      fBuild.setModel(this);
    }
    load(source, outOfSync);
    fireModelChanged(new ModelChangedEvent(this, 99, new Object[0], null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.build.BuildModel
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.core.build;

import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.build.IBuildModelFactory;

public class BuildModelFactory
  implements IBuildModelFactory
{
  private IBuildModel model;
  
  public BuildModelFactory(IBuildModel model)
  {
    this.model = model;
  }
  
  public IBuildEntry createEntry(String name)
  {
    BuildEntry entry = new BuildEntry(name);
    entry.setModel(model);
    return entry;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.core.build.BuildModelFactory
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclips
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

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