org.eclipse.jst.common.annotations.core_1.1.300.v201004141630

16:45:39.908 INFO  jd.cli.Main - Decompiling org.eclipse.jst.common.annotations.core_1.1.300.v201004141630.jar
package org.eclipse.jst.common.internal.annotations.core;

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

public class AnnotatedCommentHandler
  implements TagParseEventHandler
{
  private Map annotations;
  private Token annotationToken;
  
  public void annotationTag(Token tag)
  {
    annotationToken = tag;
  }
  
  public void endOfTag(int pos) {}
  
  public void attribute(Token name, int equalsPosition, Token value)
  {
    if ((value.getText() == null) || (value.getText().length() == 0)) {
      getAnnotations().put(annotationToken.getText(), name.getText());
    } else {
      getAnnotations().put(name.getText(), value.getText());
    }
  }
  
  public Map getAnnotations()
  {
    if (annotations == null) {
      annotations = new HashMap();
    }
    return annotations;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotatedCommentHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

public class AnnotationTagParser
{
  private TagParseEventHandler handler;
  private char[] input;
  int pos;
  int endOfLastGoodAttParse;
  private Object annotationLock = new Object();
  
  public AnnotationTagParser(TagParseEventHandler tp)
  {
    if (tp == null) {
      throw new IllegalArgumentException(AnnotationsCoreResources.AnnotationTagParser_0);
    }
    handler = tp;
  }
  
  private boolean eos()
  {
    return pos >= input.length;
  }
  
  private boolean isWS(char c)
  {
    return (c == ' ') || (c == '\n') || (c == '\r') || (c == '\t');
  }
  
  private void skipWS()
  {
    while ((pos < input.length) && ((isWS(input[pos])) || (input[pos] == '*'))) {
      pos += 1;
    }
  }
  
  private char peek()
  {
    return input[pos];
  }
  
  private char nextChar()
  {
    return input[(pos++)];
  }
  
  private boolean isNextChar(char c)
  {
    if (eos()) {
      return false;
    }
    return peek() == c;
  }
  
  private boolean isIDChar(char c)
  {
    return (!isWS(c)) && (c != '=') && (c != '@') && (c != '"');
  }
  
  private Token collectID()
  {
    StringBuffer b = new StringBuffer(16);
    Token t = new Token();
    
    t.setBeginning(pos);
    while ((!eos()) && (isIDChar(peek()))) {
      b.append(nextChar());
    }
    t.setEnd(pos - 1);
    t.setText(b.toString());
    return t;
  }
  
  private Token expectAttribName()
  {
    if (eos()) {
      return null;
    }
    int save = pos;
    
    Token retval = collectID();
    if (retval.length() == 0)
    {
      pos = save;
      return null;
    }
    return retval;
  }
  
  private Token expectTag()
  {
    if (eos()) {
      return null;
    }
    int savePos = pos;
    if (nextChar() != '@') {
      return null;
    }
    if ((eos()) || (isWS(peek()))) {
      return null;
    }
    Token retval = expectAttribName();
    if (retval.length() == 0) {
      pos = (savePos + 1);
    }
    retval.setBeginning(savePos);
    
    endOfLastGoodAttParse = pos;
    return retval;
  }
  
  private Token expectQuotedValue()
  {
    skipWS();
    if (eos()) {
      return null;
    }
    Token tok = new Token();
    
    tok.setBeginning(pos);
    if (peek() != '"') {
      return null;
    }
    nextChar();
    if (eos()) {
      return null;
    }
    StringBuffer b = new StringBuffer(64);
    while ((!eos()) && (peek() != '"')) {
      b.append(nextChar());
    }
    if (!eos()) {
      nextChar();
    }
    tok.setEnd(pos - 1);
    tok.setText(b.toString());
    return tok;
  }
  
  private boolean expectAssign()
  {
    if (eos()) {
      return false;
    }
    if (nextChar() == '=') {
      return true;
    }
    pos -= 1;
    return false;
  }
  
  private Token mkNullToken()
  {
    Token retval = new Token();
    
    retval.setBeginning(pos);
    retval.setEnd(pos - 1);
    retval.setText("");
    return retval;
  }
  
  private boolean parseNextAttribute()
  {
    skipWS();
    if (eos()) {
      return false;
    }
    Token key = collectID();
    if ((key == null) || (key.length() == 0)) {
      return false;
    }
    skipWS();
    if (eos())
    {
      handler.attribute(key, -1, mkNullToken());
      return false;
    }
    int eqPos = pos;
    if (!expectAssign())
    {
      handler.attribute(key, -1, mkNullToken());
      return false;
    }
    skipWS();
    if (eos())
    {
      handler.attribute(key, eqPos, mkNullToken());
      return false;
    }
    Token value = expectQuotedValue();
    if (value == null)
    {
      value = collectID();
      if (isNextChar('='))
      {
        pos = value.getBeginning();
        value = mkNullToken();
      }
    }
    endOfLastGoodAttParse = pos;
    handler.attribute(key, eqPos, value);
    return true;
  }
  
  private void parseAttributes()
  {
    while ((!eos()) && (parseNextAttribute())) {}
  }
  
  private void skipToTagChar()
  {
    while ((!eos()) && (peek() != '@')) {
      nextChar();
    }
  }
  
  public void setParserInput(char[] text)
  {
    synchronized (annotationLock)
    {
      input = text;
      pos = 0;
      endOfLastGoodAttParse = 0;
    }
  }
  
  public void setParserInput(String text)
  {
    setParserInput(text.toCharArray());
  }
  
  public void parse()
  {
    synchronized (annotationLock)
    {
      while (!eos())
      {
        skipToTagChar();
        Token tag = expectTag();
        if (tag == null) {
          break;
        }
        handler.annotationTag(tag);
        parseAttributes();
        handler.endOfTag(endOfLastGoodAttParse);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationTagParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;

class AnnotationsAdapter$1
  extends EStructuralFeatureImpl
{}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsAdapter.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.wst.common.internal.emf.utilities.CloneablePublic;

public class AnnotationsAdapter
  extends AdapterImpl
  implements CloneablePublic
{
  public static final String GENERATED = "generated";
  protected static final String ADAPTER_TYPE = AnnotationsAdapter.class.getName();
  public static final EStructuralFeature NOTIFICATION_FEATURE = new EStructuralFeatureImpl() {};
  private Map annotationsMap;
  
  public Object clone()
  {
    return null;
  }
  
  public static void addAnnotations(EObject emfObject, String name, Object value)
  {
    if (emfObject == null) {
      return;
    }
    AnnotationsAdapter adapter = getAdapter(emfObject);
    adapter.addAnnotations(name, value);
  }
  
  public static Object getAnnotations(EObject emfObject, String name)
  {
    if (emfObject == null) {
      return null;
    }
    return internalGetAnnotations(emfObject, name);
  }
  
  protected static Object internalGetAnnotations(EObject emfObject, String name)
  {
    if (emfObject == null) {
      return null;
    }
    AnnotationsAdapter adapter = getAdapter(emfObject);
    return adapter == null ? internalGetAnnotations(emfObject.eContainer(), name) : adapter.getAnnotations(name);
  }
  
  public static Object removeAnnotations(EObject emfObject, String name)
  {
    if (emfObject == null) {
      return null;
    }
    AnnotationsAdapter adapter = getAdapter(emfObject);
    return adapter.removeAnnotations(name);
  }
  
  protected void addAnnotations(String name, Object value)
  {
    getAnnnotations().put(name, value);
  }
  
  protected Object getAnnotations(String name)
  {
    return getAnnnotations().get(name);
  }
  
  protected Object removeAnnotations(String name)
  {
    return getAnnnotations().remove(name);
  }
  
  protected Map getAnnnotations()
  {
    if (annotationsMap == null) {
      annotationsMap = new HashMap();
    }
    return annotationsMap;
  }
  
  protected static AnnotationsAdapter getAdapter(EObject emfObject)
  {
    AnnotationsAdapter adapter = retrieveExistingAdapter(emfObject);
    return adapter == null ? createAdapter(emfObject) : adapter;
  }
  
  protected static AnnotationsAdapter createAdapter(EObject emfObject)
  {
    AnnotationsAdapter adapter = new AnnotationsAdapter();
    adapter.setTarget(emfObject);
    emfObject.eAdapters().add(adapter);
    return adapter;
  }
  
  protected static AnnotationsAdapter retrieveExistingAdapter(EObject emfObject)
  {
    return (AnnotationsAdapter)EcoreUtil.getExistingAdapter(emfObject, ADAPTER_TYPE);
  }
  
  public boolean isAdapterForType(Object type)
  {
    return ADAPTER_TYPE.equals(type);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import org.eclipse.osgi.util.NLS;

public final class AnnotationsCoreResources
  extends NLS
{
  private static final String BUNDLE_NAME = "annotationcore";
  public static String TagSpec_3;
  public static String TagSpec_4;
  public static String TagAttribSpec_6;
  public static String AnnotationTagParser_0;
  public static String AnnotationTagParser_1;
  public static String AnnotationTagRegistry_0;
  public static String AnnotationTagRegistry_9;
  
  static
  {
    NLS.initializeMessages("annotationcore", AnnotationsCoreResources.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsCoreResources
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jem.util.logger.proxy.Logger;

public class AnnotationsProviderManager$Descriptor
{
  public static final String EXTENSION_PT_PLUGIN = "org.eclipse.jst.common.annotations.core";
  public static final String ANNOTATIONS_PROVIDER = "annotationsProvider";
  public static final String CLASSNAME = "className";
  private final IConfigurationElement configElement;
  
  public AnnotationsProviderManager$Descriptor(IConfigurationElement aConfigElement)
  {
    configElement = aConfigElement;
  }
  
  public IAnnotationsProvider createInstance()
  {
    IAnnotationsProvider instance = null;
    try
    {
      instance = (IAnnotationsProvider)configElement.createExecutableExtension("className");
    }
    catch (CoreException e)
    {
      Logger.getLogger().logError(e);
    }
    return instance;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsProviderManager.Descriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.jem.util.RegistryReader;
import org.eclipse.jem.util.logger.proxy.Logger;

public class AnnotationsProviderManager
  extends RegistryReader
{
  public static final AnnotationsProviderManager INSTANCE = new AnnotationsProviderManager();
  private List annotationsProviders;
  
  static
  {
    INSTANCE.readRegistry();
  }
  
  public static class Descriptor
  {
    public static final String EXTENSION_PT_PLUGIN = "org.eclipse.jst.common.annotations.core";
    public static final String ANNOTATIONS_PROVIDER = "annotationsProvider";
    public static final String CLASSNAME = "className";
    private final IConfigurationElement configElement;
    
    public Descriptor(IConfigurationElement aConfigElement)
    {
      configElement = aConfigElement;
    }
    
    public IAnnotationsProvider createInstance()
    {
      IAnnotationsProvider instance = null;
      try
      {
        instance = (IAnnotationsProvider)configElement.createExecutableExtension("className");
      }
      catch (CoreException e)
      {
        Logger.getLogger().logError(e);
      }
      return instance;
    }
  }
  
  public AnnotationsProviderManager()
  {
    super("org.eclipse.jst.common.annotations.core", "annotationsProvider");
  }
  
  public boolean readElement(IConfigurationElement element)
  {
    if (!element.getName().equals("annotationsProvider")) {
      return false;
    }
    addAnnotationsProvider(new Descriptor(element));
    return true;
  }
  
  protected void addAnnotationsProvider(Descriptor descriptor)
  {
    IAnnotationsProvider provider = descriptor.createInstance();
    if (provider != null) {
      getAnnotationsProviders().add(provider);
    }
  }
  
  public List getAnnotationsProviders()
  {
    if (annotationsProviders == null) {
      annotationsProviders = new ArrayList();
    }
    return annotationsProviders;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsProviderManager
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.wst.common.internal.emf.resource.Translator;

public class AnnotationsTranslator
  extends Translator
{
  private AnnotatedCommentHandler handler;
  private AnnotationTagParser parser;
  public static final AnnotationsTranslator INSTANCE = new AnnotationsTranslator();
  
  public AnnotationsTranslator()
  {
    super("#comment", AnnotationsAdapter.NOTIFICATION_FEATURE, 1024);
  }
  
  public AnnotationsTranslator(String domNameAndPath)
  {
    super(domNameAndPath, AnnotationsAdapter.NOTIFICATION_FEATURE, 1024);
  }
  
  public AnnotationsTranslator(String domNameAndPath, int style)
  {
    super(domNameAndPath, AnnotationsAdapter.NOTIFICATION_FEATURE, style | 0x400);
  }
  
  public void setMOFValue(EObject emfObject, Object value)
  {
    if (value == null) {
      return;
    }
    getHandler().getAnnotations().clear();
    getParser().setParserInput(value.toString());
    getParser().parse();
    
    Map annotations = getHandler().getAnnotations();
    for (Iterator keys = annotations.keySet().iterator(); keys.hasNext();)
    {
      String name = (String)keys.next();
      AnnotationsAdapter.addAnnotations(emfObject, name, annotations.get(name));
    }
  }
  
  public boolean isSetMOFValue(EObject emfObject)
  {
    return getMOFValue(emfObject) != null;
  }
  
  public Object getMOFValue(EObject emfObject)
  {
    return AnnotationsAdapter.getAnnotations(emfObject, "generated");
  }
  
  public void unSetMOFValue(EObject emfObject)
  {
    AnnotationsAdapter.removeAnnotations(emfObject, "generated");
  }
  
  public boolean featureExists(EObject emfObject)
  {
    return true;
  }
  
  public boolean isDataType()
  {
    return true;
  }
  
  public boolean isMapFor(Object aFeature, Object oldValue, Object newValue)
  {
    return aFeature == feature;
  }
  
  protected AnnotatedCommentHandler getHandler()
  {
    if (handler == null) {
      handler = new AnnotatedCommentHandler();
    }
    return handler;
  }
  
  protected AnnotationTagParser getParser()
  {
    if (parser == null) {
      parser = new AnnotationTagParser(getHandler());
    }
    return parser;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.AnnotationsTranslator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.ICompilationUnit;

public abstract interface IAnnotationsProvider
{
  public abstract boolean isAnnotated(EObject paramEObject);
  
  public abstract ICompilationUnit getPrimaryAnnotatedCompilationUnit(EObject paramEObject);
  
  public abstract String getPrimaryTagset(EObject paramEObject);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.IAnnotationsProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

public abstract interface TagParseEventHandler
{
  public abstract void annotationTag(Token paramToken);
  
  public abstract void endOfTag(int paramInt);
  
  public abstract void attribute(Token paramToken1, int paramInt, Token paramToken2);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.TagParseEventHandler
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.common.internal.annotations.core;

public class Token
{
  private String text;
  private int beginning;
  private int end;
  
  public int getBeginning()
  {
    return beginning;
  }
  
  public int getEnd()
  {
    return end;
  }
  
  public String getText()
  {
    return text;
  }
  
  public void setBeginning(int i)
  {
    beginning = i;
  }
  
  public void setEnd(int i)
  {
    end = i;
  }
  
  public void setText(String string)
  {
    text = string;
  }
  
  public int length()
  {
    return text.length();
  }
  
  public boolean immediatelyPrecedes(int srcPos)
  {
    return end + 1 == srcPos;
  }
  
  public boolean contains(int srcPos)
  {
    return (srcPos >= beginning) && (srcPos <= end);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.common.internal.annotations.core.Token
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
1

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