org.eclipse.pde.core_3.7.1.v20120103_r372

eclipse.pde.internal.core.ifeature.IFeaturePlugin;

public class CoreUtility
{
  /* Error */
  public static void readFile(InputStream in, File file)
    throws IOException
  {
    // Byte code:
    //   0: new 191	java/io/FileOutputStream
    //   3: dup
    //   4: aload_1
    //   5: invokespecial 380	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   8: astore_2
    //   9: sipush 1024
    //   12: newarray <illegal type>
    //   14: astore_3
    //   15: goto +11 -> 26
    //   18: aload_2
    //   19: aload_3
    //   20: iconst_0
    //   21: iload 4
    //   23: invokevirtual 379	java/io/FileOutputStream:write	([BII)V
    //   26: aload_0
    //   27: aload_3
    //   28: iconst_0
    //   29: aload_3
    //   30: arraylength
    //   31: invokevirtual 382	java/io/InputStream:read	([BII)I
    //   34: dup
    //   35: istore 4
    //   37: ifgt -19 -> 18
    //   40: goto +20 -> 60
    //   43: astore 5
    //   45: aload_2
    //   46: invokevirtual 378	java/io/FileOutputStream:close	()V
    //   49: aconst_null
    //   50: astore_2
    //   51: aload_0
    //   52: invokevirtual 381	java/io/InputStream:close	()V
    //   55: aconst_null
    //   56: astore_0
    //   57: aload 5
    //   59: athrow
    //   60: aload_2
    //   61: invokevirtual 378	java/io/FileOutputStream:close	()V
    //   64: aconst_null
    //   65: astore_2
    //   66: aload_0
    //   67: invokevirtual 381	java/io/InputStream:close	()V
    //   70: aconst_null
    //   71: astore_0
    //   72: goto +10 -> 82
    //   75: astore_3
    //   76: aload_3
    //   77: invokestatic 400	org/eclipse/pde/internal/core/PDECore:logException	(Ljava/lang/Throwable;)V
    //   80: aload_3
    //   81: athrow
    //   82: return
    // Line number table:
    //   Java source line #40	-> byte code offset #0
    //   Java source line #42	-> byte code offset #9
    //   Java source line #45	-> byte code offset #15
    //   Java source line #46	-> byte code offset #18
    //   Java source line #45	-> byte code offset #26
    //   Java source line #48	-> byte code offset #43
    //   Java source line #49	-> byte code offset #45
    //   Java source line #50	-> byte code offset #49
    //   Java source line #51	-> byte code offset #51
    //   Java source line #52	-> byte code offset #55
    //   Java source line #53	-> byte code offset #57
    //   Java source line #49	-> byte code offset #60
    //   Java source line #50	-> byte code offset #64
    //   Java source line #51	-> byte code offset #66
    //   Java source line #52	-> byte code offset #70
    //   Java source line #54	-> byte code offset #75
    //   Java source line #55	-> byte code offset #76
    //   Java source line #56	-> byte code offset #80
    //   Java source line #58	-> byte code offset #82
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	83	0	in	InputStream
    //   0	83	1	file	File
    //   8	58	2	fos	java.io.FileOutputStream
    //   14	16	3	buffer	byte[]
    //   75	6	3	e	IOException
    //   18	4	4	count	int
    //   35	3	4	count	int
    //   60	1	4	count	int
    //   43	15	5	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   15	43	43	finally
    //   9	72	75	java/io/IOException
  }
  
  public static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
    throws CoreException
  {
    IProjectDescription description = proj.getDescription();
    String[] prevNatures = description.getNatureIds();
    String[] newNatures = new String[prevNatures.length + 1];
    System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
    newNatures[prevNatures.length] = natureId;
    description.setNatureIds(newNatures);
    proj.setDescription(description, monitor);
  }
  
  public static void createFolder(IFolder folder)
    throws CoreException
  {
    if (!folder.exists())
    {
      IContainer parent = folder.getParent();
      if ((parent instanceof IFolder)) {
        createFolder((IFolder)parent);
      }
      folder.create(true, true, null);
    }
  }
  
  public static void createProject(IProject project, IPath location, IProgressMonitor monitor)
    throws CoreException
  {
    if (!Platform.getLocation().equals(location))
    {
      IProjectDescription desc = project.getWorkspace().newProjectDescription(project.getName());
      desc.setLocation(location);
      project.create(desc, monitor);
    }
    else
    {
      project.create(monitor);
    }
  }
  
  public static String normalize(String text)
  {
    if ((text == null) || (text.trim().length() == 0)) {
      return "";
    }
    text = text.replaceAll("\\r|\\n|\\f|\\t", " ");
    return text.replaceAll("\\s+", " ");
  }
  
