org.eclipse.pde.core_3.7.1.v20120103_r372

c boolean hasFriend(String name)
  {
    return fFriends.containsKey(name);
  }
  
  public boolean hasSameVisibility(ExportPackageObject object)
  {
    if (object.isInternal() != isInternal()) {
      return false;
    }
    if (fFriends.size() != fFriends.size()) {
      return false;
    }
    Iterator iter = fFriends.keySet().iterator();
    while (iter.hasNext()) {
      if (!fFriends.containsKey(iter.next())) {
        return false;
      }
    }
    return true;
  }
  
  public void setUsesDirective(String value)
  {
    String oldValue = getUsesDirective();
    setDirective("uses", value);
    fHeader.update();
    firePropertyChanged(this, "uses", oldValue, value);
  }
  
  public String getUsesDirective()
  {
    return getDirective("uses");
  }
  
  protected void appendValuesToBuffer(StringBuffer sb, TreeMap table)
  {
    if (table == null) {
      return;
    }
    Object usesValue = null;
    if (table.containsKey("uses")) {
      usesValue = table.remove("uses");
    }
    Object friendsValue = null;
    if (table.containsKey("x-friends")) {
      friendsValue = table.remove("x-friends");
    }
    super.appendValuesToBuffer(sb, table);
    
    int newLineLimit = 3;
    if ((friendsValue != null) && (usesValue != null)) {
      newLineLimit = 1;
    }
    if (friendsValue != null)
    {
      table.put("x-friends", friendsValue);
      formatDirective("x-friends", sb, friendsValue, newLineLimit);
    }
    if (usesValue != null)
    {
      table.put("uses", usesValue);
      formatDirective("uses", sb, usesValue, newLineLimit);
    }
  }
  
  private void formatDirective(String directiveName, StringBuffer sb, Object usesValue, int newLineLimit)
  {
    StringTokenizer tokenizer = null;
    
    boolean newLine = false;
    if ((usesValue instanceof String))
    {
      tokenizer = new StringTokenizer((String)usesValue, ",");
      if (tokenizer.countTokens() > newLineLimit) {
        newLine = true;
      }
    }
    else if ((usesValue instanceof List))
    {
      List usesList = (List)usesValue;
      if (usesList.size() > newLineLimit) {
        newLine = true;
      }
    }
    else
    {
      Object foo = usesValue;
      
      foo.getClass();
      
      return;
    }
    String EOL = getHeader().getLineLimiter();
    
    sb.append(';');
    if (newLine) {
      sb.append(EOL).append("  ");
    }
    sb.append(directiveName);
    sb.append(":=\"");
    if (tokenizer != null)
    {
      while (tokenizer.hasMoreTokens())
      {
        sb.append(tokenizer.nextToken());
        if (tokenizer.hasMoreTokens())
        {
          sb.append(',');
          if (newLine) {
            sb.append(EOL).append("   ");
          }
        }
      }
    }
    else
    {
      List usesList = (List)usesValue;
      
      ListIterator iterator = usesList.listIterator();
      for (;;)
      {
        sb.append(iterator.next());
        if (!iterator.hasNext()) {
          break;
        }
        sb.append(',');
        if (newLine) {
          sb.append(EOL).append("   ");
        }
      }
    }
    sb.append("\"");
  }
  
  public void write(String indent, PrintWriter writer)
  {
    writer.write(write());
  }
  
  public void reconnect(IBundleModel model, ExportPackageHeader header, String versionAttribute)
  {
    super.reconnect(model, header, versionAttribute);
    
    reconnectFriends();
  }
  
  private void reconnectFriends()
  {
    Iterator keys = fFriends.keySet().iterator();
    while (keys.hasNext())
    {
      String key = (String)keys.next();
      PackageFriend friend = (PackageFriend)fFriends.get(key);
      friend.reconnect(this);
    }
  }
}

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

import org.eclipse.osgi.service.resolver.VersionRange;
import org.eclipse.pde.internal.core.ibundle.IBundle;

public class FragmentHostHeader
  extends SingleManifestHeader
{
  private static final long serialVersionUID = 1L;
  
  public FragmentHostHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  public void setHostId(String id)
  {
    setMainComponent(id);
  }
  
  public String getHostId()
  {
    return getMainComponent();
  }
  
  public void setHostRange(String range)
  {
    setAttribute("bundle-version", range);
  }
  
  public VersionRange getHostRange()
  {
    return new VersionRange(getAttribute("bundle-version"));
  }
}

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

