org.eclipse.jst.pagedesigner.jsp.core_1.2.0.v20100308

16:46:00.460 INFO  jd.cli.Main - Decompiling org.eclipse.jst.pagedesigner.jsp.core_1.2.0.v20100308.jar
package org.eclipse.jst.pagedesigner.jsp.core;

public abstract interface IJSPCoreConstants
{
  public static final String TAG_ATTRIBUTE = "attribute";
  public static final String TAG_BODY = "body";
  public static final String TAG_ELEMENT = "element";
  public static final String TAG_EXPRESSION = "expression";
  public static final String TAG_DECLARATION = "declaration";
  public static final String TAG_DIRECTIVE_INCLUDE = "directive.include";
  public static final String TAG_DIRECTIVE_PAGE = "directive.page";
  public static final String TAG_DIRECTIVE_TAGLIB = "directive.taglib";
  public static final String TAG_DOBODY = "doBody";
  public static final String TAG_FORWARD = "forward";
  public static final String TAG_GETPROPERTY = "getProperty";
  public static final String TAG_INCLUDE = "include";
  public static final String TAG_INVOKE = "invoke";
  public static final String TAG_OUTPUT = "output";
  public static final String TAG_PLUGIN = "plugin";
  public static final String TAG_ROOT = "root";
  public static final String TAG_SCRIPTLET = "scriptlet";
  public static final String TAG_SETPROPERTY = "setProperty";
  public static final String TAG_TEXT = "text";
  public static final String TAG_USEBEAN = "useBean";
  public static final String TAG_LEADING_DIRECTIVE = "directive.";
  public static final String ATTR_ALIGN = "align";
  public static final String ATTR_ARCHIVE = "archive";
  public static final String ATTR_BEANNAME = "beanName";
  public static final String ATTR_CLASS = "class";
  public static final String ATTR_CODE = "code";
  public static final String ATTR_CODEBASE = "codebase";
  public static final String ATTR_DOCTYPEROOTELEMENT = "doctype-root-element";
  public static final String ATTR_DOCTYPESYSTEM = "doctype-system";
  public static final String ATTR_DOCTYPEPUBLIC = "doctype-public";
  public static final String ATTR_FILE = "file";
  public static final String ATTR_FRAGMENT = "fragment";
  public static final String ATTR_HEIGHT = "height";
  public static final String ATTR_HSPACE = "hspace";
  public static final String ATTR_ID = "id";
  public static final String ATTR_IEPLUGINURL = "iepluginurl";
  public static final String ATTR_JREVERSION = "jreversion";
  public static final String ATTR_NAME = "name";
  public static final String ATTR_NSPLUGINURL = "nspluginurl";
  public static final String ATTR_OMITXMLDECLARATION = "omit-xml-declaration";
  public static final String ATTR_PAGE = "page";
  public static final String ATTR_PROPERTY = "property";
  public static final String ATTR_SCOPE = "scope";
  public static final String ATTR_TRIM = "trim";
  public static final String ATTR_TYPE = "type";
  public static final String ATTR_URI = "uri";
  public static final String ATTR_TAGDIR = "tagdir";
  public static final String ATTR_VALUE = "value";
  public static final String ATTR_VAR = "var";
  public static final String ATTR_VARREADER = "varReader";
  public static final String ATTR_VERSION = "version";
  public static final String ATTR_XMLNSJSP = "xmlns:jsp";
  public static final String ATTR_XMLNSTAGLIBPREFIX = "xmlns:taglibPrefix";
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.IJSPCoreConstants
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

public class JSPCorePlugin
  extends Plugin
{
  private static JSPCorePlugin plugin;
  private ResourceBundle resourceBundle;
  
  public JSPCorePlugin()
  {
    plugin = this;
    try
    {
      resourceBundle = 
        ResourceBundle.getBundle("org.eclipse.jst.pagedesigner.jsp.core.JSPCorePluginResources");
    }
    catch (MissingResourceException localMissingResourceException)
    {
      resourceBundle = null;
    }
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    super.start(context);
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    super.stop(context);
  }
  
  public static JSPCorePlugin getDefault()
  {
    return plugin;
  }
  
  public static String getResourceString(String key)
  {
    ResourceBundle bundle = getDefault().getResourceBundle();
    try
    {
      return bundle != null ? bundle.getString(key) : key;
    }
    catch (MissingResourceException localMissingResourceException) {}
    return key;
  }
  
  public ResourceBundle getResourceBundle()
  {
    return resourceBundle;
  }
  
  public static String getPluginId()
  {
    return getDefault().getBundle().getSymbolicName();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.JSPCorePlugin
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core;

public class ListenerList
{
  private int _size;
  private Object[] _listeners = null;
  private static final Object[] EmptyArray = new Object[0];
  
  public ListenerList(int capacity)
  {
    if (capacity < 1) {
      throw new IllegalArgumentException();
    }
    _listeners = new Object[capacity];
    _size = 0;
  }
  
  public synchronized void add(Object listener)
  {
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    for (int i = 0; i < _size; i++) {
      if (_listeners[i] == listener) {
        return;
      }
    }
    if (_size == _listeners.length)
    {
      Object[] temp = new Object[_size * 2 + 1];
      System.arraycopy(_listeners, 0, temp, 0, _size);
      _listeners = temp;
    }
    _listeners[(_size++)] = listener;
  }
  
  public synchronized Object[] getListeners()
  {
    if (_size == 0) {
      return EmptyArray;
    }
    Object[] result = new Object[_size];
    System.arraycopy(_listeners, 0, result, 0, _size);
    return result;
  }
  
  public synchronized void remove(Object listener)
  {
    if (listener == null) {
      throw new IllegalArgumentException();
    }
    for (int i = 0; i < _size; i++) {
      if (_listeners[i] == listener)
      {
        if (--_size == 0)
        {
          _listeners = new Object[1];
        }
        else
        {
          if (i < _size) {
            _listeners[i] = _listeners[_size];
          }
          _listeners[_size] = null;
        }
        return;
      }
    }
  }
  
  public void removeAll()
  {
    _listeners = new Object[0];
    _size = 0;
  }
  
  public int size()
  {
    return _size;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.ListenerList
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.el;

import java.util.ArrayList;
import java.util.List;
import org.apache.commons.el.ComplexValue;
import org.apache.commons.el.NamedValue;

public class ELParser
{
  private String _jsfExpression;
  private List _expressionList;
  
  public ELParser(String expression)
  {
    _jsfExpression = expression;
    init();
  }
  
  private void init()
  {
    Object parsedExpression = 
      JSFELParserHelper.parseExpression(_jsfExpression);
    if ((parsedExpression instanceof ComplexValue))
    {
      _expressionList = new ArrayList();
      _expressionList.add(((ComplexValue)parsedExpression).getPrefix());
      _expressionList.addAll(((ComplexValue)parsedExpression)
        .getSuffixes());
    }
    else if ((parsedExpression instanceof NamedValue))
    {
      _expressionList = new ArrayList();
      _expressionList.add(parsedExpression);
    }
  }
  
  public Object[] getElements()
  {
    if (_expressionList == null) {
      return null;
    }
    return _expressionList.toArray();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.el.ELParser
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.el;

import java.io.StringReader;
import org.apache.commons.el.Expression;
import org.apache.commons.el.ExpressionString;
import org.apache.commons.el.parser.ELParser;
import org.apache.commons.el.parser.ParseException;

public final class JSFELParserHelper
{
  public static String JSF_EL_LEFT_BRACE = "#{";
  public static String JSF_EL_RIGHT_BRACE = "}";
  
  public static Object parseExpression(String expressionString)
  {
    expressionString = toJspElExpression(expressionString);
    
    ELParser parser = new ELParser(new StringReader(expressionString));
    try
    {
      Object expression = parser.ExpressionString();
      if ((!(expression instanceof Expression)) && 
        (!(expression instanceof ExpressionString))) {
        return null;
      }
      return expression;
    }
    catch (ParseException localParseException) {}
    return null;
  }
  
  public static boolean isValidEL(String expressionString)
  {
    if ((expressionString == null) || (expressionString.length() == 0)) {
      return false;
    }
    return (expressionString.startsWith(JSF_EL_LEFT_BRACE)) && (expressionString.endsWith(JSF_EL_RIGHT_BRACE));
  }
  
  public static String trimELBrace(String expressionString)
  {
    if (!isValidEL(expressionString)) {
      return expressionString;
    }
    String trimedExpression = null;
    
    trimedExpression = expressionString.substring(JSF_EL_LEFT_BRACE
      .length(), expressionString.length() - 
      JSF_EL_RIGHT_BRACE.length());
    
    return trimedExpression;
  }
  
  public static String toJspElExpression(String expressionString)
  {
    StringBuffer sb = new StringBuffer(expressionString.length());
    int remainsPos = 0;
    for (int posOpenBrace = expressionString.indexOf('{'); posOpenBrace >= 0; posOpenBrace = expressionString
          .indexOf('{', remainsPos))
    {
      if (posOpenBrace > 0)
      {
        if (posOpenBrace - 1 > remainsPos) {
          sb.append(expressionString.substring(remainsPos, 
            posOpenBrace - 1));
        }
        if (expressionString.charAt(posOpenBrace - 1) == '$')
        {
          sb.append("${'${'}");
          remainsPos = posOpenBrace + 1;
          continue;
        }
        if (expressionString.charAt(posOpenBrace - 1) == '#')
        {
          sb.append("${");
          int posCloseBrace = indexOfMatchingClosingBrace(
            expressionString, posOpenBrace);
          sb.append(expressionString.substring(posOpenBrace + 1, 
            posCloseBrace + 1));
          remainsPos = posCloseBrace + 1;
          continue;
        }
        if (posOpenBrace > remainsPos) {
          sb.append(expressionString.charAt(posOpenBrace - 1));
        }
      }
      sb.append('{');
      remainsPos = posOpenBrace + 1;
    }
    sb.append(expressionString.substring(remainsPos));
    
    return new String(sb.toString());
  }
  
  private static int findQuote(String expressionString, int start)
  {
    int indexofSingleQuote = expressionString.indexOf('\'', start);
    int indexofDoubleQuote = expressionString.indexOf('"', start);
    return minIndex(indexofSingleQuote, indexofDoubleQuote);
  }
  
  private static int indexOfMatchingClosingBrace(String expressionString, int indexofOpeningBrace)
  {
    int len = expressionString.length();
    int i = indexofOpeningBrace + 1;
    do
    {
      if (i >= len) {
        throw new IllegalStateException(
          "Missing closing brace. Expression: '" + 
          expressionString + "'");
      }
      int indexofClosingBrace = expressionString.indexOf('}', i);
      i = minIndex(indexofClosingBrace, findQuote(expressionString, i));
      if (i < 0) {
        throw new IllegalStateException(
          "Missing closing brace. Expression: '" + 
          expressionString + "'");
      }
      if (i == indexofClosingBrace) {
        break;
      }
      i = indexOfMatchingClosingQuote(expressionString, i) + 1;
    } while (i != 0);
    throw new IllegalStateException(
      "Missing closing quote. Expression: '" + 
      expressionString + "'");
    
    return i;
  }
  
  private static int indexOfMatchingClosingQuote(String expressionString, int indexOfOpeningQuote)
  {
    char quote = expressionString.charAt(indexOfOpeningQuote);
    for (int i = expressionString.indexOf(quote, indexOfOpeningQuote + 1); i >= 0; i = expressionString
          .indexOf(quote, i + 1)) {
      if (!isEscaped(expressionString, i)) {
        return i;
      }
    }
    return -1;
  }
  
  private static boolean isEscaped(String expressionString, int i)
  {
    int escapeCharCount = 0;
    do
    {
      escapeCharCount++;i--;
    } while ((i >= 0) && (expressionString.charAt(i) == '\\'));
    return escapeCharCount % 2 != 0;
  }
  
  public static int minIndex(int a, int b)
  {
    return a < b ? a : b < 0 ? a : a < 0 ? b : b;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.el.JSFELParserHelper
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar;

import java.util.ArrayList;
import java.util.List;
import org.eclipse.jst.pagedesigner.jsp.core.ListenerList;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IChangeListener;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class DocumentPageVariableAdapter
  implements IDocumentPageVariableAdapter
{
  private IDOMDocument _document;
  private ListenerList _changeListeners = new ListenerList(2);
  private List _variableInfos = new ArrayList();
  private boolean _readingInfo = false;
  
  public DocumentPageVariableAdapter(IDOMDocument doc)
  {
    _document = doc;
  }
  
  public IVariableInfo[] getBeanInfos()
  {
    IVariableInfo[] ret = new IVariableInfo[_variableInfos.size()];
    return (IVariableInfo[])_variableInfos.toArray(ret);
  }
  
  public void addChangeListener(IChangeListener listener)
  {
    reReadInfo();
    _changeListeners.add(listener);
  }
  
  public void removeChangeListener(IChangeListener listener)
  {
    _changeListeners.remove(listener);
  }
  
  protected void fireChanged()
  {
    Object[] listeners = _changeListeners.getListeners();
    for (int i = 0; i < listeners.length; i++)
    {
      IChangeListener l = (IChangeListener)listeners[i];
      l.changed();
    }
  }
  
  public boolean isAdapterForType(Object type)
  {
    return IDocumentPageVariableAdapter.class.equals(type);
  }
  
  public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos)
  {
    switch (eventType)
    {
    case 1: 
    case 4: 
    case 5: 
      refresh();
    }
  }
  
  public void refresh()
  {
    reReadInfo();
  }
  
  /* Error */
  protected void reReadInfo()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 151	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_readingInfo	Z
    //   4: ifeq +4 -> 8
    //   7: return
    //   8: aload_0
    //   9: getfield 152	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_variableInfos	Ljava/util/List;
    //   12: astore_1
    //   13: aload_0
    //   14: new 82	java/util/ArrayList
    //   17: dup
    //   18: invokespecial 157	java/util/ArrayList:<init>	()V
    //   21: putfield 152	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_variableInfos	Ljava/util/List;
    //   24: aload_0
    //   25: aload_0
    //   26: getfield 154	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_document	Lorg/eclipse/wst/xml/core/internal/provisional/document/IDOMDocument;
    //   29: invokespecial 165	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:readNode	(Lorg/w3c/dom/Node;)V
    //   32: aload_0
    //   33: aload_1
    //   34: aload_0
    //   35: getfield 152	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_variableInfos	Ljava/util/List;
    //   38: invokespecial 166	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:isSame	(Ljava/util/List;Ljava/util/List;)Z
    //   41: ifne +18 -> 59
    //   44: aload_0
    //   45: invokevirtual 162	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:fireChanged	()V
    //   48: goto +11 -> 59
    //   51: astore_2
    //   52: aload_0
    //   53: iconst_0
    //   54: putfield 151	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_readingInfo	Z
    //   57: aload_2
    //   58: athrow
    //   59: aload_0
    //   60: iconst_0
    //   61: putfield 151	org/eclipse/jst/pagedesigner/jsp/core/internal/pagevar/DocumentPageVariableAdapter:_readingInfo	Z
    //   64: return
    // Line number table:
    //   Java source line #136	-> byte code offset #0
    //   Java source line #137	-> byte code offset #7
    //   Java source line #140	-> byte code offset #8
    //   Java source line #141	-> byte code offset #13
    //   Java source line #142	-> byte code offset #24
    //   Java source line #143	-> byte code offset #32
    //   Java source line #144	-> byte code offset #44
    //   Java source line #146	-> byte code offset #51
    //   Java source line #147	-> byte code offset #52
    //   Java source line #148	-> byte code offset #57
    //   Java source line #147	-> byte code offset #59
    //   Java source line #149	-> byte code offset #64
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	65	0	this	DocumentPageVariableAdapter
    //   12	22	1	oldInfo	List
    //   51	7	2	localObject	Object
    // Exception table:
    //   from	to	target	type
    //   8	51	51	finally
  }
  
  private boolean isSame(List oldInfo, List list)
  {
    if (oldInfo.size() != list.size()) {
      return false;
    }
    int i = 0;
    for (int size = oldInfo.size(); i < size; i++)
    {
      IVariableInfo info1 = (IVariableInfo)oldInfo.get(i);
      IVariableInfo info2 = (IVariableInfo)list.get(i);
      if (info1 == null) {
        return false;
      }
      if (!info1.equals(info2)) {
        return false;
      }
    }
    return true;
  }
  
  private void readNode(Node node)
  {
    if (((node instanceof INodeNotifier)) && ((node instanceof Element)))
    {
      Element element = (Element)node;
      Object obj = ((INodeNotifier)element)
        .getAdapterFor(IPageVariableAdapter.class);
      if ((obj instanceof IPageVariableAdapter))
      {
        IPageVariableAdapter adapter = (IPageVariableAdapter)obj;
        if (adapter.supportMultipleVariable(element))
        {
          List infos = ((IPageVariableAdapter)obj)
            .getVariableInfos(element);
          if (infos != null) {
            _variableInfos.addAll(infos);
          }
        }
        else
        {
          IVariableInfo info = adapter.getVariableInfo(element);
          if (info != null) {
            _variableInfos.add(info);
          }
        }
      }
    }
    NodeList childNodes = node.getChildNodes();
    if (childNodes != null)
    {
      int i = 0;
      for (int length = childNodes.getLength(); i < length; i++)
      {
        Node childNode = childNodes.item(i);
        readNode(childNode);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.DocumentPageVariableAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.w3c.dom.Element;

public class PageVariableAdapter
  implements IPageVariableAdapter
{
  static final PageVariableAdapter _instance = new PageVariableAdapter();
  
  public static PageVariableAdapter getInstance()
  {
    return _instance;
  }
  
  public boolean isAdapterForType(Object type)
  {
    return IPageVariableAdapter.class.equals(type);
  }
  
  private IDocumentPageVariableAdapter getDocumentAdapter(INodeNotifier notifier)
  {
    if ((notifier instanceof IDOMNode))
    {
      IDOMModel model = ((IDOMNode)notifier).getModel();
      if (model != null)
      {
        IDOMDocument document = model.getDocument();
        if (document != null) {
          return (IDocumentPageVariableAdapter)document
            .getAdapterFor(IDocumentPageVariableAdapter.class);
        }
      }
    }
    return null;
  }
  
  public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos)
  {
    IDocumentPageVariableAdapter docadapter = getDocumentAdapter(notifier);
    switch (eventType)
    {
    case 4: 
      docadapter.refresh();
      break;
    case 1: 
    case 5: 
      if (((notifier instanceof Element)) && 
        (supportVariableInfo((Element)notifier))) {
        docadapter.refresh();
      }
      break;
    }
  }
  
  public boolean supportMultipleVariable(Element element)
  {
    return false;
  }
  
  private boolean supportVariableInfo(Element element)
  {
    return PageVariableAdatperRegistry.getInstance().getTagVarDescriptor(
      element) != null;
  }
  
  public IVariableInfo getVariableInfo(Element element)
  {
    TagVarDescriptor desc = PageVariableAdatperRegistry.getInstance()
      .getTagVarDescriptor(element);
    if (desc == null) {
      return null;
    }
    String name;
    if (desc.isVarNameIsAttr())
    {
      String name = element.getAttribute(desc.getVarName());
      if ((name == null) || (name.length() == 0)) {
        return null;
      }
    }
    else
    {
      name = desc.getVarName();
    }
    String type;
    if (desc.isVarTypeStringIsAttr())
    {
      String type = element.getAttribute(desc.getVarTypeString());
      if ((type == null) || (type.length() == 0)) {
        return null;
      }
    }
    else
    {
      type = desc.getVarTypeString();
    }
    return new VariableInfo(name, desc.getVarTypeMode(), type);
  }
  
  public List getVariableInfos(Element element)
  {
    IVariableInfo info = getVariableInfo(element);
    if (info == null) {
      return Collections.EMPTY_LIST;
    }
    List ret = new ArrayList(1);
    ret.add(info);
    return ret;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.PageVariableAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar;

import java.util.HashMap;
import java.util.Map;
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.jst.pagedesigner.jsp.core.JSPCorePlugin;
import org.eclipse.jst.pagedesigner.jsp.core.util.CMUtil;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.w3c.dom.Element;

public class PageVariableAdatperRegistry
{
  public static final String PAGEVAR = "pageVar";
  public static final String TAGLIB = "taglib";
  public static final String TAG = "tag";
  public static final String VARNAME = "varName";
  public static final String VARNAMEISATTR = "varNameIsAttr";
  public static final String VARTYPEMODE = "varTypeMode";
  public static final String TAGNAME = "tagName";
  public static final String VARTYPESTRING = "varTypeString";
  public static final String VARTYPESTRINGISATTR = "varTypeStringIsAttr";
  public static final String URI = "uri";
  private static PageVariableAdatperRegistry _instance = null;
  private Map _registry;
  private TagVarDescriptor _useBeanDescriptor;
  
  public static PageVariableAdatperRegistry getInstance()
  {
    if (_instance == null) {
      _instance = new PageVariableAdatperRegistry();
    }
    return _instance;
  }
  
  private PageVariableAdatperRegistry()
  {
    _registry = readAllDescriptors();
  }
  
  private Map readAllDescriptors()
  {
    Map map = new HashMap();
    
    IExtensionPoint extensionPoint = Platform.getExtensionRegistry()
      .getExtensionPoint(JSPCorePlugin.getPluginId(), "pageVar");
    IExtension[] extensions = extensionPoint.getExtensions();
    for (int i = 0; i < extensions.length; i++)
    {
      IExtension ext = extensions[i];
      IConfigurationElement[] facs = ext.getConfigurationElements();
      for (int j = 0; j < facs.length; j++) {
        if (facs[j].getName().equals("taglib"))
        {
          String uri = facs[j].getAttribute("uri");
          if ((uri != null) && (uri.length() != 0))
          {
            IConfigurationElement[] tags = facs[j].getChildren("tag");
            for (int k = 0; k < tags.length; k++)
            {
              TagVarDescriptor desc = new TagVarDescriptor();
              
              String tag = tags[k].getAttribute("tagName");
              String varName = tags[k].getAttribute("varName");
              boolean varNameIsAttr = "true".equalsIgnoreCase(tags[k]
                .getAttribute("varNameIsAttr"));
              String varTypeString = tags[k]
                .getAttribute("varTypeString");
              boolean varTypeStringIsAttr = "true"
                .equalsIgnoreCase(tags[k]
                .getAttribute("varTypeStringIsAttr"));
              String varTypeModeString = tags[k]
                .getAttribute("varTypeMode");
              int varTypeMode = toVarTypeMode(varTypeModeString);
              
              desc.setVarName(varName);
              desc.setVarNameIsAttr(varNameIsAttr);
              desc.setVarTypeMode(varTypeMode);
              desc.setVarTypeString(varTypeString);
              desc.setVarTypeStringIsAttr(varTypeStringIsAttr);
              desc.setTagName(tag);
              
              map.put(uri + "#" + tag, desc);
            }
          }
        }
      }
    }
    return map;
  }
  
  public static int toVarTypeMode(String varTypeModeString)
  {
    if ("CLASSNAME".equalsIgnoreCase(varTypeModeString)) {
      return 0;
    }
    if ("EXPRESSION".equalsIgnoreCase(varTypeModeString)) {
      return 1;
    }
    if ("EXPRESSION_COLLECTION_ITEM".equalsIgnoreCase(varTypeModeString)) {
      return 2;
    }
    if ("BUNDLE".equalsIgnoreCase(varTypeModeString)) {
      return 3;
    }
    return 1;
  }
  
  public TagVarDescriptor getTagVarDescriptor(String uri, String tagname)
  {
    String key = uri + "#" + tagname;
    return (TagVarDescriptor)_registry.get(key);
  }
  
  private TagVarDescriptor getJSPTagVarDescriptor(String localName)
  {
    if ("useBean".equals(localName))
    {
      if (_useBeanDescriptor == null)
      {
        _useBeanDescriptor = new TagVarDescriptor();
        _useBeanDescriptor.setVarName("id");
        _useBeanDescriptor.setVarNameIsAttr(true);
        _useBeanDescriptor.setVarTypeMode(0);
        _useBeanDescriptor
          .setVarTypeString("class");
        _useBeanDescriptor.setVarTypeStringIsAttr(true);
      }
      return _useBeanDescriptor;
    }
    return null;
  }
  
  public TagVarDescriptor getTagVarDescriptor(Element target)
  {
    if ((target instanceof IDOMElement))
    {
      IDOMElement xmlEle = (IDOMElement)target;
      CMElementDeclaration decl = CMUtil.getElementDeclaration(xmlEle);
      if (decl != null)
      {
        if (CMUtil.isJSP(decl)) {
          return getJSPTagVarDescriptor(xmlEle.getLocalName());
        }
        String uri = CMUtil.getTagURI(decl);
        if (uri != null) {
          return getTagVarDescriptor(uri, xmlEle.getLocalName());
        }
      }
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.PageVariableAdatperRegistry
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar;

public class TagVarDescriptor
{
  private String _varName;
  private boolean _varNameIsAttr;
  private String _varTypeString;
  private boolean _varTypeStringIsAttr;
  private int _varTypeMode;
  private String _tagName;
  
  public String getVarName()
  {
    return _varName;
  }
  
  public void setVarName(String varName)
  {
    _varName = varName;
  }
  
  public boolean isVarNameIsAttr()
  {
    return _varNameIsAttr;
  }
  
  public void setVarNameIsAttr(boolean varNameIsAttr)
  {
    _varNameIsAttr = varNameIsAttr;
  }
  
  public int getVarTypeMode()
  {
    return _varTypeMode;
  }
  
  public void setVarTypeMode(int varTypeMode)
  {
    _varTypeMode = varTypeMode;
  }
  
  public String getVarTypeString()
  {
    return _varTypeString;
  }
  
  public void setVarTypeString(String varTypeString)
  {
    _varTypeString = varTypeString;
  }
  
  public boolean isVarTypeStringIsAttr()
  {
    return _varTypeStringIsAttr;
  }
  
  public void setVarTypeStringIsAttr(boolean varTypeStringIsAttr)
  {
    _varTypeStringIsAttr = varTypeStringIsAttr;
  }
  
  public void setTagName(String tag)
  {
    _tagName = tag;
  }
  
  public String getTagName()
  {
    return _tagName;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.TagVarDescriptor
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar;

import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo;

public class VariableInfo
  implements IVariableInfo
{
  private String _typeInfo;
  private int _mode;
  private String _name;
  
  public VariableInfo(String name, int mode, String typeInfo)
  {
    _name = name;
    _mode = mode;
    _typeInfo = typeInfo;
  }
  
  public String getName()
  {
    return _name;
  }
  
  public int getMode()
  {
    return _mode;
  }
  
  public String getTypeInfoString()
  {
    return _typeInfo;
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if ((obj instanceof VariableInfo))
    {
      VariableInfo info = (VariableInfo)obj;
      
      return (_mode == _mode) && (equals(_name, _name)) && (equals(_typeInfo, _typeInfo));
    }
    return false;
  }
  
  private boolean equals(String s1, String s2)
  {
    if (s1 == null) {
      return s2 == null;
    }
    return s1.equals(s2);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.VariableInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar;

import java.util.EventListener;

public abstract interface IChangeListener
  extends EventListener
{
  public abstract void changed();
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.IChangeListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar;

public abstract interface IPageVariablesProvider
{
  public abstract void refresh();
  
  public abstract IVariableInfo[] getBeanInfos();
  
  public abstract void addChangeListener(IChangeListener paramIChangeListener);
  
  public abstract void removeChangeListener(IChangeListener paramIChangeListener);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar;

public abstract interface IVariableInfo
{
  public static final int CLASSNAME = 0;
  public static final int EXPRESSION = 1;
  public static final int EXPRESSION_LISTITEM = 2;
  public static final int RESOURCEBUNDLE = 3;
  
  public abstract String getName();
  
  public abstract int getMode();
  
  public abstract String getTypeInfoString();
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter;

import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IPageVariablesProvider;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;

public abstract interface IDocumentPageVariableAdapter
  extends IPageVariablesProvider, INodeAdapter
{}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IDocumentPageVariableAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter;

import java.util.List;
import org.eclipse.jst.pagedesigner.jsp.core.pagevar.IVariableInfo;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
import org.w3c.dom.Element;

public abstract interface IPageVariableAdapter
  extends INodeAdapter
{
  public abstract boolean supportMultipleVariable(Element paramElement);
  
  public abstract IVariableInfo getVariableInfo(Element paramElement);
  
  public abstract List getVariableInfos(Element paramElement);
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.IPageVariableAdapter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter;

import org.eclipse.jst.pagedesigner.jsp.core.internal.pagevar.PageVariableAdapter;
import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;

public class PageVariableAdapterFactory
  extends AbstractAdapterFactory
{
  public PageVariableAdapterFactory()
  {
    super(IPageVariableAdapter.class, true);
  }
  
  protected INodeAdapter createAdapter(INodeNotifier target)
  {
    if ((target instanceof IDOMElement)) {
      return PageVariableAdapter.getInstance();
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.pagevar.adapter.PageVariableAdapterFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.jst.pagedesigner.jsp.core.util;

import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument;
import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration;
import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
import org.eclipse.wst.xml.core.internal.provisional.contentmodel.CMNodeWrapper;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;

public class CMUtil
{
  public static String getTagURI(CMElementDeclaration decl)
  {
    if ((decl instanceof CMNodeWrapper)) {
      decl = (CMElementDeclaration)((CMNodeWrapper)decl)
        .getOriginNode();
    }
    if ((decl instanceof TLDElementDeclaration))
    {
      CMDocument doc = ((TLDElementDeclaration)decl).getOwnerDocument();
      if ((doc instanceof TLDDocument)) {
        return ((TLDDocument)doc).getUri();
      }
    }
    return null;
  }
  
  public static CMElementDeclaration getElementDeclaration(IDOMElement element)
  {
    INodeNotifier notifier = (INodeNotifier)element.getOwnerDocument();
    if (notifier == null) {
      return null;
    }
    ModelQueryAdapter mqa = (ModelQueryAdapter)notifier
      .getAdapterFor(ModelQueryAdapter.class);
    if (mqa == null) {
      return null;
    }
    return mqa.getModelQuery().getCMElementDeclaration(element);
  }
  
  public static TLDElementDeclaration getTLDElementDeclaration(IDOMElement element)
  {
    CMNode decl = getElementDeclaration(element);
    if ((decl instanceof CMNodeWrapper)) {
      decl = ((CMNodeWrapper)decl).getOriginNode();
    }
    if ((decl instanceof TLDElementDeclaration)) {
      return (TLDElementDeclaration)decl;
    }
    return null;
  }
  
  public static boolean isJSP(CMElementDeclaration decl)
  {
    if (!decl.supports("isJSP")) {
      return false;
    }
    return 
      ((Boolean)decl.getProperty("isJSP")).booleanValue();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.jst.pagedesigner.jsp.core.util.CMUtil
 * 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