  public static void deleteContent(File curr)
  {
    if (curr.exists())
    {
      if (curr.isDirectory())
      {
        File[] children = curr.listFiles();
        if (children != null) {
          for (int i = 0; i < children.length; i++) {
            deleteContent(children[i]);
          }
        }
      }
      curr.delete();
    }
  }
  
  public static boolean guessUnpack(BundleDescription bundle)
  {
    if (bundle == null) {
      return true;
    }
    if (new File(bundle.getLocation()).isFile()) {
      return false;
    }
    HostSpecification host = bundle.getHost();
    if ((host != null) && (host.getName().equals("org.eclipse.equinox.launcher"))) {
      return true;
    }
    IWorkspaceRoot root = PDECore.getWorkspace().getRoot();
    IContainer container = root.getContainerForLocation(new Path(bundle.getLocation()));
    if (container == null) {
      return true;
    }
    if ((container instanceof IProject)) {
      try
      {
        if (!((IProject)container).hasNature("org.eclipse.jdt.core.javanature")) {
          return true;
        }
      }
      catch (CoreException e)
      {
        PDECore.logException(e);
      }
    }
    IPluginModelBase model = PluginRegistry.findModel(bundle);
    if (model == null) {
      return true;
    }
    if ((model instanceof IBundlePluginModelBase))
    {
      IBundleModel bundleModel = ((IBundlePluginModelBase)model).getBundleModel();
      if (bundleModel != null)
      {
        IBundle b = bundleModel.getBundle();
        String header = b.getHeader("Eclipse-BundleShape");
        if (header != null) {
          return "dir".equals(header);
        }
      }
    }
    FeatureModelManager manager = PDECore.getDefault().getFeatureModelManager();
    IFeatureModel[] models = manager.getModels();
    for (int i = 0; i < models.length; i++)
    {
      IFeatureModel featureModel = models[i];
      IFeaturePlugin[] plugins = featureModel.getFeature().getPlugins();
      for (int j = 0; j < plugins.length; j++)
      {
        IFeaturePlugin featurePlugin = plugins[j];
        if (featurePlugin.getId().equals(bundle.getSymbolicName())) {
          return featurePlugin.isUnpack();
        }
      }
    }
    IPluginLibrary[] libraries = model.getPluginBase().getLibraries();
    if (libraries.length == 0) {
      return false;
    }
    for (int i = 0; i < libraries.length; i++) {
      if (libraries[i].getName().equals(".")) {
        return false;
      }
    }
    return true;
  }
  
  public static boolean jarContainsResource(File file, String resource, boolean directory)
  {
    ZipFile jarFile = null;
    try
    {
      jarFile = new ZipFile(file, 1);
      ZipEntry resourceEntry = jarFile.getEntry(resource);
      if (resourceEntry != null) {
        return directory ? resourceEntry.isDirectory() : true;
      }
    }
    catch (IOException e)
    {
      PDECore.logException(e);
    }
    catch (FactoryConfigurationError e)
    {
      PDECore.logException(e);
    }
    finally
    {
      try
      {
        if (jarFile != null) {
          jarFile.close();
        }
      }
      catch (IOException e2)
      {
        PDECore.logException(e2);
      }
    }
    try
    {
      if (jarFile != null) {
        jarFile.close();
      }
    }
    catch (IOException e2)
    {
      PDECore.logException(e2);
    }
    return false;
  }
  