import java.util.Map;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.ibundle.IBundle;

public class ImportPackageHeader
  extends BasePackageHeader
{
  private static final long serialVersionUID = 1L;
  
  public ImportPackageHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  protected PDEManifestElement createElement(ManifestElement element)
  {
    return new ImportPackageObject(this, element, getVersionAttribute());
  }
  
  public ImportPackageObject getPackage(String packageName)
  {
    return fElementMap == null ? null : (ImportPackageObject)fElementMap.get(packageName);
  }
  
  public ImportPackageObject[] getPackages()
  {
    PDEManifestElement[] elements = getElements();
    ImportPackageObject[] result = new ImportPackageObject[elements.length];
    System.arraycopy(elements, 0, result, 0, elements.length);
    return result;
  }
  
  public ImportPackageObject addPackage(String id)
  {
    ImportPackageObject obj = new ImportPackageObject(this, id, null, getVersionAttribute());
    addManifestElement(obj);
    return obj;
  }
}

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

import java.io.PrintWriter;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.bundle.BundlePluginBase;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.osgi.framework.Version;

public class ImportPackageObject
  extends PackageObject
{
  private static final long serialVersionUID = 1L;
  
  private static String getVersion(ExportPackageDescription desc)
  {
    String version = desc.getVersion().toString();
    if (!version.equals(Version.emptyVersion.toString())) {
      return desc.getVersion().toString();
    }
    return null;
  }
  
  public ImportPackageObject(ManifestHeader header, ManifestElement element, String versionAttribute)
  {
    super(header, element, versionAttribute);
  }
  
  public ImportPackageObject(ManifestHeader header, ExportPackageDescription desc, String versionAttribute)
  {
    super(header, desc.getName(), getVersion(desc), versionAttribute);
  }
  
  public ImportPackageObject(ManifestHeader header, String id, String version, String versionAttribute)
  {
    super(header, id, version, versionAttribute);
  }
  
  public boolean isOptional()
  {
    int manifestVersion = BundlePluginBase.getBundleManifestVersion(getHeader().getBundle());
    if (manifestVersion > 1) {
      return "optional".equals(getDirective("resolution"));
    }
    return "true".equals(getAttribute("optional"));
  }
  
  public void setOptional(boolean optional)
  {
    boolean old = isOptional();
    int manifestVersion = BundlePluginBase.getBundleManifestVersion(getHeader().getBundle());
    if (optional)
    {
      if (manifestVersion > 1) {
        setDirective("resolution", "optional");
      } else {
        setAttribute("optional", "true");
      }
    }
    else
    {
      setDirective("resolution", null);
      setAttribute("optional", null);
    }
    fHeader.update();
    firePropertyChanged(this, "resolution", Boolean.toString(old), Boolean.toString(optional));
  }
  
  public void reconnect(IBundleModel model, ImportPackageHeader header, String versionAttribute)
  {
    super.reconnect(model, header, versionAttribute);
  }
  
  public void write(String indent, PrintWriter writer)
  {
    writer.write(write());
  }
  
  public void restoreProperty(String propertyName, Object oldValue, Object newValue)
  {
    if ("resolution".equalsIgnoreCase(propertyName)) {
      setOptional(new Boolean(newValue.toString()).booleanValue());
    } else if ((fVersionAttribute != null) && (fVersionAttribute.equalsIgnoreCase(propertyName))) {
      setVersion(newValue.toString());
    }
  }
}

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

import org.eclipse.pde.internal.core.ibundle.IBundle;

public class LazyStartHeader
  extends SingleManifestHeader
{
  private static final long serialVersionUID = 1L;
  
  public LazyStartHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  public boolean isLazyStart()
  {
    return "true".equals(getMainComponent());
  }
  
  public void setLazyStart(boolean lazy)
  {
    setMainComponent(Boolean.toString(lazy));
  }
}

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

import java.io.PrintWriter;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.pde.internal.core.bundle.BundleObject;
import org.eclipse.pde.internal.core.bundle.BundlePluginBase;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
import org.eclipse.pde.internal.core.text.IEditingModel;

