org.eclipse.wst.common.emf_1.2.100.v201101101900

16:48:49.003 INFO  jd.cli.Main - Decompiling org.eclipse.wst.common.emf_1.2.100.v201101101900.jar
package org.eclipse.wst.common.internal.emf;

import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.ILock;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.wst.common.internal.emf.plugin.EcoreUtilitiesPlugin;
import org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapter;

public class ResourceSynchronizedIsLoadingAdapter
  extends ResourceIsLoadingAdapter
{
  private final ILock loadingLock;
  private static final long DELAY = 300000L;
  
  public ResourceSynchronizedIsLoadingAdapter()
  {
    loadingLock = Job.getJobManager().newLock();
    if (loadingLock != null) {
      loadingLock.acquire();
    }
  }
  
  /* Error */
  public void waitForResourceToLoad()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   4: ifnonnull +4 -> 8
    //   7: return
    //   8: iconst_0
    //   9: istore_1
    //   10: aload_0
    //   11: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   14: ifnull +60 -> 74
    //   17: aload_0
    //   18: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   21: ldc2_w 47
    //   24: invokeinterface 114 3 0
    //   29: dup
    //   30: istore_1
    //   31: ifne +43 -> 74
    //   34: aload_0
    //   35: invokespecial 104	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:logWarning	()V
    //   38: goto +36 -> 74
    //   41: pop
    //   42: iload_1
    //   43: ifeq +44 -> 87
    //   46: aload_0
    //   47: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   50: invokeinterface 113 1 0
    //   55: goto +32 -> 87
    //   58: astore_2
    //   59: iload_1
    //   60: ifeq +12 -> 72
    //   63: aload_0
    //   64: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   67: invokeinterface 113 1 0
    //   72: aload_2
    //   73: athrow
    //   74: iload_1
    //   75: ifeq +12 -> 87
    //   78: aload_0
    //   79: getfield 97	org/eclipse/wst/common/internal/emf/ResourceSynchronizedIsLoadingAdapter:loadingLock	Lorg/eclipse/core/runtime/jobs/ILock;
    //   82: invokeinterface 113 1 0
    //   87: return
    // Line number table:
    //   Java source line #65	-> byte code offset #0
    //   Java source line #66	-> byte code offset #7
    //   Java source line #68	-> byte code offset #8
    //   Java source line #70	-> byte code offset #10
    //   Java source line #71	-> byte code offset #17
    //   Java source line #72	-> byte code offset #34
    //   Java source line #74	-> byte code offset #41
    //   Java source line #78	-> byte code offset #42
    //   Java source line #79	-> byte code offset #46
    //   Java source line #77	-> byte code offset #58
    //   Java source line #78	-> byte code offset #59
    //   Java source line #79	-> byte code offset #63
    //   Java source line #80	-> byte code offset #72
    //   Java source line #78	-> byte code offset #74
    //   Java source line #79	-> byte code offset #78
    //   Java source line #82	-> byte code offset #87
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	88	0	this	ResourceSynchronizedIsLoadingAdapter
    //   9	66	1	lockAcquired	boolean
    //   58	15	2	localObject	Object
    //   41	1	3	localInterruptedException	InterruptedException
    // Exception table:
    //   from	to	target	type
    //   10	38	41	java/lang/InterruptedException
    //   10	42	58	finally
  }
  
  private void logWarning()
  {
    Notifier notificationTarget = getTarget();
    if ((notificationTarget != null) && ((notificationTarget instanceof Resource)))
    {
      Resource resource = (Resource)notificationTarget;
      EcoreUtilitiesPlugin.logError("[WARNING] Could not acquire Semaphore Lock for Resource: \"" + resource.getURI() + "\" in " + getClass());
    }
  }
  
  public void notifyChanged(Notification notification)
  {
    if (notification.getNotifier() != null) {
      if (isSetLoadedResourceNotification(notification))
      {
        if (loadingLock != null) {
          loadingLock.release();
        }
        removeIsLoadingSupport();
      }
    }
  }
  
  public void forceRelease()
  {
    if ((loadingLock != null) && (loadingLock.getDepth() > 0)) {
      loadingLock.release();
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.ResourceSynchronizedIsLoadingAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf;

import org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapter;
import org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapterFactory;

public class ResourceSynchronizedIsLoadingAdapterFactory
  extends ResourceIsLoadingAdapterFactory
{
  public ResourceIsLoadingAdapter createResourceIsLoadingAdapter()
  {
    return new ResourceSynchronizedIsLoadingAdapter();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.ResourceSynchronizedIsLoadingAdapterFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.plugin;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.eclipse.wst.common.internal.emf.ResourceSynchronizedIsLoadingAdapterFactory;
import org.eclipse.wst.common.internal.emf.resource.RendererFactory;
import org.osgi.framework.BundleContext;

public class EcoreUtilitiesPlugin
  extends Plugin
{
  public static final String PLUGIN_ID = "org.eclipse.wst.common.emf";
  public static final String ID = "org.eclipse.wst.common.emf";
  public static final String TRANSLATOR_EXTENSTION_POINT = "translatorExtension";
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
    RendererFactory.setDefaultHandler(PluginRendererFactoryDefaultHandler.INSTANCE);
    PackageURIMapReader reader = new PackageURIMapReader();
    reader.processExtensions();
    
    org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapterFactory.INSTANCE = new ResourceSynchronizedIsLoadingAdapterFactory();
  }
  
  public static IStatus createStatus(int severity, String message, Throwable exception)
  {
    return new Status(severity, "org.eclipse.wst.common.emf", message, exception);
  }
  
  public static IStatus createStatus(int severity, String message)
  {
    return createStatus(severity, message, null);
  }
  
  public static void logError(Throwable exception)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.wst.common.emf")).log(createStatus(4, exception.getMessage(), exception));
  }
  
  public static void logError(CoreException exception)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.wst.common.emf")).log(exception.getStatus());
  }
  
  public static void logError(String message)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.wst.common.emf")).log(createStatus(4, message));
  }
  
  public static void logWarning(String message)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.wst.common.emf")).log(createStatus(2, message));
  }
  
  public static void logWarning(Throwable exception)
  {
    Platform.getLog(Platform.getBundle("org.eclipse.wst.common.emf")).log(createStatus(2, exception.getMessage(), exception));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.plugin.EcoreUtilitiesPlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.plugin;

import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.wst.common.internal.emf.resource.CompatibilityPackageMappingRegistry;

public class PackageURIMapReader
{
  private static final String URI_ATT_NAME = "uri";
  private static final String PREFIX_ATT_NAME = "prefix";
  private static final String EXTENSION_POINT_NAME = "packageURIMap";
  
  private IExtensionPoint getExtensionPoint()
  {
    return Platform.getExtensionRegistry().getExtensionPoint("org.eclipse.wst.common.emf", "packageURIMap");
  }
  
  public void processExtensions()
  {
    CompatibilityPackageMappingRegistry reg = CompatibilityPackageMappingRegistry.INSTANCE;
    IExtension[] extensions = getExtensionPoint().getExtensions();
    for (int i = 0; i < extensions.length; i++) {
      processExtension(extensions[i], reg);
    }
  }
  
  private void processExtension(IExtension extension, CompatibilityPackageMappingRegistry reg)
  {
    IConfigurationElement[] configs = extension.getConfigurationElements();
    for (int i = 0; i < configs.length; i++) {
      processConfiguration(configs[i], reg);
    }
  }
  
  private void processConfiguration(IConfigurationElement element, CompatibilityPackageMappingRegistry reg)
  {
    String prefix = element.getAttribute("prefix");
    String uri = element.getAttribute("uri");
    reg.registerPrefixToPackageURI(prefix, uri);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.plugin.PackageURIMapReader
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.plugin;

import org.eclipse.wst.common.core.util.UIContextDetermination;
import org.eclipse.wst.common.internal.emf.resource.EMF2DOMRendererFactoryDefaultHandler;
import org.eclipse.wst.common.internal.emf.resource.RendererFactory;

public class PluginRendererFactoryDefaultHandler
  extends EMF2DOMRendererFactoryDefaultHandler
{
  static final PluginRendererFactoryDefaultHandler INSTANCE = new PluginRendererFactoryDefaultHandler();
  static final String EXT_POINT_NAME = "rendererFactory";
  
  public RendererFactory getDefaultRendererFactory()
  {
    RendererFactory aFactory = (RendererFactory)UIContextDetermination.createInstance("rendererFactory");
    return aFactory == null ? super.getDefaultRendererFactory() : aFactory;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.plugin.PluginRendererFactoryDefaultHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

public abstract class AbstractRendererImpl
  implements Renderer
{
  protected TranslatorResource resource;
  private int versionId;
  private boolean validating = true;
  
  public void setResource(TranslatorResource aResource)
  {
    resource = aResource;
  }
  
  public TranslatorResource getResource()
  {
    return resource;
  }
  
  public int getVersionId()
  {
    return versionId;
  }
  
  public void setVersionId(int versionId)
  {
    this.versionId = versionId;
  }
  
  public boolean isValidating()
  {
    return validating;
  }
  
  public void setValidating(boolean b)
  {
    validating = b;
  }
  
  public void accessForRead() {}
  
  public void accessForWrite() {}
  
  public boolean isModified()
  {
    return false;
  }
  
  public boolean isShared()
  {
    return false;
  }
  
  public boolean isSharedForWrite()
  {
    return false;
  }
  
  public void preDelete() {}
  
  public void preUnload() {}
  
  public void releaseFromRead() {}
  
  public void releaseFromWrite() {}
  
  public void setBatchMode(boolean isBatch) {}
  
  public boolean useStreamsForIO()
  {
    return true;
  }
  
  public boolean isBatchMode()
  {
    return false;
  }
  
  public boolean isReverting()
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.AbstractRendererImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

public final class AttributeTranslatorFilter
  extends TranslatorFilter
{
  public AttributeTranslatorFilter()
  {
    super(null, -1);
  }
  
  public AttributeTranslatorFilter(Translator trans, int version)
  {
    super(trans, version);
  }
  
  public final int scanNextTranslator(Translator[] children, int start)
  {
    for (int found = start + 1; found < children.length; found++) {
      if (children[found].isDOMAttribute()) {
        break;
      }
    }
    found = found < children.length ? found : -1;
    return found;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.AttributeTranslatorFilter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.EObject;
import org.xml.sax.Attributes;

public class CacheEventNode
{
  public static final String ROOT_NODE = "EMF_ROOT_NODE";
  private String nodeName = null;
  private Translator translator = null;
  private Notifier emfOwner = null;
  private StringBuffer buffer = null;
  private List children = null;
  private int versionID;
  private String[] attributes = null;
  private CacheEventNode parent = null;
  private CacheEventPool containingPool = null;
  private Boolean ignorable = null;
  
  public CacheEventNode(CacheEventPool containingPool)
  {
    this.containingPool = containingPool;
  }
  
  public void init(TranslatorResource resource)
  {
    discard();
    setEmfOwner(resource);
    setTranslator(resource.getRootTranslator());
    setVersionID(resource.getVersionID());
    nodeName = "EMF_ROOT_NODE";
  }
  
  public void init(CacheEventNode parentArg, String nodeNameArg, Attributes attributesArg)
  {
    discard();
    nodeName = nodeNameArg;
    init(parentArg, attributesArg);
  }
  
  private void init(CacheEventNode parentRecord, Attributes attributesArg)
  {
    setParent(parentRecord);
    
    setAttributes(attributesArg);
    if (parent != null)
    {
      if ((parent.translator != null) && (parent.isInDOMPath())) {
        setParent(parent.getParent());
      }
      setVersionID(parent.getVersionID());
      if ((parent.getEmfOwner() != null) && (parent.getTranslator() != null))
      {
        if (parent.getParent() != null) {
          setTranslator(parent.getTranslator().findChild(nodeName, parent.getEmfOwner(), getVersionID()));
        } else {
          setTranslator(parent.getTranslator());
        }
        if (translator == null) {
          throw new IllegalStateException("Parent Translator (" + parent.getTranslator() + 
            ") did not find a Child Translator for \"" + 
            nodeName + "\".");
        }
        if ((translator.getReadAheadHelper(nodeName) == null) && (!translator.isManagedByParent()))
        {
          Notifier myEmfOwner = translator.createEMFObject(getNodeName(), null);
          setEmfOwner(myEmfOwner);
          translator.setMOFValue(parent.getEmfOwner(), myEmfOwner);
        }
      }
    }
    processAttributes();
  }
  
  public void commit()
  {
    if ((parent == null) || (isIgnorable()))
    {
      discard();
      releaseFromContainingPool();
      return;
    }
    ReadAheadHelper helper = null;
    Translator activeTranslator = getTranslator();
    Translator parentTranslator = getParent().getTranslator();
    if ((parent != null) && (parent.getEmfOwner() == null))
    {
      parent.appendToBuffer(this);
      if ((helper = getParent().getReadAheadHelper()) != null)
      {
        EObject parentOwner = null;
        if (helper.nodeValueIsReadAheadName(getNodeName()))
        {
          parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getBuffer());
          
          getParent().updateEMF(parentOwner);
        }
        else if (helper.nodeNameIsReadAheadName(getNodeName()))
        {
          parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getNodeName());
          
          getParent().updateEMF(parentOwner);
        }
      }
    }
    else
    {
      if (activeTranslator != null) {
        if (activeTranslator.isManagedByParent())
        {
          Object value = activeTranslator.convertStringToValue(getNodeName(), null, getBuffer(), getParent().getEmfOwner());
          activeTranslator.setMOFValue(getParent().getEmfOwner(), value);
          processAttributes();
        }
        else
        {
          activeTranslator.setTextValueIfNecessary(getBuffer(), getEmfOwner(), getVersionID());
        }
      }
      discard();
      releaseFromContainingPool();
    }
  }
  
  private void discard()
  {
    translator = null;
    emfOwner = null;
    buffer = null;
    if (children != null) {
      children.clear();
    }
    children = null;
    attributes = null;
    parent = null;
  }
  
  private void releaseFromContainingPool()
  {
    if (containingPool != null) {
      containingPool.releaseNode(this);
    }
  }
  
  public boolean isIgnorable()
  {
    if (ignorable == null)
    {
      boolean result = false;
      if (translator != null) {
        if (translator.isEmptyContentSignificant())
        {
          result = false;
        }
        else
        {
          String domPath = translator.getDOMPath();
          result = domPath.indexOf(nodeName) >= 0;
        }
      }
      ignorable = (result ? Boolean.TRUE : Boolean.FALSE);
    }
    return ignorable.booleanValue();
  }
  
  public boolean isChildIgnorable(String childNodeName)
  {
    boolean result = false;
    
    Translator childTranslator = null;
    if (getTranslator() != null)
    {
      childTranslator = getTranslator().findChild(childNodeName, getEmfOwner(), getVersionID());
      if (childTranslator != null) {
        if (childTranslator.isEmptyContentSignificant())
        {
          result = false;
        }
        else
        {
          String temp = null;
          result = temp.indexOf(childNodeName) >= 0;
        }
      }
    }
    return result;
  }
  
  public boolean isInDOMPath()
  {
    boolean result = false;
    if (getTranslator() != null) {
      result = getNodeName().equals(getTranslator().getDOMPath());
    }
    return result;
  }
  
  public String toString()
  {
    StringBuffer output = new StringBuffer("CacheEventNode[");
    output.append("nodeName=");
    output.append(nodeName);
    output.append("; translator=");
    output.append(translator);
    output.append("; emfOwner=");
    try
    {
      output.append(emfOwner);
    }
    catch (RuntimeException localRuntimeException)
    {
      output.append("Could not render as string!");
    }
    output.append("; buffer=");
    output.append(buffer);
    output.append("; hasChildren=");
    output.append((children != null) && (children.size() > 0));
    if (children != null) {
      for (int i = 0; i < children.size(); i++)
      {
        output.append("\n\tchildren(");
        output.append(i);
        output.append("): ");
        output.append(children.get(i));
      }
    }
    output.append("]");
    return output.toString();
  }
  
  public void updateEMF(EObject owner)
  {
    setEmfOwner(owner);
    if (parent != null)
    {
      translator.setMOFValue((EObject)parent.getEmfOwner(), owner);
      processAttributes();
    }
    updateEMF();
  }
  
  public void updateEMF()
  {
    if (children == null) {
      return;
    }
    CacheEventNode child = null;
    Translator childTranslator = null;
    Object value = null;
    if (getEmfOwner() != null)
    {
      Notifier parentOwner = getEmfOwner();
      Translator parentTranslator = getTranslator();
      for (int i = 0; i < children.size(); i++)
      {
        child = (CacheEventNode)children.get(i);
        if (isChildIgnorable(child.getNodeName()))
        {
          addChildren(child.getChildren());
        }
        else
        {
          childTranslator = parentTranslator.findChild(child.getNodeName(), parentOwner, child.getVersionID());
          child.setTranslator(childTranslator);
          
          value = childTranslator.convertStringToValue(child.getNodeName(), null, child.getBuffer(), parentOwner);
          childTranslator.setMOFValue(parentOwner, value);
          if (childTranslator.isObjectMap())
          {
            child.setEmfOwner((Notifier)value);
            childTranslator.setTextValueIfNecessary(child.getBuffer(), child.getEmfOwner(), getVersionID());
          }
          child.processAttributes();
          child.updateEMF();
        }
        child.discard();
        child.releaseFromContainingPool();
      }
      children = null;
    }
  }
  
  public void addChild(CacheEventNode child)
  {
    if (children == null) {
      children = new ArrayList();
    }
    if ((parent != null) && (isIgnorable())) {
      parent.addChild(child);
    } else {
      children.add(child);
    }
  }
  
  protected void addChildren(List childrenArg)
  {
    if (children == null) {
      children = new ArrayList();
    }
    children.addAll(childrenArg);
  }
  
  public boolean removeChild(CacheEventNode child)
  {
    if (children == null) {
      return false;
    }
    return children.remove(child);
  }
  
  public List getChildren()
  {
    return children;
  }
  
  public ReadAheadHelper getReadAheadHelper()
  {
    if ((translator != null) && (translator.hasReadAheadNames())) {
      return translator.getReadAheadHelper(nodeName);
    }
    return null;
  }
  
  public void setAttributes(Attributes attr)
  {
    if ((attr != null) && (attr.getLength() > 0))
    {
      if (attributes == null) {
        attributes = new String[attr.getLength() * 2];
      }
      for (int i = 0; i < attr.getLength(); i++)
      {
        attributes[i] = attr.getQName(i);
        attributes[(i + attr.getLength())] = attr.getValue(i);
      }
    }
  }
  
  public void processAttributes()
  {
    if ((attributes != null) && (attributes.length > 0)) {
      if ((emfOwner != null) && (translator != null))
      {
        Translator attrTranslator = null;
        int limit = attributes.length / 2;
        Object value = null;
        for (int i = 0; i < limit; i++)
        {
          attrTranslator = translator.findChild(attributes[i], emfOwner, versionID);
          if (attrTranslator != null)
          {
            value = attrTranslator.convertStringToValue(attributes[(i + limit)], (EObject)emfOwner);
            attrTranslator.setMOFValue((EObject)emfOwner, value);
          }
        }
        attributes = null;
      }
    }
  }
  
  public void appendToBuffer(char[] data, int start, int length)
  {
    if ((parent != null) && (isIgnorable()))
    {
      parent.appendToBuffer(data, start, length);
      return;
    }
    if (buffer == null) {
      buffer = new StringBuffer();
    }
    buffer.insert(buffer.length(), data, start, length);
  }
  
  public void appendToBuffer(CacheEventNode record)
  {
    addChild(record);
  }
  
  public String getBuffer()
  {
    if (buffer == null) {
      return null;
    }
    return buffer.toString();
  }
  
  public Notifier getEmfOwner()
  {
    return emfOwner;
  }
  
  public CacheEventNode getParent()
  {
    return parent;
  }
  
  private void setParent(CacheEventNode record)
  {
    parent = record;
  }
  
  public Translator getTranslator()
  {
    return translator;
  }
  
  public void setEmfOwner(Notifier notifier)
  {
    emfOwner = notifier;
  }
  
  public void setTranslator(Translator translator)
  {
    this.translator = translator;
  }
  
  public String getNodeName()
  {
    return nodeName;
  }
  
  public int getVersionID()
  {
    if (parent == null) {
      try
      {
        return ((TranslatorResource)getEmfOwner()).getVersionID();
      }
      catch (RuntimeException localRuntimeException) {}
    }
    return versionID;
  }
  
  public void setVersionID(int i)
  {
    versionID = i;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CacheEventNode
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.ArrayList;
import java.util.Collection;
import org.xml.sax.Attributes;

public class CacheEventPool
{
  public static final int DEFAULT_CAPACITY = 10;
  public static final int DEFAULT_CAPACITY_INCREMENT = 25;
  private int poolCapacity = 10;
  private CacheEventStack availablePool = null;
  private Collection inusePool = null;
  
  public CacheEventPool()
  {
    this(10);
  }
  
  public CacheEventPool(int initialCapacity)
  {
    poolCapacity = (initialCapacity > 0 ? initialCapacity : 10);
    availablePool = new CacheEventStack();
    inusePool = new ArrayList(poolCapacity);
  }
  
  public CacheEventNode createCacheEventNode(TranslatorResource resource)
  {
    CacheEventNode adapter = fetchFreeNode();
    adapter.init(resource);
    return adapter;
  }
  
  public CacheEventNode createCacheEventNode(CacheEventNode parent, String nodeName, Attributes attributes)
  {
    CacheEventNode adapter = fetchFreeNode();
    adapter.init(parent, nodeName, attributes);
    return adapter;
  }
  
  public void releaseNode(CacheEventNode adapter)
  {
    freeNode(adapter);
  }
  
  public void freezePool()
  {
    availablePool.clear();
    availablePool = null;
  }
  
  public void warmPool()
  {
    ensureMinimumCapacity();
  }
  
  private CacheEventNode fetchFreeNode()
  {
    CacheEventNode result = null;
    if ((availablePool == null) || (availablePool.isEmpty())) {
      warmPool();
    }
    result = availablePool.pop();
    inusePool.add(result);
    
    return result;
  }
  
  private void freeNode(CacheEventNode adapter)
  {
    if (inusePool.remove(adapter)) {
      availablePool.push(adapter);
    }
    if (availablePool.size() > 5 * poolCapacity)
    {
      availablePool.clear();
      ensureMinimumCapacity();
    }
  }
  
  private void ensureMinimumCapacity()
  {
    if (availablePool == null) {
      availablePool = new CacheEventStack();
    }
    if (availablePool.size() < poolCapacity)
    {
      int minimumCapacity = poolCapacity - availablePool.size();
      for (int i = 0; i < minimumCapacity; i++) {
        availablePool.push(new CacheEventNode(this));
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CacheEventPool
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.ArrayList;
import java.util.EmptyStackException;

public class CacheEventStack
  extends ArrayList
{
  private static final long serialVersionUID = 1208895320149054103L;
  
  public CacheEventNode peek()
  {
    if (size() == 0) {
      throw new EmptyStackException();
    }
    return (CacheEventNode)get(size() - 1);
  }
  
  public CacheEventNode pop()
  {
    if (size() == 0) {
      throw new EmptyStackException();
    }
    return (CacheEventNode)remove(size() - 1);
  }
  
  public void push(CacheEventNode adapter)
  {
    add(adapter);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CacheEventStack
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.HashMap;
import java.util.Map;

public class CompatibilityPackageMappingRegistry
{
  public static CompatibilityPackageMappingRegistry INSTANCE = new CompatibilityPackageMappingRegistry();
  private Map prefixToPackageURIs = new HashMap();
  private Map packageURIsToPrefixes = new HashMap();
  
  public Map getPackageURIsToPrefixes()
  {
    return packageURIsToPrefixes;
  }
  
  public Map getPrefixToPackageURIs()
  {
    return prefixToPackageURIs;
  }
  
  public void registerPrefixToPackageURI(String prefix, String uri)
  {
    if ((prefix != null) && (uri != null))
    {
      prefixToPackageURIs.put(prefix, uri);
      packageURIsToPrefixes.put(uri, prefix);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilityPackageMappingRegistry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

public class CompatibilityResourceFactory
  extends XMIResourceFactoryImpl
{
  protected Map prefixToPackageURIs;
  protected Map packageURIsToPrefixes;
  
  public Map getPrefixToPackageURI()
  {
    return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
  }
  
  public Map getPackageURIsToPrefixes()
  {
    return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
  }
  
  public Resource createResource(URI uri)
  {
    return new CompatibilityXMIResourceImpl(uri);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilityResourceFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.util.Map;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler;
import org.xml.sax.Attributes;

public class CompatibilitySAXXMIHandler
  extends SAXXMIHandler
{
  protected static final String NULL_ATTRIB = "xsi:null";
  
  public CompatibilitySAXXMIHandler(XMLResource xmiResource, XMLHelper helper, Map options)
  {
    super(xmiResource, helper, options);
  }
  
  protected boolean isNull()
  {
    boolean isnull = super.isNull();
    if (!isnull) {
      isnull = attribs.getValue("xsi:null") != null;
    }
    return isnull;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilitySAXXMIHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.URIConverter;

public abstract interface CompatibilityURIConverter
  extends URIConverter
{
  public abstract URI deNormalize(URI paramURI);
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilityURIConverter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.impl.SAXWrapper;
import org.eclipse.emf.ecore.xmi.impl.XMILoadImpl;
import org.xml.sax.helpers.DefaultHandler;

public class CompatibilityXMILoadImpl
  extends XMILoadImpl
{
  public CompatibilityXMILoadImpl(XMLHelper helper)
  {
    super(helper);
  }
  
  protected DefaultHandler makeDefaultHandler()
  {
    return new SAXWrapper(new CompatibilitySAXXMIHandler(resource, helper, options));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilityXMILoadImpl
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.xmi.XMIResource;

public abstract interface CompatibilityXMIResource
  extends XMIResource
{
  public static final int FORMAT_EMF1 = 0;
  public static final int FORMAT_MOF5 = 1;
  
  public abstract void addOriginalPackageURI(String paramString1, String paramString2);
  
  public abstract int getFormat();
  
  public abstract void setFormat(int paramInt);
  
  public abstract boolean usesDefaultFormat();
  
  public abstract void removePreservingIds(EObject paramEObject);
}

/* Location:
 * Qualified Name:     org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.wst.common.internal.emf.resource;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.resource.impl.ResourceImpl.ContentsEList;
import org.eclipse.emf.ecore.xmi.XMLHelper;
import org.eclipse.emf.ecore.xmi.XMLLoad;
import org.eclipse.emf.ecore.xmi.XMLSave;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
import org.eclipse.wst.common.internal.emf.utilities.IDUtil;
import org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapter;
import org.eclipse.wst.common.internal.emf.utilities.ResourceIsLoadingAdapterFactory;

public class CompatibilityXMIResourceImpl
  extends XMIResourceImpl
  implements CompatibilityXMIResource
{
  protected static final String DEFAULT_ENCODING = "UTF-8";
  protected int format = 0;
  protected Map originalPackageURIs = new HashMap();
  private boolean preserveIDs = false;
  private static final String PLATFORM_PROTOCOL = "platform";
  private static final String PLATFORM_PLUGIN = "plugin";
  
  public CompatibilityXMIResourceImpl()
  {
    initDefaultSaveOptions();
  }
  
  public CompatibilityXMIResourceImpl(URI uri)
  {
    super(uri);
    initDefaultSaveOptions();
  }
  
  protected final XMLHelper createXMLHelper()
  {
    MappedXMIHelper helper = doCreateXMLHelper();
    helper.setPackageURIsToPrefixes(getPackageURIsToPrefixes());
    return helper;
  }
  
  protected MappedXMIHelper doCreateXMLHelper()
  {
    return new MappedXMIHelper(this, getPrefixToPackageURIs());
  }
  
  protected Map getPrefixToPackageURIs()
  {
    return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
  }
  
  protected Map getPackageURIsToPrefixes()
  {
    return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
  }
  
  public void addOriginalPackageURI(String packageUri, String originalUri)
  {
    originalPackageURIs.put(packageUri, originalUri);
  }
  
  public int getFormat()
  {
    return format;
  }
  
  public void setFormat(int format)
  {
    if (!isPlatformPluginResourceURI()) {
      this.format = format;
    }
  }
  
  private boolean isPlatformPluginResourceURI()
  {
    URI aURI = getURI();
    
    return (aURI != null) && ("platform".equals(uri.scheme())) && ("plugin".equals(uri.segment(0)));
  }
  
  public String getURIFragment(EObject eObject)
  {
    if (usesDefaultFormat()) {
      return super.getURIFragment(eObject);
    }
    return IDUtil.getOrAssignID(eObject, this);
  }
  
  public boolean usesDefaultFormat()
  {
    return format == 0;
  }
  
  protected XMLSave createXMLSave()
  {
    if (usesDefaultFormat()) {
      return super.createXMLSave();
    }
    return new CompatibilityXMISaveImpl(createXMLHelper());
  }
  
  public void doSave(OutputStream outputStream, Map options)
    throws IOException
  {
    super.doSave(outputStream, options);
  }
  
  protected void initDefaultSaveOptions()
  {
    if (defaultSaveOptions == null) {
      getDefaultSaveOptions();
    }
  }
  
  protected EObject getEObjectByID(String id)
  {
    if (idToEObjectMap != null)
    {
      EObject eObject = (EObject)idToEObjectMap.get(id);
      if (eObject != null) {
        return eObject;
      }
    }
    return null;
  }
  
  protected void unloaded(InternalEObject internalEObject)
  {
    internalEObject.eSetProxyURI(uri.appendFragment(super.getURIFragment(internalEObject)));
    internalEObject.eAdapters().clear();
  }
  
  public final void doLoad(InputStream inputStream, Map options)
    throws IOException
  {
    basicDoLoad(inputStream, options);
  }
  
  /**
   * @deprecated
   */
  protected void basicDoLoad(InputStream inputStream, Map options)
    throws IOException
  {
    super.doLoad(inputStream, options);
  }
  
  protected void init()
  {
    super.init();
    setEncoding("UTF-8");
  }
  
  protected XMLLoad createXMLLoad()
  {
    return new CompatibilityXMILoadImpl(createXMLHelper());
  }
  
  public void removePreservingIds(EObject rootObject)
  {
    setPreserveIDs(true);
    getContents().remove(rootObject);
  }
  
  public boolean isPreserveIDs()
  {
    return preserveIDs;
  }
  
  public void setPreserveIDs(boolean preserveIDs)
  {
    this.preserveIDs = preserveIDs;
  }
  
  protected void detachedHelper(EObject eObject)
  {
    if (modificationTrackingAdapter != null) {
      eObject.eAdapters().remove(modificationTrackingAdapter);
    }
    if (useUUIDs()) {
      DETACHED_EOBJECT_TO_ID_MAP.put(eObject, getID(eObject));
    }
    if ((!isPreserveIDs()) && (idToEObjectMap != null) && (eObjectToIDMap != null)) {
      idToEObjectMap.remove(eObjectToIDMap.remove(eObject));
    }
  }
  
  public void load(Map options)
    throws IOException
  {
    ResourceIsLoadingAdapter adapter = null;
    if (isLoaded)
    {
      adapter = ResourceIsLoadingAdapter.findAdapter(this);
      if (adapter != null) {
        adapter.waitForResourceToLoad();
      }
      return;
    }
    synchronized (this)
    {
      adapter = ResourceIsLoadingAdapter.findAdapter(this);
      if ((adapter == null) && (!isLoaded)) {
        addSynchronizationLoadingAdapter();
      }
    }
    if (adapter != null) {
      adapter.waitForResourceToLoad();
    } else {
      try
      {
        super.load(options);
      }
      catch (IOException ioe)
      {
        removeLoadingSynchronizationAdapter();
        throw ioe;
      }
      catch (RuntimeException re)
      {
        removeLoadingSynchronizationAdapter();
        throw re;
      }
      catch (Error e)
      {
        removeLoadingSynchronizationAdapter();
        throw e;
      }
    }
  }
  
  public void loadExisting(Map options)
    throws IOException
  {
    ResourceIsLoadingAdapter adapter = null;
    if (isLoaded)
    {
      adapter = ResourceIsLoadingAdapter.findAdapter(this);
      if (adapter != null) {
        adapter.waitForResourceToLoad();
      }
      return;
    }
    synchronized (this)
    {
      adapter = ResourceIsLoadingAdapter.findAdapter(this);
      if ((adapter == null) && (!isLoaded)) {
        addSynchronizationLoadingAdapter();
      }
    }
    if (adapter != null) {
      adapter.waitForResourceToLoad();
    } else {
      try
      {
        load(null, options);
      }
      catch (IOException ioe)
      {
        removeLoadingSynchronizationAdapter();
        throw ioe;
      }
      catch (RuntimeException re)
      {
        removeLoadingSynchronizationAdapter();
        throw re;
      }
      catch (Error e)
      {
        removeLoadingSynchronizationAdapter();
        throw e;
      }
    }
  }
  
  protected void addSynchronizationLoadingAdapter()
  {
    synchronized (eAdapters())
    {
      if (ResourceIsLoadingAdapter.findAdapter(this) == null) {
        eAdapters().add(ResourceIsLoadingAdapterFactory.INSTANCE.createResourceIsLoadingAdapter());
      }
    }
  }
  
  protected void removeLoadingSynchronizationAdapter()
  {
    ResourceIsLoadingAdapter adapter = ResourceIsLoadingAdapter.findAdapter(this);
    if (adapter != null)
    {
      adapter.forceRelease();
      eAdapters().remove(adapter);
    }
  }
  
  public boolean isResourceBeingLoaded(boolean isLoaded)
  {
    return (!this.isLoaded) && (isLoaded) && ((contents == null) || (contents.isEmpty()));
  }
  
  public EList getContents()
  {
    waitForResou
1 2 3 4 5 6 7 8 9 10 11

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