  /* Error */
  public static void copyFile(IPath originPath, String name, File target)
  {
    // Byte code:
    //   0: new 189	java/io/File
    //   3: dup
    //   4: aload_0
    //   5: invokeinterface 423 1 0
    //   10: aload_1
    //   11: invokespecial 374	java/io/File:<init>	(Ljava/io/File;Ljava/lang/String;)V
    //   14: astore_3
    //   15: aload_3
    //   16: invokevirtual 368	java/io/File:exists	()Z
    //   19: ifne +4 -> 23
    //   22: return
    //   23: aconst_null
    //   24: astore 4
    //   26: aconst_null
    //   27: astore 5
    //   29: new 190	java/io/FileInputStream
    //   32: dup
    //   33: aload_3
    //   34: invokespecial 377	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   37: astore 4
    //   39: new 191	java/io/FileOutputStream
    //   42: dup
    //   43: aload_2
    //   44: invokespecial 380	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   47: astore 5
    //   49: sipush 1024
    //   52: newarray <illegal type>
    //   54: astore 6
    //   56: aload 4
    //   58: aload 6
    //   60: invokevirtual 376	java/io/FileInputStream:read	([B)I
    //   63: istore 7
    //   65: goto +22 -> 87
    //   68: aload 5
    //   70: aload 6
    //   72: iconst_0
    //   73: iload 7
    //   75: invokevirtual 379	java/io/FileOutputStream:write	([BII)V
    //   78: aload 4
    //   80: aload 6
    //   82: invokevirtual 376	java/io/FileInputStream:read	([B)I
    //   85: istore 7
    //   87: iload 7
    //   89: iconst_m1
    //   90: if_icmpne -22 -> 68
    //   93: goto +78 -> 171
    //   96: astore 6
    //   98: aload 6
    //   100: invokestatic 400	org/eclipse/pde/internal/core/PDECore:logException	(Ljava/lang/Throwable;)V
    //   103: aload 4
    //   105: ifnull +8 -> 113
    //   108: aload 4
    //   110: invokevirtual 375	java/io/FileInputStream:close	()V
    //   113: aload 5
    //   115: ifnull +86 -> 201
    //   118: aload 5
    //   120: invokevirtual 378	java/io/FileOutputStream:close	()V
    //   123: goto +78 -> 201
    //   126: astore 9
    //   128: aload 9
    //   130: invokestatic 400	org/eclipse/pde/internal/core/PDECore:logException	(Ljava/lang/Throwable;)V
    //   133: goto +68 -> 201
    //   136: astore 8
    //   138: aload 4
    //   140: ifnull +8 -> 148
    //   143: aload 4
    //   145: invokevirtual 375	java/io/FileInputStream:close	()V
    //   148: aload 5
    //   150: ifnull +18 -> 168
    //   153: aload 5
    //   155: invokevirtual 378	java/io/FileOutputStream:close	()V
    //   158: goto +10 -> 168
    //   161: astore 9
    //   163: aload 9
    //   165: invokestatic 400	org/eclipse/pde/internal/core/PDECore:logException	(Ljava/lang/Throwable;)V
    //   168: aload 8
    //   170: athrow
    //   171: aload 4
    //   173: ifnull +8 -> 181
    //   176: aload 4
    //   178: invokevirtual 375	java/io/FileInputStream:close	()V
    //   181: aload 5
    //   183: ifnull +18 -> 201
    //   186: aload 5
    //   188: invokevirtual 378	java/io/FileOutputStream:close	()V
    //   191: goto +10 -> 201
    //   194: astore 9
    //   196: aload 9
    //   198: invokestatic 400	org/eclipse/pde/internal/core/PDECore:logException	(Ljava/lang/Throwable;)V
    //   201: return
    // Line number table:
    //   Java source line #202	-> byte code offset #0
    //   Java source line #203	-> byte code offset #15
    //   Java source line #204	-> byte code offset #22
    //   Java source line #205	-> byte code offset #23
    //   Java source line #206	-> byte code offset #26
    //   Java source line #208	-> byte code offset #29
    //   Java source line #209	-> byte code offset #39
    //   Java source line #210	-> byte code offset #49
    //   Java source line #211	-> byte code offset #56
    //   Java source line #212	-> byte code offset #65
    //   Java source line #213	-> byte code offset #68
    //   Java source line #214	-> byte code offset #78
    //   Java source line #212	-> byte code offset #87
    //   Java source line #216	-> byte code offset #96
    //   Java source line #217	-> byte code offset #98
    //   Java source line #220	-> byte code offset #103
    //   Java source line #221	-> byte code offset #108
    //   Java source line #222	-> byte code offset #113
    //   Java source line #223	-> byte code offset #118
    //   Java source line #224	-> byte code offset #126
    //   Java source line #225	-> byte code offset #128
    //   Java source line #218	-> byte code offset #136
    //   Java source line #220	-> byte code offset #138
    //   Java source line #221	-> byte code offset #143
    //   Java source line #222	-> byte code offset #148
    //   Java source line #223	-> byte code offset #153
    //   Java source line #224	-> byte code offset #161
    //   Java source line #225	-> byte code offset #163
    //   Java source line #227	-> byte code offset #168
    //   Java source line #220	-> byte code offset #171
    //   Java source line #221	-> byte code offset #176
    //   Java source line #222	-> byte code offset #181
    //   Java source line #223	-> byte code offset #186
    //   Java source line #224	-> byte code offset #194
    //   Java source line #225	-> byte code offset #196
    //   Java source line #228	-> byte code offset #201
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	202	0	originPath	IPath
    //   0	202	1	name	String
    //   0	202	2	target	File
    //   14	20	3	source	File
    //   24	153	4	is	FileInputStream
    //   27	160	5	os	java.io.FileOutputStream
    //   54	27	6	buf	byte[]
    //   96	3	6	e	IOException
    //   63	25	7	len	int
    //   136	33	8	localObject	Object
    //   126	3	9	e	IOException
    //   161	3	9	e	IOException
    //   194	3	9	e	IOException
    // Exception table:
    //   from	to	target	type
    //   29	93	96	java/io/IOException
    //   103	123	126	java/io/IOException
    //   29	103	136	finally
    //   138	158	161	java/io/IOException
    //   171	191	194	java/io/IOException
  }
  