public class ManifestHeader
  extends BundleObject
  implements IManifestHeader
{
  private static final long serialVersionUID = 1L;
  private int fOffset = -1;
  private int fLength = -1;
  protected String fName;
  protected String fValue;
  protected transient IBundle fBundle;
  protected String fLineDelimiter;
  
  public ManifestHeader() {}
  
  public ManifestHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    fName = name;
    fBundle = bundle;
    fLineDelimiter = lineDelimiter;
    processValue(value);
    setModel(fBundle.getModel());
  }
  
  protected void processValue(String value)
  {
    fValue = value;
  }
  
  public String getLineLimiter()
  {
    return fLineDelimiter;
  }
  
  public void setName(String name)
  {
    fName = name;
  }
  
  public String getName()
  {
    return fName;
  }
  
  public String getValue()
  {
    return fValue;
  }
  
  public void setValue(String value)
  {
    String old = fValue;
    fValue = value;
    fBundle.getModel().fireModelObjectChanged(this, getName(), old, value);
  }
  
  public void setOffset(int offset)
  {
    fOffset = offset;
  }
  
  public int getOffset()
  {
    return fOffset;
  }
  
  public void setLength(int length)
  {
    fLength = length;
  }
  
  public int getLength()
  {
    return fLength;
  }
  
  public String write()
  {
    StringBuffer sb = new StringBuffer(fName);
    sb.append(": ");
    try
    {
      if (fOffset != -1)
      {
        IBundleModel model = fBundle.getModel();
        if ((model instanceof IEditingModel))
        {
          IDocument doc = ((IEditingModel)model).getDocument();
          int line = doc.getLineOfOffset(fOffset);
          String text = doc.get(fOffset, doc.getLineLength(line)).trim();
          if (text.length() == fName.length() + 1)
          {
            sb.append(fLineDelimiter);
            sb.append(" ");
          }
        }
      }
    }
    catch (BadLocationException localBadLocationException) {}
    sb.append(getValue());
    sb.append(fLineDelimiter);
    return sb.toString();
  }
  
  public void write(String indent, PrintWriter writer) {}
  
  public void setBundle(IBundle bundle)
  {
    fBundle = bundle;
  }
  
  public IBundle getBundle()
  {
    return fBundle;
  }
  
  public String getKey()
  {
    return getName();
  }
  
  public void setKey(String key)
    throws CoreException
  {
    setName(key);
  }
  
  protected int getManifestVersion()
  {
    return BundlePluginBase.getBundleManifestVersion(fBundle);
  }
  
  public void update() {}
  
  public void update(boolean notify) {}
}

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

import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeMap;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.bundle.BundleObject;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.osgi.framework.BundleException;