  public static Document getTextDocument(File bundleLocation, String path)
  {
    ZipFile jarFile = null;
    InputStream stream = null;
    try
    {
      String extension = new Path(bundleLocation.getName()).getFileExtension();
      if (("jar".equals(extension)) && (bundleLocation.isFile()))
      {
        jarFile = new ZipFile(bundleLocation, 1);
        ZipEntry manifestEntry = jarFile.getEntry(path);
        if (manifestEntry != null) {
          stream = jarFile.getInputStream(manifestEntry);
        }
      }
      else
      {
        File file = new File(bundleLocation, path);
        if (file.exists()) {
          stream = new FileInputStream(file);
        }
      }
      return getTextDocument(stream);
    }
    catch (IOException e)
    {
      PDECore.logException(e);
    }
    finally
    {
      try
      {
        if (jarFile != null) {
          jarFile.close();
        }
        if (stream != null) {
          stream.close();
        }
      }
      catch (IOException e)
      {
        PDECore.logException(e);
      }
    }
    return null;
  }
  
  public static Document getTextDocument(InputStream in)
  {
    ByteArrayOutputStream output = null;
    String result = null;
    try
    {
      output = new ByteArrayOutputStream();
      
      byte[] buffer = new byte['?'];
      int count;
      while ((count = in.read(buffer, 0, buffer.length)) > 0)
      {
        int count;
        output.write(buffer, 0, count);
      }
      result = output.toString("UTF-8");
      output.close();
      output = null;
      in.close();
      in = null;
    }
    catch (IOException localIOException1)
    {
      if (output != null) {
        try
        {
          output.close();
        }
        catch (IOException ee)
        {
          PDECore.logException(ee);
        }
      }
      if (in != null) {
        try
        {
          in.close();
        }
        catch (IOException ee)
        {
          PDECore.logException(ee);
        }
      }
    }
    return result == null ? null : new Document(result);
  }
}

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

import java.util.Comparator;

class HeaderMap$HeaderComparator
  implements Comparator
{
  HeaderMap$HeaderComparator(HeaderComparator paramHeaderComparator)
  {
    this();
  }
  
  public int compare(Object arg0, Object arg1)
  {
    String header0 = (String)arg0;
    String header1 = (String)arg1;
    return header0.compareToIgnoreCase(header1);
  }
  
  private HeaderMap$HeaderComparator() {}
}

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

import java.util.Comparator;
import java.util.TreeMap;

public class HeaderMap
  extends TreeMap
{
  private static final long serialVersionUID = 1L;
  
  private static class HeaderComparator
    implements Comparator
  {
    HeaderComparator(HeaderComparator paramHeaderComparator)
    {
      this();
    }
    
    public int compare(Object arg0, Object arg1)
    {
      String header0 = (String)arg0;
      String header1 = (String)arg1;
      return header0.compareToIgnoreCase(header1);
    }
    
    private HeaderComparator() {}
  }
  
  public HeaderMap()
  {
    super(new HeaderComparator(null));
  }
}

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

import java.util.Enumeration;

class Headers$ArrayEnumeration
  implements Enumeration
{
  private Object[] array;
  int cur;
  final Headers this$0;
  
  public Headers$ArrayEnumeration(Headers paramHeaders, Object[] array, int size)
  {
    this$0 = paramHeaders;cur = 0;
    this.array = new Object[size];
    System.arraycopy(array, 0, this.array, 0, this.array.length);
  }
  
  public boolean hasMoreElements()
  {
    return cur < array.length;
  }
  
  public Object nextElement()
  {
    return array[(cur++)];
  }
}

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

import java.util.Collection;
import java.util.Dictionary;
import java.util.Enumeration;
import java.util.Map;
import java.util.Set;

public class Headers
  extends Dictionary
  implements Map
{
  private boolean readOnly = false;
  private Object[] headers;
  private Object[] values;
  private int size = 0;
  
  public Headers(int initialCapacity)
  {
    headers = new Object[initialCapacity];
    values = new Object[initialCapacity];
  }
  
  public Headers(Dictionary values)
  {
    this(values.size());
    
    Enumeration keys = values.keys();
    while (keys.hasMoreElements())
    {
      Object key = keys.nextElement();
      set(key, values.get(key));
    }
  }
  
  public synchronized Enumeration keys()
  {
    return new ArrayEnumeration(headers, size);
  }
  
  public synchronized Enumeration elements()
  {
    return new ArrayEnumeration(values, size);
  }
  
  private int getIndex(Object key)
  {
    boolean stringKey = key instanceof String;
    for (int i = 0; i < size; i++) {
      if ((stringKey) && ((headers[i] instanceof String)))
      {
        if (((String)headers[i]).equalsIgnoreCase((String)key)) {
          return i;
        }
      }
      else if (headers[i].equals(key)) {
        return i;
      }
    }
    return -1;
  }
  
  private Object remove(int remove)
  {
    Object removed = values[remove];
    for (int i = remove; i < size; i++) {
      if (i == headers.length - 1)
      {
        headers[i] = null;
        values[i] = null;
      }
      else
      {
        headers[i] = headers[(i + 1)];
        values[i] = values[(i + 1)];
      }
    }
    if (remove < size) {
      size -= 1;
    }
    return removed;
  }
  
  private void add(Object header, Object value)
  {
    if (size == headers.length)
    {
      Object[] newHeaders = new Object[headers.length + 10];
      Object[] newValues = new Object[values.length + 10];
      System.arraycopy(headers, 0, newHeaders, 0, headers.length);
      System.arraycopy(values, 0, newValues, 0, values.length);
      headers = newHeaders;
      values = newValues;
    }
    headers[size] = header;
    values[size] = value;
    size += 1;
  }
  
  public synchronized Object get(Object key)
  {
    int i = -1;
    if ((i = getIndex(key)) != -1) {
      return values[i];
    }
    return null;
  }
  
  public synchronized Object set(Object key, Object value, boolean replace)
  {
    if (readOnly) {
      throw new UnsupportedOperationException();
    }
    if ((key instanceof String)) {
      key = ((String)key).intern();
    }
    int i = getIndex(key);
    if (value == null)
    {
      if (i != -1) {
        return remove(i);
      }
    }
    else
    {
      if (i != -1)
      {
        if (!replace) {
          throw new IllegalArgumentException();
        }
        Object oldVal = values[i];
        values[i] = value;
        return oldVal;
      }
      add(key, value);
    }
    return null;
  }
  
  public synchronized Object set(Object key, Object value)
  {
    return set(key, value, false);
  }
  
  public synchronized void setReadOnly()
  {
    readOnly = true;
  }
  
  public synchronized int size()
  {
    return size;
  }
  
  public synchronized boolean isEmpty()
  {
    return size == 0;
  }
  
  public synchronized Object put(Object key, Object value)
  {
    if (readOnly) {
      throw new UnsupportedOperationException();
    }
    return set(key, value, true);
  }
  
  public Object remove(Object key)
  {
    throw new UnsupportedOperationException();
  }
  
  public String toString()
  {
    return values.toString();
  }
  
  class ArrayEnumeration
    implements Enumeration
  {
    private Object[] array;
    int cur = 0;
    
    public ArrayEnumeration(Object[] array, int size)
    {
      this.array = new Object[size];
      System.arraycopy(array, 0, this.array, 0, this.array.length);
    }
    
    public boolean hasMoreElements()
    {
      return cur < array.length;
    }
    
    public Object nextElement()
    {
      return array[(cur++)];
    }
  }
  
  public synchronized void clear()
  {
    if (readOnly) {
      throw new UnsupportedOperationException();
    }
  }
  
  public synchronized boolean containsKey(Object key)
  {
    return getIndex(key) >= 0;
  }
  
  public boolean containsValue(Object var0)
  {
    throw new UnsupportedOperationException();
  }
  
  public Set entrySet()
  {
    throw new UnsupportedOperationException();
  }
  
  public Set keySet()
  {
    throw new UnsupportedOperationException();
  }
  
  public void putAll(Map var0)
  {
    throw new UnsupportedOperationException();
  }
  
  public Collection values()
  {
    throw new UnsupportedOperationException();
  }
}

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

import java.util.StringTokenizer;
import org.eclipse.pde.core.plugin.IFragment;
import org.eclipse.pde.core.plugin.IFragmentModel;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginExtension;
import org.eclipse.pde.core.plugin.IPluginExtensionPoint;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.internal.core.text.plugin.PluginExtensionPointNode;

public class IdUtil
{
  public static boolean isValidCompositeID(String name)
  {
    if (name.length() <= 0) {
      return false;
    }
    for (int i = 0; i < name.length(); i++)
    {
      char c = name.charAt(i);
      if (((c < 'A') || ('Z' < c)) && ((c < 'a') || ('z' < c)) && ((c < '0') || ('9' < c)) && (c != '_') && (
        (i == 0) || (i == name.length() - 1) || (c != '.'))) {
        return false;
      }
    }
    return true;
  }
  