public class PDEManifestElement
  extends BundleObject
{
  private static final long serialVersionUID = 1L;
  protected String[] fValueComponents;
  protected TreeMap fAttributes;
  protected TreeMap fDirectives;
  protected transient ManifestHeader fHeader;
  
  public PDEManifestElement(ManifestHeader header, String value)
  {
    setHeader(header);
    setValue(value);
    setModel(fHeader.getBundle().getModel());
  }
  
  protected PDEManifestElement(ManifestHeader header, ManifestElement manifestElement)
  {
    setHeader(header);
    init(manifestElement);
    setModel(fHeader.getBundle().getModel());
  }
  
  public String[] getValueComponents()
  {
    return fValueComponents;
  }
  
  protected void setValueComponents(String[] valueComponents)
  {
    fValueComponents = valueComponents;
  }
  
  public String[] getAttributes(String key)
  {
    return getTableValues(fAttributes, key);
  }
  
  public String getAttribute(String key)
  {
    return getTableValue(fAttributes, key);
  }
  
  public Set getKeys()
  {
    return getTableKeys(fAttributes);
  }
  
  public void addAttribute(String key, String value)
  {
    fAttributes = addTableValue(fAttributes, key, value);
  }
  
  public void setAttribute(String key, String value)
  {
    fAttributes = setTableValue(fAttributes, key, value);
  }
  
  public String getDirective(String key)
  {
    return getTableValue(fDirectives, key);
  }
  
  public String[] getDirectives(String key)
  {
    return getTableValues(fDirectives, key);
  }
  
  public Set getDirectiveKeys()
  {
    return getTableKeys(fDirectives);
  }
  
  public void addDirective(String key, String value)
  {
    fDirectives = addTableValue(fDirectives, key, value);
  }
  
  public void setDirective(String key, String value)
  {
    fDirectives = setTableValue(fDirectives, key, value);
  }
  
  private String getTableValue(TreeMap table, String key)
  {
    if (table == null) {
      return null;
    }
    Object result = table.get(key);
    if (result == null) {
      return null;
    }
    if ((result instanceof String)) {
      return (String)result;
    }
    ArrayList valueList = (ArrayList)result;
    
    return (String)valueList.get(valueList.size() - 1);
  }
  
  private String[] getTableValues(TreeMap table, String key)
  {
    if (table == null) {
      return null;
    }
    Object result = table.get(key);
    if (result == null) {
      return null;
    }
    if ((result instanceof String)) {
      return new String[] { (String)result };
    }
    ArrayList valueList = (ArrayList)result;
    return (String[])valueList.toArray(new String[valueList.size()]);
  }
  
  private Set getTableKeys(TreeMap table)
  {
    if (table == null) {
      return null;
    }
    return table.keySet();
  }
  
  private TreeMap addTableValue(TreeMap table, String key, String value)
  {
    if (table == null) {
      table = new TreeMap();
    }
    Object curValue = table.get(key);
    if (curValue != null)
    {
      ArrayList newList;
      ArrayList newList;
      if ((curValue instanceof ArrayList))
      {
        newList = (ArrayList)curValue;
      }
      else
      {
        newList = new ArrayList(5);
        newList.add(curValue);
      }
      newList.add(value);
      table.put(key, newList);
    }
    else
    {
      table.put(key, value);
    }
    return table;
  }
  
  private TreeMap setTableValue(TreeMap table, String key, String value)
  {
    if (table == null) {
      table = new TreeMap();
    }
    if ((value == null) || (value.trim().length() == 0)) {
      table.remove(key);
    } else {
      table.put(key, value);
    }
    return table;
  }
  
  public void setValue(String value)
  {
    if (value == null)
    {
      setValueComponents(new String[0]);
      return;
    }
    try
    {
      ManifestElement[] elements = ManifestElement.parseHeader(fHeader.fName, value);
      if ((elements != null) && (elements.length > 0)) {
        init(elements[0]);
      }
    }
    catch (BundleException localBundleException) {}
  }
  
  private void init(ManifestElement manifestElement)
  {
    setValueComponents(manifestElement.getValueComponents());
    Enumeration attKeys = manifestElement.getKeys();
    if (attKeys != null)
    {
      String[] values;
      int i;
      for (; attKeys.hasMoreElements(); i < values.length)
      {
        String attKey = (String)attKeys.nextElement();
        values = ManifestElement.getArrayFromList(manifestElement.getAttribute(attKey));
        i = 0; continue;
        addAttribute(attKey, values[i]);i++;
      }
    }
    Enumeration dirKeys = manifestElement.getDirectiveKeys();
    if (dirKeys != null)
    {
      String[] values;
      int i;
      for (; dirKeys.hasMoreElements(); i < values.length)
      {
        String dirKey = (String)dirKeys.nextElement();
        values = ManifestElement.getArrayFromList(manifestElement.getDirective(dirKey));
        i = 0; continue;
        addDirective(dirKey, values[i]);i++;
      }
    }
  }
  
  public String write()
  {
    StringBuffer sb = new StringBuffer(getValue());
    appendValuesToBuffer(sb, fAttributes);
    appendValuesToBuffer(sb, fDirectives);
    return sb.toString();
  }
  
  public String getValue()
  {
    StringBuffer sb = new StringBuffer();
    if (fValueComponents == null) {
      return "";
    }
    for (int i = 0; i < fValueComponents.length; i++)
    {
      if (i != 0) {
        sb.append("; ");
      }
      sb.append(fValueComponents[i]);
    }
    return sb.toString();
  }
  
  protected void appendValuesToBuffer(StringBuffer sb, TreeMap table)
  {
    if (table == null) {
      return;
    }
    Iterator dkeys = table.keySet().iterator();
    while (dkeys.hasNext())
    {
      String dkey = (String)dkeys.next();
      Object value = table.get(dkey);
      if (value != null)
      {
        sb.append(";");
        sb.append(dkey);
        sb.append(table.equals(fDirectives) ? ":=" : "=");
        if ((value instanceof String))
        {
          boolean wrap = shouldWrap(value.toString());
          if (wrap) {
            sb.append("\"");
          }
          sb.append(value);
          if (wrap) {
            sb.append("\"");
          }
        }
        else if ((value instanceof ArrayList))
        {
          ArrayList values = (ArrayList)value;
          boolean wrap = (values.size() > 1) || ((values.size() == 1) && (shouldWrap(values.get(0).toString())));
          if (wrap) {
            sb.append("\"");
          }
          for (int i = 0; i < values.size(); i++)
          {
            if (i != 0) {
              sb.append(",");
            }
            sb.append(values.get(i));
          }
          if (wrap) {
            sb.append("\"");
          }
        }
      }
    }
  }
  
  private boolean shouldWrap(String value)
  {
    return (value.indexOf(' ') != -1) || (value.indexOf(',') != -1) || (value.indexOf('.') != -1) || (value.indexOf('[') != -1) || (value.indexOf('(') != -1);
  }
  
  public ManifestHeader getHeader()
  {
    return fHeader;
  }
  
  public void setHeader(ManifestHeader header)
  {
    fHeader = header;
  }
  
  public void reconnect(IBundleModel model, ManifestHeader header)
  {
    super.reconnect(model);
    
    fHeader = header;
  }
}

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