  public static boolean isValidCompositeID3_0(String name)
  {
    if (name.length() <= 0) {
      return false;
    }
    for (int i = 0; i < name.length(); i++)
    {
      char c = name.charAt(i);
      if (((c < 'A') || ('Z' < c)) && ((c < 'a') || ('z' < c)) && ((c < '0') || ('9' < c)) && (c != '_') && (c != '-') && (
        (i == 0) || (i == name.length() - 1) || (c != '.'))) {
        return false;
      }
    }
    return true;
  }
  
  public static boolean isValidSimpleID(String name)
  {
    if (name.length() <= 0) {
      return false;
    }
    for (int i = 0; i < name.length(); i++)
    {
      char c = name.charAt(i);
      if (((c < 'A') || ('Z' < c)) && ((c < 'a') || ('z' < c)) && ((c < '0') || ('9' < c)) && (c != '_')) {
        return false;
      }
    }
    return true;
  }
  
  public static String getValidId(String projectName)
  {
    return projectName.replaceAll("[^a-zA-Z0-9\\._-]", "_");
  }
  
  public static String getValidName(String id)
  {
    StringTokenizer tok = new StringTokenizer(id, ".");
    while (tok.hasMoreTokens())
    {
      String token = tok.nextToken();
      if (!tok.hasMoreTokens())
      {
        String name = Character.toUpperCase(token.charAt(0)) + (token.length() > 1 ? token.substring(1) : "");
        return name;
      }
    }
    return "";
  }
  
  public static String getValidProvider(String id)
  {
    StringTokenizer tok = new StringTokenizer(id, ".");
    int count = tok.countTokens();
    if ((count > 2) && (tok.nextToken().equals("com"))) {
      return tok.nextToken().toUpperCase();
    }
    return "";
  }
  
  public static String getFullId(IPluginExtension extension)
  {
    String id = extension.getId();
    IPluginBase plugin = extension.getPluginBase();
    String schemaVersion = plugin.getSchemaVersion();
    if ((schemaVersion != null) && (Double.parseDouble(schemaVersion) >= 3.2D) && 
      (id.indexOf('.') > 0)) {
      return id;
    }
    if ((plugin instanceof IFragment)) {
      return ((IFragment)plugin).getPluginId() + '.' + id;
    }
    return plugin.getId() + '.' + id;
  }
  
  public static String getFullId(IPluginExtensionPoint point, IPluginModelBase model)
  {
    if (((point instanceof PluginExtensionPointNode)) && (model != null))
    {
      String pointId = point.getId();
      String schemaVersion = model.getPluginBase().getSchemaVersion();
      if ((schemaVersion != null) && (Double.parseDouble(schemaVersion) >= 3.2D) && (pointId.indexOf('.') > 0)) {
        return pointId;
      }
      String id = null;
      if ((model instanceof IFragmentModel))
      {
        IFragment fragment = ((IFragmentModel)model).getFragment();
        if (fragment != null) {
          id = fragment.getPluginId();
        }
      }
      if (id == null) {
        id = model.getPluginBase().getId();
      }
      return id + '.' + pointId;
    }
    return point.getFullId();
  }
  
  public static boolean isInterestingExtensionPoint(String point)
  {
    return ("org.eclipse.pde.core.source".equals(point)) || ("org.eclipse.core.runtime.products".equals(point)) || ("org.eclipse.pde.core.javadoc".equals(point)) || ("org.eclipse.ui.intro".equals(point));
  }
}

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

import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.pde.core.build.IBuild;
import org.eclipse.pde.core.build.IBuildEntry;
import org.eclipse.pde.internal.core.build.WorkspaceBuildModel;
import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
import org.eclipse.pde.internal.core.project.PDEProject;

public class ManifestUtils
{
  public static IPackageFragmentRoot[] findPackageFragmentRoots(IManifestHeader header, IProject project)
  {
    IJavaProject javaProject = JavaCore.create(project);
    String[] libs;
    String[] libs;
    if ((header == null) || (header.getValue() == null)) {
      libs = new String[] { "." };
    } else {
      libs = header.getValue().split(",");
    }
    IBuild build = getBuild(project);
    if (build == null) {
      try
      {
        return javaProject.getPackageFragmentRoots();
      }
      catch (JavaModelException localJavaModelException)
      {
        return new IPackageFragmentRoot[0];
      }
    }
    List pkgFragRoots = new LinkedList();
    for (int j = 0; j < libs.length; j++)
    {
      String lib = libs[j];
      
      IPackageFragmentRoot root = null;
      if (!lib.equals(".")) {
        try
        {
          root = javaProject.getPackageFragmentRoot(project.getFile(lib));
        }
        catch (IllegalArgumentException localIllegalArgumentException)
        {
          return new IPackageFragmentRoot[0];
        }
      }
      if ((root != null) && (root.exists()))
      {
        pkgFragRoots.add(root);
      }
      else
      {
        IBuildEntry entry = build.getEntry("source." + lib);
        if (entry != null)
        {
          String[] tokens = entry.getTokens();
          for (int i = 0; i < tokens.length; i++)
          {
            IResource resource = project.findMember(tokens[i]);
            if (resource != null)
            {
              root = javaProject.getPackageFragmentRoot(resource);
              if ((root != null) && (root.exists())) {
                pkgFragRoots.add(root);
              }
            }
          }
        }
      }
    }
    return (IPackageFragmentRoot[])pkgFragRoots.toArray(new IPackageFragmentRoot[pkgFragRoots.size()]);
  }
  
  public static final IBuild getBuild(IProject project)
  {
    IFile buildProps = PDEProject.getBuildProperties(project);
    if (buildProps.exists())
    {
      WorkspaceBuildModel model = new WorkspaceBuildModel(buildProps);
      if (model != null) {
        return model.getBuild();
      }
    }
    return null;
  }
  
  public static boolean isImmediateRoot(IPackageFragmentRoot root)
    throws JavaModelException
  {
    int kind = root.getKind();
    return (kind == 1) || ((kind == 2) && (!root.isExternal()));
  }
}

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

import java.util.HashMap;

public class PDEHTMLHelper
{
  public static final HashMap fgEntityLookup = new HashMap(6);
  
  static
  {
    fgEntityLookup.put("lt", "<");
    fgEntityLookup.put("gt", ">");
    fgEntityLookup.put("nbsp", " ");
    fgEntityLookup.put("amp", "&");
    fgEntityLookup.put("apos", "'");
    fgEntityLookup.put("quot", "\"");
  }
  
  public static String stripTags(String html)
  {
    if (html == null) {
      return null;
    }
    int length = html.length();
    boolean write = true;
    char oldChar = ' ';
    StringBuffer sb = new StringBuffer(length);
    
    boolean processingEntity = false;
    StringBuffer entityBuffer = null;
    for (int i = 0; i < length; i++)
    {
      char curr = html.charAt(i);
      if (curr == '&')
      {
        processingEntity = true;
        entityBuffer = new StringBuffer();
      }
      else
      {
        if ((processingEntity) && (curr == ';'))
        {
          processingEntity = false;
          
          String entity = (String)fgEntityLookup.get(entityBuffer.toString());
          if (entity == null) {
            continue;
          }
          curr = entity.charAt(0);
        }
        else if (processingEntity)
        {
          entityBuffer.append(curr);
          continue;
        }
        if (curr == '<')
        {
          write = false;
        }
        else if (curr == '>')
        {
          write = true;
        }
        else if ((write) && (curr != '\r') && (curr != '\n') && (curr != '\t') && (
          (curr != ' ') || (oldChar != curr)))
        {
          sb.append(curr);
          oldChar = curr;
        }
      }
    }
    if (isAllWhitespace(sb.toString())) {
      return null;
    }
    return sb.toString();
  }
  
  public static boolean isAllWhitespace(String string)
  {
    if (string == null) {
      return false;
    }
    char[] characters = string.toCharArray();
    for (int i = 0; i < characters.length; i++) {
      if (!Character.isWhitespace(characters[i])) {
        return false;
      }
    }
    return true;
  }
}

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

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.ListIterator;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
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.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.service.resolver.ExportPackageDescription;
import org.eclipse.osgi.service.resolver.ImportPackageSpecification;
import org.eclipse.osgi.service.resolver.State;
import org.eclipse.osgi.service.resolver.StateHelper;
import org.eclipse.pde.core.plugin.IPluginBase;
import org.eclipse.pde.core.plugin.IPluginLibrary;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.internal.core.ClasspathUtilCore;
import org.eclipse.pde.internal.core.PDECore;
import org.eclipse.pde.internal.core.PDEPreferencesManager;