import java.io.PrintWriter;
import org.eclipse.pde.internal.core.bundle.BundleObject;

public class PackageFriend
  extends BundleObject
{
  private static final long serialVersionUID = 1L;
  private String fName;
  private transient PackageObject fPackageObject;
  
  public PackageFriend(PackageObject object, String name)
  {
    fName = name;
    fPackageObject = object;
  }
  
  public String getName()
  {
    return fName;
  }
  
  public String toString()
  {
    return fName;
  }
  
  public ManifestHeader getHeader()
  {
    return fPackageObject.getHeader();
  }
  
  public void reconnect(PackageObject object)
  {
    fPackageObject = object;
  }
  
  public void writeDelimeter(PrintWriter writer)
  {
    writer.print(',');
  }
}

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

import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;

public class PackageObject
  extends PDEManifestElement
{
  private static final long serialVersionUID = 1L;
  protected transient String fVersionAttribute;
  
  public PackageObject(ManifestHeader header, ManifestElement element, String versionAttribute)
  {
    super(header, element);
    fVersionAttribute = versionAttribute;
  }
  
  public PackageObject(ManifestHeader header, String name, String version, String versionAttribute)
  {
    super(header, name.length() > 0 ? name : ".");
    fVersionAttribute = versionAttribute;
    if (version != null) {
      addAttribute(fVersionAttribute, version);
    }
  }
  
  public String toString()
  {
    StringBuffer buffer = new StringBuffer(getValue());
    String version = getVersion();
    if ((version != null) && (version.length() > 0))
    {
      buffer.append(" ");
      boolean wrap = Character.isDigit(version.charAt(0));
      if (wrap) {
        buffer.append("(");
      }
      buffer.append(version);
      if (wrap) {
        buffer.append(")");
      }
    }
    return buffer.toString();
  }
  
  public String getVersion()
  {
    String[] version = getAttributes(fVersionAttribute);
    if ((version == null) || (version.length == 0)) {
      return null;
    }
    if (version.length == 1) {
      return version[0];
    }
    return version[0] + ',' + version[1];
  }
  
  public String getName()
  {
    return getValue();
  }
  
  public void setName(String name)
  {
    setValueComponents(new String[] { name });
  }
  
  public void setVersion(String version)
  {
    String old = getVersion();
    setAttribute(fVersionAttribute, version);
    fHeader.update();
    firePropertyChanged(this, fVersionAttribute, old, version);
  }
  
  public void reconnect(IBundleModel model, ManifestHeader header, String versionAttribute)
  {
    super.reconnect(model, header);
    
    fVersionAttribute = versionAttribute;
  }
}

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

import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.core.plugin.IPluginImport;
import org.eclipse.pde.internal.core.bundle.BundlePluginBase;
import org.eclipse.pde.internal.core.ibundle.IBundle;