public class PDEJavaHelper
{
  public static boolean isDiscouraged(String fullyQualifiedName, IJavaProject project, BundleDescription desc)
  {
    try
    {
      IType type = project.findType(fullyQualifiedName.replace('$', '.'));
      if ((type != null) && (type.exists()))
      {
        HashMap map = getPackageFragmentsHash(project, Collections.EMPTY_LIST, false);
        if (map.containsValue(type.getPackageFragment())) {
          return false;
        }
      }
    }
    catch (JavaModelException localJavaModelException)
    {
      int dot = fullyQualifiedName.lastIndexOf('.');
      if (dot != -1) {
        fullyQualifiedName = fullyQualifiedName.substring(0, dot);
      } else {
        fullyQualifiedName = ".";
      }
      State state = desc.getContainingState();
      StateHelper helper = state.getStateHelper();
      ExportPackageDescription[] exports = helper.getVisiblePackages(desc);
      for (int i = 0; i < exports.length; i++)
      {
        BundleDescription exporter = exports[i].getExporter();
        if (exporter != null) {
          if ((fullyQualifiedName.equals(exports[i].getName())) && (helper.getAccessCode(desc, exports[i]) == 2)) {
            return true;
          }
        }
      }
    }
    return false;
  }
  
  public static boolean isOnClasspath(String fullyQualifiedName, IJavaProject project)
  {
    if (fullyQualifiedName.indexOf('$') != -1) {
      fullyQualifiedName = fullyQualifiedName.replace('$', '.');
    }
    try
    {
      IType type = project.findType(fullyQualifiedName);
      return (type != null) && (type.exists());
    }
    catch (JavaModelException localJavaModelException) {}
    return false;
  }
  
  public static IJavaSearchScope getSearchScope(IJavaProject project)
  {
    return SearchEngine.createJavaSearchScope(getNonJRERoots(project));
  }
  
  public static IJavaSearchScope getSearchScope(IProject project)
  {
    return getSearchScope(JavaCore.create(project));
  }
  
  public static IPackageFragmentRoot[] getNonJRERoots(IJavaProject project)
  {
    ArrayList result = new ArrayList();
    try
    {
      IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
      for (int i = 0; i < roots.length; i++) {
        if (!isJRELibrary(roots[i])) {
          result.add(roots[i]);
        }
      }
    }
    catch (JavaModelException localJavaModelException) {}
    return (IPackageFragmentRoot[])result.toArray(new IPackageFragmentRoot[result.size()]);
  }
  
  public static boolean isJRELibrary(IPackageFragmentRoot root)
  {
    try
    {
      IPath path = root.getRawClasspathEntry().getPath();
      if ((path.equals(new Path(JavaRuntime.JRE_CONTAINER))) || (path.equals(new Path("JRE_LIB")))) {
        return true;
      }
    }
    catch (JavaModelException localJavaModelException) {}
    return false;
  }
  
  public static IPackageFragment getPackageFragment(String packageName, String pluginID, IProject project)
  {
    if (project == null) {
      return getExternalPackageFragment(packageName, pluginID);
    }
    IJavaProject jp = JavaCore.create(project);
    if (jp != null) {
      try
      {
        IPackageFragmentRoot[] roots = jp.getAllPackageFragmentRoots();
        for (int i = 0; i < roots.length; i++)
        {
          IPackageFragment frag = roots[i].getPackageFragment(packageName);
          if (frag.exists()) {
            return frag;
          }
        }
      }
      catch (JavaModelException localJavaModelException) {}
    }
    return null;
  }
  
  private static IPackageFragment getExternalPackageFragment(String packageName, String pluginID)
  {
    if (pluginID == null) {
      return null;
    }
    IPluginModelBase base = null;
    try
    {
      IPluginModelBase plugin = PluginRegistry.findModel(pluginID);
      if (plugin == null) {
        return null;
      }
      ImportPackageSpecification[] packages = plugin.getBundleDescription().getImportPackages();
      for (int i = 0; i < packages.length; i++) {
        if (packages[i].getName().equals(packageName))
        {
          ExportPackageDescription desc = (ExportPackageDescription)packages[i].getSupplier();
          if (desc == null) {
            break;
          }
          base = PluginRegistry.findModel(desc.getExporter().getSymbolicName());
          break;
        }
      }
      if (base == null) {
        return null;
      }
      IResource res = base.getUnderlyingResource();
      if (res != null)
      {
        IJavaProject jp = JavaCore.create(res.getProject());
        if (jp != null) {
          try
          {
            IPackageFragmentRoot[] roots = jp.getAllPackageFragmentRoots();
            for (int i = 0; i < roots.length; i++)
            {
              IPackageFragment frag = roots[i].getPackageFragment(packageName);
              if (frag.exists()) {
                return frag;
              }
            }
          }
          catch (JavaModelException localJavaModelException1) {}
        }
      }
      IProject proj = PDECore.getWorkspace().getRoot().getProject("External Plug-in Libraries");
      if (proj == null) {
        return searchWorkspaceForPackage(packageName, base);
      }
      IJavaProject jp = JavaCore.create(p
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