public class RequireBundleHeader
  extends CompositeManifestHeader
{
  private static final long serialVersionUID = 1L;
  
  public RequireBundleHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  public void addBundle(IPluginImport iimport)
  {
    addBundle(iimport.getId(), iimport.getVersion(), iimport.isReexported(), iimport.isOptional());
  }
  
  public void addBundle(IPluginImport iimport, int index)
  {
    String id = iimport.getId();
    String version = iimport.getVersion();
    boolean exported = iimport.isReexported();
    boolean optional = iimport.isOptional();
    
    RequireBundleObject element = new RequireBundleObject(this, id);
    
    configureBundle(version, exported, optional, element);
    
    addManifestElement(element, index, true);
  }
  
  public void addBundle(String id)
  {
    addBundle(id, null, false, false);
  }
  
  public void addBundle(String id, String version, boolean exported, boolean optional)
  {
    RequireBundleObject element = new RequireBundleObject(this, id);
    configureBundle(version, exported, optional, element);
    addManifestElement(element);
  }
  
  private void configureBundle(String version, boolean exported, boolean optional, RequireBundleObject element)
  {
    int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(getBundle());
    if (optional) {
      if (bundleManifestVersion > 1) {
        element.setDirective("resolution", "optional");
      } else {
        element.setAttribute("optional", "true");
      }
    }
    if (exported) {
      if (bundleManifestVersion > 1) {
        element.setDirective("visibility", "reexport");
      } else {
        element.setAttribute("reprovide", "true");
      }
    }
    if ((version != null) && (version.trim().length() > 0)) {
      element.setAttribute("bundle-version", version.trim());
    }
  }
  
  public void removeBundle(String id)
  {
    removeManifestElement(id);
  }
  
  public void removeBundle(RequireBundleObject bundle)
  {
    removeManifestElement(bundle);
  }
  
  protected PDEManifestElement createElement(ManifestElement element)
  {
    return new RequireBundleObject(this, element);
  }
  
  public void updateBundle(int index, IPluginImport iimport)
  {
    if (index == -1) {
      return;
    }
    PDEManifestElement element = getElementAt(index);
    if (element != null)
    {
      element.setValue(iimport.getId());
      
      int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(getBundle());
      if (iimport.isOptional())
      {
        if (bundleManifestVersion > 1) {
          element.setDirective("resolution", "optional");
        } else {
          element.setAttribute("optional", "true");
        }
      }
      else if (bundleManifestVersion > 1) {
        element.setDirective("resolution", null);
      } else {
        element.setAttribute("optional", null);
      }
      if (iimport.isReexported())
      {
        if (bundleManifestVersion > 1) {
          element.setDirective("visibility", "reexport");
        } else {
          element.setAttribute("reprovide", "true");
        }
      }
      else if (bundleManifestVersion > 1) {
        element.setDirective("visibility", null);
      } else {
        element.setAttribute("reprovide", null);
      }
      element.setAttribute("bundle-version", iimport.getVersion());
    }
    update(true);
  }
  
  public RequireBundleObject[] getRequiredBundles()
  {
    PDEManifestElement[] elements = getElements();
    RequireBundleObject[] result = new RequireBundleObject[elements.length];
    System.arraycopy(elements, 0, result, 0, elements.length);
    return result;
  }
}

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

import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.bundle.BundlePluginBase;

public class RequireBundleObject
  extends PDEManifestElement
{
  private static final long serialVersionUID = 1L;
  
  public RequireBundleObject(ManifestHeader header, String value)
  {
    super(header, value);
  }
  
  public RequireBundleObject(ManifestHeader header, ManifestElement manifestElement)
  {
    super(header, manifestElement);
  }
  
  public void setId(String id)
  {
    String old = getId();
    setValue(id);
    fHeader.update();
    firePropertyChanged(this, fHeader.getName(), old, id);
  }
  
  public String getId()
  {
    return getValue();
  }
  
  public void setVersion(String version)
  {
    String old = getVersion();
    
    setAttribute("bundle-version", null);
    
    String[] values = ManifestElement.getArrayFromList(version);
    if ((values != null) && (values.length > 0)) {
      for (int i = 0; i < values.length; i++) {
        addAttribute("bundle-version", values[i]);
      }
    }
    fHeader.update();
    firePropertyChanged(this, "bundle-version", old, version);
  }
  
  public String getVersion()
  {
    String[] versionSegments = getAttributes("bundle-version");
    StringBuffer version = new StringBuffer();
    if (versionSegments == null) {
      return null;
    }
    if (versionSegments.length == 0) {
      return null;
    }
    if (versionSegments.length == 1)
    {
      version.append(versionSegments[0]);
    }
    else if (versionSegments.length == 2)
    {
      version.append(versionSegments[0]);
      version.append(',');
      version.append(versionSegments[1]);
    }
    return version.toString();
  }
  
  public void setOptional(boolean optional)
  {
    boolean old = isOptional();
    int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(fHeader.getBundle());
    if (optional)
    {
      if (bundleManifestVersion > 1) {
        setDirective("resolution", "optional");
      } else {
        setAttribute("optional", "true");
      }
    }
    else if (bundleManifestVersion > 1) {
      setDirective("resolution", null);
    } else {
      setAttribute("optional", null);
    }
    fHeader.update();
    firePropertyChanged(this, "resolution", Boolean.toString(old), Boolean.toString(optional));
  }
  
  public boolean isOptional()
  {
    int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(fHeader.getBundle());
    if (bundleManifestVersion > 1) {
      return "optional".equals(getDirective("resolution"));
    }
    return "true".equals(getAttribute("optional"));
  }
  
  public void setReexported(boolean export)
  {
    boolean old = isReexported();
    int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(fHeader.getBundle());
    if (export)
    {
      if (bundleManifestVersion > 1) {
        setDirective("visibility", "reexport");
      } else {
        setAttribute("reprovide", "true");
      }
    }
    else if (bundleManifestVersion > 1) {
      setDirective("visibility", null);
    } else {
      setAttribute("reprovide", null);
    }
    fHeader.update();
    firePropertyChanged(this, "visibility", Boolean.toString(old), Boolean.toString(export));
  }
  
  public boolean isReexported()
  {
    int bundleManifestVersion = BundlePluginBase.getBundleManifestVersion(fHeader.getBundle());
    if (bundleManifestVersion > 1) {
      return "reexport".equals(getDirective("visibility"));
    }
    return "true".equals(getAttribute("reprovide"));
  }
}

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

import java.util.ArrayList;
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.ibundle.IBundle;

public class RequiredExecutionEnvironmentHeader
  extends CompositeManifestHeader
{
  private static final long serialVersionUID = 1L;
  
  public RequiredExecutionEnvironmentHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  protected PDEManifestElement createElement(ManifestElement element)
  {
    return new ExecutionEnvironment(this, element.getValue());
  }
  
  public boolean hasExecutionEnvironment(IExecutionEnvironment env)
  {
    return hasElement(env.getId());
  }
  
  public void addExecutionEnvironment(IExecutionEnvironment env)
  {
    addManifestElement(new ExecutionEnvironment(this, env.getId()));
  }
  
  public void addExecutionEnvironment(ExecutionEnvironment environment, int index)
  {
    addManifestElement(environment, index, true);
  }
  
  public void addExecutionEnvironments(Object[] envs)
  {
    ArrayList list = new ArrayList(envs.length);
    for (int i = 0; i < envs.length; i++)
    {
      ExecutionEnvironment env = null;
      if ((envs[i] instanceof ExecutionEnvironment)) {
        env = (ExecutionEnvironment)envs[i];
      } else if ((envs[i] instanceof IExecutionEnvironment)) {
        env = new ExecutionEnvironment(this, ((IExecutionEnvironment)envs[i]).getId());
      }
      if ((env != null) && (!hasElement(env.getName()))) {
        list.add(env);
      }
    }
    if (list.size() > 0) {
      addManifestElements((ExecutionEnvironment[])list.toArray(new ExecutionEnvironment[list.size()]));
    }
  }
  
  public void addExecutionEnvironments(ExecutionEnvironment[] envs)
  {
    addManifestElements(envs);
  }
  
  public ExecutionEnvironment removeExecutionEnvironment(ExecutionEnvironment env)
  {
    return (ExecutionEnvironment)removeManifestElement(env);
  }
  
  public ExecutionEnvironment removeExecutionEnvironmentUnique(ExecutionEnvironment environment)
  {
    return (ExecutionEnvironment)removeManifestElement(environment, true);
  }
  
  public ExecutionEnvironment[] getEnvironments()
  {
    PDEManifestElement[] elements = getElements();
    ExecutionEnvironment[] result = new ExecutionEnvironment[elements.length];
    System.arraycopy(elements, 0, result, 0, elements.length);
    return result;
  }
}

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

import org.eclipse.osgi.util.ManifestElement;
import org.eclipse.pde.internal.core.ibundle.IBundle;
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
import org.osgi.framework.BundleException;

public class SingleManifestHeader
  extends ManifestHeader
{
  private static final long serialVersionUID = 1L;
  private PDEManifestElement fElement;
  
  public SingleManifestHeader(String name, String value, IBundle bundle, String lineDelimiter)
  {
    super(name, value, bundle, lineDelimiter);
  }
  
  protected void processValue(String value)
  {
    try
    {
      ManifestElement[] elements = ManifestElement.parseHeader(getName(), value);
      if (elements.length > 0) {
        fElement = new PDEManifestElement(this, elements[0]);
      }
    }
    catch (BundleException localBundleException) {}
    if (fElement == null) {
      fElement = new PDEManifestElement(this, "");
    }
    fValue = value;
  }
  
  public void setAttribute(String key, String value)
  {
    fElement.setAttribute(key, value);
    update();
  }
  
  public void setDirective(String key, String value)
  {
    fElement.setDirective(key, value);
    update();
  }
  
  public void setMainComponent(String value)
  {
    if (value == null) {
      fElement.setValueComponents(null);
    } else {
      fElement.setValueComponents(new String[] { value });
    }
    update();
  }
  
  public String getAttribute(String key)
  {
    return fElement.getAttribute(key);
  }
  
  public String getDirective(String key)
  {
    return fElement.getDirective(key);
  }
  
  public String getMainComponent()
  {
    return fElement.getValue();
  }
  
  public void update()
  {
    update(true);
  }
  
  public void update(boolean notify)
  {
    String old = fValue;
    fValue = fElement.write();
    if (notify) {
      fBundle.getModel().fireModelObjectChanged(this, fName, old, fValue);
    }
  }
}

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

import org.eclipse.pde.internal.core.text.DocumentElementNode;

public class DocumentGenericNode
  extends DocumentElementNode
{
  private static final long serialVersionUID = 1L;
  
  public DocumentGenericNode(String name)
  {
    setXMLTagName(name);
  }
}

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

import org.eclipse.jface.text.IDocument;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.pde.core.plugin.IFragment;
import org.eclipse.pde.core.plugin.IFragmentModel;

public class FragmentModel
  extends PluginModelBase
  implements IFragmentModel
{
  public FragmentModel(IDocument document, boolean isReconciling)
  {
    super(document, isReconciling);
  }
  
  public IFragment getFragment()
  {
    return (IFragment)getPluginBase();
  }
  
  public boolean isFragmentModel()
  {
    return true;
  }
  
  public BundleDescription getBundleDescription()
  {
    return null;
  }
  
  public void setBundleDescription(BundleDescription description) {}
}

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

import java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.pde.core.plugin.IFragment;

public class FragmentNode
  extends PluginBaseNode
  implements IFragment
{
  private static final long serialVersionUID = 1L;
  
  public String getPluginId()
  {
    return getXMLAttributeValue("plugin-id");
  }
  
  public String getPluginVersion()
  {
    return getXMLAttributeValue("plugin-version");
  }
  
  public int getRule()
  {
    String match = getXMLAttributeValue("match");
    if ((match == null) || (match.trim().length() == 0)) {
      return 0;
    }
    if (match.equals("compatible")) {
      return 2;
    }
    if (match.equals("perfect")) {
      return 3;
    }
    if (match.equals("equivalent")) {
      return 1;
    }
    return 4;
  }
  
  public void setPluginId(String id)
    throws CoreException
  {
    setXMLAttribute("plugin-id", id);
  }
  
  public void setPluginVersion(String version)
    throws CoreException
  {
    setXMLAttribute("plugin-version", version);
  }
  
  public void setRule(int rule)
    throws CoreException
  {
    String match = "";
    switch (rule)
    {
    case 2: 
      match = "compatible";
      break;
    case 1: 
      match = "equivalent";
      break;
    case 3: 
      match = "perfect";
      break;
    case 4: 
      match = "greaterOrEqual";
    }
    setXMLAttribute("match", match);
  }
  
  protected String[] getSpecificAttributes()
  {
    ArrayList result = new ArrayList();
    
    String pluginID = getPluginId();
    if ((pluginID != null) && (pluginID.trim().length() > 0)) {
      result.add("   plugin-id=\"" + pluginID + "\"");
    }
    String pluginVersion = getPluginVersion();
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-2017. Infinite Loop Ltd