Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils')
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/BodyHelper.java345
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CacheManager.java85
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CommandUtil.java85
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/DOMUtil.java260
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/EntityMap.java212
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLSpecialCharHelper.java464
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLUtil.java106
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ICacheEntryCreator.java31
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java92
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/IntFlexArray.java76
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java286
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JavaUtil.java97
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/NodeLocationComparator.java77
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/PreviewUtil.java391
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ProjectResolver.java521
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectManyHelper.java196
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectionHelper.java384
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/StructuredModelUtil.java70
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/UriAdapterFactory.java52
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/WebAppUtil.java64
-rw-r--r--jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/XMLUtil.java100
21 files changed, 0 insertions, 3994 deletions
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/BodyHelper.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/BodyHelper.java
deleted file mode 100644
index 2a20b1a72..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/BodyHelper.java
+++ /dev/null
@@ -1,345 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-
-import javax.xml.namespace.QName;
-
-import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
-import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
-import org.eclipse.jst.pagedesigner.adapters.IBodyInfo;
-import org.eclipse.jst.pagedesigner.adapters.internal.BodyInfo;
-import org.eclipse.jst.pagedesigner.dom.DOMPosition;
-import org.eclipse.jst.pagedesigner.dom.DOMRefPosition;
-import org.eclipse.jst.pagedesigner.dom.DOMRefPosition2;
-import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * This class helps location insertion position to inside correct body or doc
- * prefix. NOTE: this class only doing limited support on doc level position
- * validation. Element specific position validation will be done in other
- * places.
- *
- * @author mengbo
- */
-public class BodyHelper {
- // bit flags used for child skipping.
- /**
- * Bit flag for empty text node
- */
- public static final int EMPTY_TEXT = 1;
-
- /**
- * Bit flag for comment node
- */
- public static final int COMMENT = 2;
-
- /**
- * Bit flag for HEAD node
- */
- public static final int HEADER = 3;
-
- /**
- *
- * @param child
- * @return boolean
- */
- private static boolean isSkippableChild(Node parent, Node child, int flag) {
- if ((flag & COMMENT) != 0 && child.getNodeType() == Node.COMMENT_NODE)
- return true;
- if ((flag & EMPTY_TEXT) != 0 && child instanceof IDOMText
- && ((IDOMText) child).isElementContentWhitespace())
- return true;
-
- if ((flag & HEADER) != 0 && child.getNodeType() == Node.ELEMENT_NODE) {
- String uri = CMUtil.getElementNamespaceURI((Element) child);
- IBodyInfo parentInfo = getBodyInfo((IDOMNode) parent);
- if (parentInfo != null
- && parentInfo.isBodyHeader((IDOMNode) parent, uri,
- ((Element) child).getLocalName()))
- return true;
- }
- return false;
- }
-
- /**
- * check whether uri/tag should be header of any body container that is
- * ancester of the start node.
- *
- * @param start
- * @param uri
- * @param tag
- * @return IDOMNode
- */
- public static IDOMNode findHeaderContainer(IDOMNode start, String uri,
- String tag) {
- while (start != null) {
- IBodyInfo designInfo = getBodyInfo(start);
- if (designInfo != null && designInfo.isBodyContainer(start)) {
- if (designInfo.isBodyHeader(start, uri, tag))
- return start;
- }
- start = (IDOMNode) start.getParentNode();
- }
- return null;
- }
-
- /**
- * find the closest body insertion point, to make it as deep as possible.
- * (Move into as more body as possible)
- * @param position
- * @return IDOMPosition
- */
- public static IDOMPosition findBodyInsertLocation(IDOMPosition position) {
- // forward first.
- Node reference = position.getNextSiblingNode();
- Node container = position.getContainerNode();
- while (reference != null) {
- IBodyInfo info = getBodyInfo((IDOMNode) reference);
- if (info != null && info.isBodyContainer((IDOMNode) reference)) {
- // good, we find a body!
- position = new DOMPosition(reference, 0);
- return findBodyInsertLocation(position);
- }
- if (isSkippableChild(container, reference, EMPTY_TEXT | COMMENT
- | HEADER)) {
- reference = reference.getNextSibling();
- continue;
- }
- break;
- }
-
- // backward
- reference = position.getPreviousSiblingNode();
- while (reference != null) {
- IBodyInfo info = getBodyInfo((IDOMNode) reference);
- if (info != null && info.isBodyContainer((IDOMNode) reference)) {
- // good, we find a body!
- position = new DOMPosition(reference, reference.getChildNodes()
- .getLength());
- return findBodyInsertLocation(position);
- }
- // XXX: not skip header here. So if there is some header with wrong
- // location, we will respect user.
- if (isSkippableChild(container, reference, EMPTY_TEXT | COMMENT)) {
- reference = reference.getPreviousSibling();
- continue;
- }
- break;
- }
-
- // not find any body at same level as the insertion point.
- return position;
- }
-
- /**
- * The element type identified by "uri" and "tag" is going to be inserted
- * into the document. This method is used to adjust the insert position so
- * it can be put into correct body or header section.
- * @param uri
- * @param tag
- * @param position
- * @return IDOMPosition
- *
- */
- public static IDOMPosition adjustInsertPosition(String uri, String tag,
- IDOMPosition position) {
- IDOMNode parent = (IDOMNode) position.getContainerNode();
- IBodyInfo designInfo = getBodyInfo(parent);
- if (designInfo == null) {
- return position; // should not happen.
- }
-
- IDOMNode headerContainer = findHeaderContainer(parent, uri, tag);
-
- if (headerContainer == null) {
- // the new node is not header.
- if (shouldIgnoreAdjust(uri, tag)) {
- return position;
- }
-
- // new node is not body header. So should place inside the inner most
- // body.
- if (!designInfo.isBodyContainer(parent)) {
- return position; // it's parent is not body, so we suggest
- // it's parent already correctly located, and respect user's
- // choice.
- }
-
- // ok, we are inside some body, but we don't know whether we are in
- // the inner most body.
- // try to find a body container at same level and see whether we can
- // move into that body.
- return findBodyInsertLocation(position);
- }
- // good, we find a body container and the new node should be header
- // of it.
- Node child = headerContainer.getFirstChild();
-
- // if parent is different from headerContainer, then
- // child!=referenceHolder[0] will always be true
- while (child != null) // && child != refNode)
- {
- Comparator comp = NodeLocationComparator.getInstance();
- // Currently the comparator deels with tags like taglib and
- // loadbundle particularly, comparasion result 0
- // means it didn't compare the tags.
- if (comp.compare(child, tag) < 0
- || (comp.compare(child, tag) == 0 && isSkippableChild(
- headerContainer, child, COMMENT | EMPTY_TEXT
- | HEADER))) {
- child = child.getNextSibling();
- } else {
- break;
- }
- }
- if (child != null) {
- return new DOMRefPosition(child, false);
- }
- return new DOMPosition(parent, parent.getChildNodes()
- .getLength());
- }
-
- /**
- * Find the position to insert a header element into the specified parent.
- *
- * @param uri
- * @param tag
- * @param parent
- * @param ref
- */
- public static void findHeaderInsertPosition(String uri, String tag,
- Node parent, Node[] ref) {
- Node child = parent.getFirstChild();
- while (child != null) {
- Comparator comp = NodeLocationComparator.getInstance();
- if (comp.compare(child, tag) < 0
- || (comp.compare(child, tag) == 0 && isSkippableChild(
- parent, child, COMMENT | EMPTY_TEXT | HEADER))) {
- child = child.getNextSibling();
- } else {
- break;
- }
- }
- ref[0] = child;
- return;
- }
-
- /**
- * @param position
- * @param body
- * @param defaultPrefix
- * @return the new dom position based on the insert. May return null if
- * insert fails.
- */
- public static IDOMPosition insertBody(IDOMPosition position, QName body,
- String defaultPrefix) {
- IBodyInfo bodyInfo = getBodyInfo((IDOMNode) position.getContainerNode());
-
- Node node = position.getContainerNode();
- final Node originalContainer = node;
- final Node nextSibling = position.getNextSiblingNode();
-
- // create the body element first.
- Document ownerDoc;
- if (node instanceof Document) {
- ownerDoc = (Document) node;
- } else {
- ownerDoc = node.getOwnerDocument();
- }
- if (ownerDoc == null) {
- return null; // should not happen
- }
-
- final String prefix = JSPUtil.getOrCreatePrefix(((IDOMNode) node).getModel(),
- body.getNamespaceURI(), defaultPrefix);
- final Element ele = ownerDoc.createElement((prefix == null ? ""
- : (prefix + ":"))
- + body.getLocalPart());
-
- // need to find out the insertion point
- while (node instanceof IDOMNode) {
- if (bodyInfo.isBodyContainer((IDOMNode) node)) {
- // ok, node is a body container.
- // we could create the new node as child of node and move all
- // node's none header children
- // as children of the new node.
-
- NodeList nl = node.getChildNodes();
- ArrayList list = new ArrayList();
- for (int i = 0; i < nl.getLength(); i++) {
- Node child = nl.item(i);
- if (isSkippableChild(node, child, HEADER | COMMENT
- | EMPTY_TEXT)) {
- continue;
- }
- list.add(nl.item(i));
- }
- for (int i = 0; i < list.size(); i++) {
- ele.appendChild((Node) list.get(i));
- }
- node.appendChild(ele);
-
- if (node == originalContainer) {
- if (nextSibling == null) {
- return new DOMRefPosition2(ele, true);
- } else if (nextSibling.getParentNode() == ele) {
- // next sibling is not in header part
- return new DOMRefPosition(nextSibling, false);
- } else {
- return new DOMPosition(ele, 0);
- }
- }
- return position;
- }
- node = node.getParentNode();
- }
- // should not happen, because document and documentfragment node will
- // always be body node
- // so if reach here, means the position is not in document.
- return null;
- }
-
- /**
- * For certain special tags, do not following the "header"/"body" separation
- * and can't fit into the relocation process.
- *
- * @param uri
- * @param tag
- * @return true if tag is an element that should be moved in response to
- * body insert.
- */
- public static boolean shouldIgnoreAdjust(String uri, String tag) {
- // FIXME:
- return (ITLDConstants.URI_HTML.equalsIgnoreCase(uri) && "script"
- .equalsIgnoreCase(tag))
- || (ITLDConstants.URI_JSP.equals(uri));
- }
-
- /**
- * @param node
- * @return the body info corresponding to node (should we use a node adapter?)
- */
- public static IBodyInfo getBodyInfo(IDOMNode node) {
- // TODO: in the future, when bodyinfo is no longer singleton, we'll use
- // adapter mechanism.
- return BodyInfo.getInstance();
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CacheManager.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CacheManager.java
deleted file mode 100644
index 548328177..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CacheManager.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-
-/**
- * This is a cache manager. It will use the ICacheEntryCreator interface to
- * manage creating new item and dispose old item.
- *
- * @author mengbo
- * @version 1.5
- */
-public class CacheManager {
- ICacheEntryCreator _creator;
-
- int _maxSize;
-
- // key --> value
- Map _map = new HashMap();
-
- // keep track of LRU
- LinkedList _keys = new LinkedList();
-
- /**
- * @param creator
- * @param maxSize
- */
- public CacheManager(ICacheEntryCreator creator, int maxSize) {
- _creator = creator;
- _maxSize = maxSize;
- if (_maxSize <= 0) {
- _maxSize = 10;
- }
- }
-
- /**
- * @param key
- * @return the cache entry for key
- */
- public Object getEntry(Object key) {
- Object result = _map.get(key);
- if (result == null) {
- // not existed yet.
- if (_map.size() >= _maxSize) {
- // we need to remove the oldest one.
- Object keyRemove = _keys.removeFirst();
- Object objToRemove = _map.remove(keyRemove);
- _creator.dispose(keyRemove, objToRemove);
- }
- result = _creator.createEntry(key);
- _keys.addLast(key);
- _map.put(key, result);
- return result;
- }
- _keys.remove(key);
- _keys.addLast(key);
- return result;
- }
-
- /**
- * Dispose the cache
- */
- public void disposeAll() {
- _keys.clear();
- for (Iterator iter = _map.keySet().iterator(); iter.hasNext();) {
- Object key = iter.next();
- Object entry = _map.get(key);
- _creator.dispose(key, entry);
- }
- _map.clear();
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CommandUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CommandUtil.java
deleted file mode 100644
index b86284f22..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/CommandUtil.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.jst.jsf.common.metadata.query.ITaglibDomainMetaDataModelContext;
-import org.eclipse.jst.jsf.common.metadata.query.TaglibDomainMetaDataQueryHelper;
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IStructuredDocumentContextResolverFactory;
-import org.eclipse.jst.jsf.context.resolver.structureddocument.IWorkspaceContextResolver;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContext;
-import org.eclipse.jst.jsf.context.structureddocument.IStructuredDocumentContextFactory;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
-import org.eclipse.jst.pagedesigner.editors.palette.TagToolPaletteEntry;
-import org.eclipse.jst.pagedesigner.itemcreation.CreationData;
-import org.eclipse.jst.pagedesigner.itemcreation.ITagCreator;
-import org.eclipse.jst.pagedesigner.itemcreation.internal.TagCreationFactory;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Element;
-
-/**
- * @author mengbo
- * @version 1.5
- */
-public class CommandUtil {
- private static final Logger _log = PDPlugin.getLogger(CommandUtil.class);
-
- /**
- * @param tagItem
- * @param model
- * @param domPosition
- * @param customizationData
- * @return the element inserted or null if failed
- */
- public static Element excuteInsertion(TagToolPaletteEntry tagItem,
- IDOMModel model, IDOMPosition domPosition, IAdaptable customizationData) {
- try
- {
- IStructuredDocument doc = model.getDocument().getStructuredDocument();
-
- IStructuredDocumentContext context =
- IStructuredDocumentContextFactory.INSTANCE.getContext(doc, -1);
- IWorkspaceContextResolver resolver =
- IStructuredDocumentContextResolverFactory.INSTANCE.getWorkspaceContextResolver(context);
-
- IProject project = resolver.getProject();
-
- final ITaglibDomainMetaDataModelContext modelContext =
- TaglibDomainMetaDataQueryHelper
- .createMetaDataModelContext(project, tagItem.getURI());
-
- // TODO: note that the constructor currently causes the prefix defn
- // to be added to the target doc. This should be moved into
- // an ensure method in the AbstractTagCreator
- final CreationData creationData =
- new CreationData(tagItem, model, domPosition, modelContext, customizationData);
-
- ITagCreator tagCreator =
- TagCreationFactory.getInstance().createTagCreator(creationData.getTagId());
-
- if (tagCreator == null)
- {
- return null;//should never get here!
- }
-
- return tagCreator.createTag(creationData);
- } catch (Exception e) {
- _log.error("Problem creating tag "+tagItem.getTagName()+" at:" + domPosition + "\n", e);
- }
- return null;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/DOMUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/DOMUtil.java
deleted file mode 100644
index 098d28552..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/DOMUtil.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-/**
- * @author mengbo
- */
-public class DOMUtil {
- /**
- * @param parent
- * @param tag
- * @return the list of child elements of parent that are Elements
- * and that have name 'tag' ignoring case
- */
- public static List getChildElementsByTagIgnoreCase(Element parent,
- String tag) {
- List ret = new ArrayList();
- NodeList nodeList = parent.getChildNodes();
- for (int i = 0, size = nodeList.getLength(); i < size; i++) {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String t = node.getNodeName();
- if (tag.equalsIgnoreCase(t)) {
- ret.add(node);
- }
- }
- }
- return ret;
- }
-
- /**
- * @param ele
- * @return the element value of the TEXT_NODE children of element
- * concat'd together
- */
- public static String getTextElementValue(Element ele) {
- StringBuffer buffer = new StringBuffer();
- Node node = ele.getFirstChild();
- while (node != null) {
- if (node.getNodeType() == Node.TEXT_NODE) {
- buffer.append(node.getNodeValue());
- } else if (node.getNodeType() == Node.CDATA_SECTION_NODE) {
- buffer.append(node.getNodeValue());
- }
- node = node.getNextSibling();
- }
- return buffer.toString();
- }
-
- /**
- * @param element
- * @param string
- * @return the attribute named string on element ignoring case in the comparison
- * or null if not found
- */
- public static String getAttributeIgnoreCase(Element element, String string) {
- NamedNodeMap map = element.getAttributes();
- for (int i = 0; i < map.getLength(); i++) {
- Node attr = map.item(i);
- if (string.equalsIgnoreCase(attr.getNodeName())) {
- return attr.getNodeValue();
- }
- }
- return null;
- }
-
- /**
- * @param parent
- * @param tags
- * @return the list of children of parent with name in tags ignoring case
- */
- public static List getChildrenByTagsIgnoreCase(Element parent, String[] tags) {
- List result = new ArrayList();
- NodeList nodeList = parent.getChildNodes();
- for (int i = 0, size = nodeList.getLength(); i < size; i++) {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- String t = node.getNodeName();
- for (int k = 0; k < tags.length; k++) {
- if (tags[k].equalsIgnoreCase(t)) {
- result.add(node);
- break;
- }
- }
- }
- }
- return result;
- }
-
- /**
- * @param ele
- */
- public static void removeAllChildren(Element ele) {
- ((ElementImpl) ele).removeChildNodes();
- }
-
- /**
- * @param ele
- * @param value
- */
- public static void setTextElementValue(Element ele, String value) {
- removeAllChildren(ele);
- Text txt = ele.getOwnerDocument().createTextNode(value);
- ele.appendChild(txt);
- }
-
- /**
- * @param ele
- * @param attr
- * @param defaultvalue
- * @return the integer attribute of ele called attr. Default value
- * is returned if the attribute is not found.
- */
- public static int getIntAttributeIgnoreCase(Element ele, String attr,
- int defaultvalue) {
- if (ele == null) {
- return defaultvalue;
- }
- String attrvalue = getAttributeIgnoreCase(ele, attr);
- if (attrvalue == null) {
- return defaultvalue;
- }
- try {
- return Integer.parseInt(attrvalue);
- } catch (NumberFormatException ex) {
- return defaultvalue;
- }
- }
-
- /**
- * get all child elements
- *
- * @param ele
- * @return the list of element children of type ELEMENT_NODE
- */
- public static List getElementChildren(Element ele) {
- List ret = new ArrayList();
- NodeList nodeList = ele.getChildNodes();
- for (int i = 0, size = nodeList.getLength(); i < size; i++) {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ret.add(node);
- }
- }
- return ret;
- }
-
- /**
- * judge whether element has an attribute named attrName
- *
- * @param ele
- * @param attrName
- * @return true if element has attribute called attrName ignoring
- * case in the comparison.
- */
- public static boolean hasAttribute(Element ele, String attrName) {
- NamedNodeMap map = ele.getAttributes();
- for (int i = 0; i < map.getLength(); i++) {
- Node attr = map.item(i);
- if (attr.getNodeName().equalsIgnoreCase(attrName)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * @param node
- * @param sb
- */
- public static void nodeToString(Node node, StringBuffer sb) {
- int type = node.getNodeType();
- switch (type) {
- case Node.DOCUMENT_NODE:
- sb.append("<?xml version=\"1.0\" ?>");
- nodeToString(((Document) node).getDocumentElement(), sb);
- break;
-
- case Node.ELEMENT_NODE:
- sb.append("<");
- sb.append(node.getNodeName());
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- Node attr = attrs.item(i);
- sb.append(" " + attr.getNodeName() + "=\""
- + attr.getNodeValue() + "\"");
- }
-
- NodeList children = node.getChildNodes();
- if (children != null) {
- int len = children.getLength();
- if (len != 0) {
- sb.append(">");
- }
- for (int i = 0; i < len; i++) {
- nodeToString(children.item(i), sb);
- }
- }
- break;
-
- case Node.ENTITY_REFERENCE_NODE:
- sb.append("&");
- sb.append(node.getNodeName());
- sb.append(";");
- break;
-
- case Node.CDATA_SECTION_NODE:
- sb.append("<![CDATA[");
- sb.append(node.getNodeValue());
- sb.append("]]>");
- break;
-
- case Node.TEXT_NODE:
- sb.append(node.getNodeValue());
- break;
-
- case Node.PROCESSING_INSTRUCTION_NODE:
- sb.append("<?");
- sb.append(node.getNodeName());
- String data = node.getNodeValue();
- {
- sb.append(" ");
- sb.append(data);
- }
- sb.append("?>");
- break;
- }
-
- if (type == Node.ELEMENT_NODE) {
- if (node.getFirstChild() != null) {
- sb.append("</");
- sb.append(node.getNodeName());
- sb.append(">");
- } else {
- sb.append("/>");
- }
-
- }
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/EntityMap.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/EntityMap.java
deleted file mode 100644
index 0b68bad6d..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/EntityMap.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-
-/**
- * @author mengbo
- */
-public class EntityMap {
- private static Logger _log = PDPlugin.getLogger(EntityMap.class);
-
- /**
- * @param s
- * @return s translated for HTML entities.
- */
- public static String translate(String s) {
- char[] array = s.toCharArray();
- StringBuffer buffer = new StringBuffer();
- int posi = 0;
- int len = array.length;
- while (posi < len) {
- if (array[posi] != '&') {
- buffer.append(replaceBadEntity(array[posi++]));
- continue;
- }
-
- // now array[posi] == '&'
- int lastPosi = posi;
- posi++;
- if (posi < len && array[posi] == '#') {
- posi++;
- }
- while (posi < len) {
- if (!Character.isLetterOrDigit(array[posi]))
- {
- break;
- }
- posi++;
- }
- // now posi>=array.length or array[posi] is non letter or digit
- String str = new String(array, lastPosi, posi - lastPosi);
- if (translateEntity(str, buffer)) {
- // translated, skip the ';'
- if (posi < len && array[posi] == ';') {
- posi++;
- }
- }
-
- if (posi == len) {
- return buffer.toString();
- }
- }
- return buffer.toString();
- }
-
- /**
- * Translate entity maps and compact whitespace. For heading and training
- * space, will not trim, only compact (making multiple whitespace to become
- * a single ' ' char).
- * @param s
- * @return the result string.
- */
- public static String translateAndCompact(String s) {
- char[] array = s.toCharArray();
- StringBuffer buffer = new StringBuffer();
- int posi = 0;
- int len = array.length;
- while (posi < len) {
- if (HTMLUtil.isHTMLWhitespace(array[posi])) {
- while (++posi < len && HTMLUtil.isHTMLWhitespace(array[posi]))
- {
- // no body
- // loop until we have find non-whitepspace or endof array
- }
-
- buffer.append(' ');
- continue;
- }
- if (array[posi] != '&') {
- buffer.append(replaceBadEntity(array[posi++]));
- continue;
- }
-
- // now array[posi] == '&'
- int lastPosi = posi;
- posi++;
- if (posi < len && array[posi] == '#') {
- posi++;
- }
- while (posi < len) {
- if (!Character.isLetterOrDigit(array[posi])) {
- break;
- }
- posi++;
- }
- // now posi>=array.length or array[posi] is non letter or digit
- String str = new String(array, lastPosi, posi - lastPosi);
-
- if (translateEntity(str, buffer)) {
- // translated, skip the ';'
- if (posi < len && array[posi] == ';') {
- posi++;
- }
- }
-
- if (posi == len) {
- return buffer.toString();
- }
- }
- return buffer.toString();
- }
-
- /**
- * if can translate will return true and append the result string if can't
- * translate will return false and append original string
- *
- * @param s
- * the form &#number or &letterordigit without the trailing ";"
- * @param strBuf
- * @return true the translation can be done
- */
- public static boolean translateEntity(String s, StringBuffer strBuf) {
- int i = HTMLSpecialCharHelper.getSpecial(s); // HTMLSpecialCharHelper
- // support without
- // traning ';'
- if (i != -1) {
- strBuf.append((char) i);
- return true;
- }
- if (s.length() > 2 && s.charAt(1) == '#') {
- String number;
- number = s.substring(2);
- try {
- int n;
- if (number.length() > 0
- && (number.charAt(0) == 'x' || number.charAt(0) == 'X')) {
- n = Integer.parseInt(number.substring(1), 16);
- } else {
- n = Integer.parseInt(number);
- }
- strBuf.append(replaceBadEntity((char) n));
- return true;
- } catch (Exception ex) {
- // Error in integer formating
- _log.info("Error occurred in integer formatting", ex); //$NON-NLS-1$
- strBuf.append(s);
- return false;
- }
- }
- strBuf.append(s);
- return false;
- }
-
- /**
- * In HTML &#149; is sometimes used (mostly based on CP 1252), but is
- * illegal, because it does not exist in Unicode
- *
- * @param n
- * @return
- * see http://www.w3.org/Talks/1999/0830-tutorial-unicode-mjd/slide27-0.html
- */
- private static char replaceBadEntity(char n) {
- if (n < 132 || n > 156)
- return n;
- switch (n) {
- case 132:
- return (char) 8222;
- case 133:
- return (char) 8230;
- case 134:
- return (char) 8224;
- case 135:
- return (char) 8225;
- case 139:
- return (char) 8249;
- case 140:
- return (char) 338;
- case 145:
- return (char) 8216;
- case 146:
- return (char) 8217;
- case 147:
- return (char) 8220;
- case 148:
- return (char) 8221;
- case 149:
- return (char) 8226;
- case 151:
- return (char) 8212;
- case 153:
- return (char) 8482;
- case 155:
- return (char) 8250;
- case 156:
- return (char) 339;
- default:
- return n;
- }
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLSpecialCharHelper.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLSpecialCharHelper.java
deleted file mode 100644
index 495919830..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLSpecialCharHelper.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Enumeration;
-import java.util.Hashtable;
-
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-
-/**
- * entity map support.
- *
- * @author mengbo
- */
-public class HTMLSpecialCharHelper {
- private static Logger _log = PDPlugin
- .getLogger(HTMLSpecialCharHelper.class);
-
- private static Hashtable _table;
-
- private static Hashtable _reverse;
- static {
- _table = new Hashtable(256);
-
- _table.put(Integer.valueOf(34), "&quot;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(38), "&amp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(60), "&lt;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(62), "&gt;"); //$NON-NLS-1$
-
- _table.put(Integer.valueOf(160), "&nbsp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(161), "&iexcl;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(162), "&cent;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(163), "&pound;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(164), "&curren;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(165), "&yen;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(166), "&brvbar;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(167), "&sect;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(168), "&uml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(169), "&copy;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(170), "&ordf;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(171), "&laquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(172), "&not;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(173), "&shy;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(174), "&reg;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(175), "&macr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(176), "&deg;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(177), "&plusmn;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(178), "&sup2;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(179), "&sup3;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(180), "&acute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(181), "&micro;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(182), "&para;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(183), "&middot;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(184), "&cedil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(185), "&sup1;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(186), "&ordm;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(187), "&raquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(188), "&frac14;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(189), "&frac12;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(190), "&frac34;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(191), "&iquest;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(192), "&Agrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(193), "&Aacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(194), "&Acirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(195), "&Atilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(196), "&Auml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(197), "&Aring;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(198), "&AElig;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(199), "&Ccedil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(200), "&Egrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(201), "&Eacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(202), "&Ecirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(203), "&Euml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(204), "&Igrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(205), "&Iacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(206), "&Icirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(207), "&Iuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(208), "&ETH;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(209), "&Ntilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(210), "&Ograve;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(211), "&Oacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(212), "&Ocirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(213), "&Otilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(214), "&Ouml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(215), "&times;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(216), "&Oslash;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(217), "&Ugrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(218), "&Uacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(219), "&Ucirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(220), "&Uuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(221), "&Yacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(222), "&THORN;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(223), "&szlig;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(224), "&agrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(225), "&aacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(226), "&acirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(227), "&atilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(228), "&auml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(229), "&aring;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(230), "&aelig;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(231), "&ccedil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(232), "&egrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(233), "&eacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(234), "&ecirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(235), "&euml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(236), "&igrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(237), "&iacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(238), "&icirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(239), "&iuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(240), "&eth;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(241), "&ntilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(242), "&ograve;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(243), "&oacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(244), "&ocirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(245), "&otilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(246), "&ouml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(247), "&divide;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(248), "&oslash;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(249), "&ugrave;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(250), "&uacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(251), "&ucirc;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(252), "&uuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(253), "&yacute;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(254), "&thorn;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(255), "&yuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(402), "&fnof;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(913), "&Alpha;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(914), "&Beta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(915), "&Gamma;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(916), "&Delta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(917), "&Epsilon;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(918), "&Zeta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(919), "&Eta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(920), "&Theta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(921), "&Iota;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(922), "&Kappa;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(923), "&Lambda;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(924), "&Mu;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(925), "&Nu;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(926), "&Xi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(927), "&Omicron;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(928), "&Pi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(929), "&Rho;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(931), "&Sigma;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(932), "&Tau;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(933), "&Upsilon;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(934), "&Phi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(935), "&Chi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(936), "&Psi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(937), "&Omega;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(945), "&alpha;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(946), "&beta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(947), "&gamma;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(948), "&delta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(949), "&epsilon;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(950), "&zeta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(951), "&eta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(952), "&theta;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(953), "&iota;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(954), "&kappa;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(955), "&lambda;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(956), "&mu;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(957), "&nu;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(958), "&xi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(959), "&omicron;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(960), "&pi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(961), "&rho;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(962), "&sigmaf;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(963), "&sigma;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(964), "&tau;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(965), "&upsilon;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(966), "&phi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(967), "&chi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(968), "&psi;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(969), "&omega;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(977), "&thetasym;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(978), "&upsih;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(982), "&piv;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8226), "&bull;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8230), "&hellip;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8242), "&prime;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8243), "&Prime;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8254), "&oline;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8260), "&frasl;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8472), "&weierp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8465), "&image;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8476), "&real;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8482), "&trade;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8501), "&alefsym;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8592), "&larr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8593), "&uarr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8594), "&rarr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8595), "&darr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8596), "&harr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8629), "&crarr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8656), "&lArr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8657), "&uArr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8658), "&rArr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8659), "&dArr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8660), "&hArr;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8704), "&forall;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8706), "&part;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8707), "&exist;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8709), "&empty;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8711), "&nabla;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8712), "&isin;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8713), "&notin;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8715), "&ni;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8719), "&prod;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8722), "&sum;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8722), "&minus;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8727), "&lowast;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8730), "&radic;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8733), "&prop;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8734), "&infin;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8736), "&ang;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8869), "&and;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8870), "&or;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8745), "&cap;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8746), "&cup;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8747), "&int;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8756), "&there4;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8764), "&sim;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8773), "&cong;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8773), "&asymp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8800), "&ne;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8801), "&equiv;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8804), "&le;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8805), "&ge;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8834), "&sub;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8835), "&sup;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8836), "&nsub;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8838), "&sube;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8839), "&supe;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8853), "&oplus;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8855), "&otimes;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8869), "&perp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8901), "&sdot;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8968), "&lceil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8969), "&rceil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8970), "&lfloor;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8971), "&rfloor;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9001), "&lang;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9002), "&rang;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9674), "&loz;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9824), "&spades;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9827), "&clubs;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9829), "&hearts;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(9830), "&diams;"); //$NON-NLS-1$
-
- _table.put(Integer.valueOf(338), "&OElig;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(339), "&oelig;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(352), "&Scaron;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(353), "&scaron;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(376), "&Yuml;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(710), "&circ;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(732), "&tilde;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8194), "&ensp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8195), "&emsp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8201), "&thinsp;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8204), "&zwnj;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8205), "&zwj;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8206), "&lrm;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8207), "&rlm;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8211), "&ndash;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(151), "&mdash;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8216), "&lsquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8217), "&rsquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8218), "&sbquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8220), "&ldquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8221), "&rdquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8222), "&bdquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8224), "&dagger;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8225), "&Dagger;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8240), "&permil;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8249), "&lsaquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8250), "&rsaquo;"); //$NON-NLS-1$
- _table.put(Integer.valueOf(8364), "&euro;"); //$NON-NLS-1$
-
- _reverse = new Hashtable(256);
- for (Enumeration e = _table.keys(); e.hasMoreElements();) {
- Object key = e.nextElement();
- String value = (String) _table.get(key);
- _reverse.put(value, key);
- // also support without the training ';'
- _reverse.put(value.substring(0, value.length() - 1), key);
- }
- }
-
- /**
- * @param ch
- * @return if not in the special list
- */
- public static String getSpecial(int ch) {
- return (String) _table.get(Integer.valueOf(ch));
- }
-
- /**
- * @param str
- * @return the code value corresponding to the string or null
- * if string is unknown
- */
- public static int getSpecial(String str) {
- Integer result = (Integer) _reverse.get(str);
- if (result == null) {
- return -1;
- }
- return result.intValue();
- }
-
- /**
- * @param str
- * @param start
- * @param end
- * @param writer
- * @throws IOException
- */
- public static void encode(String str, int start, int end, Writer writer)
- throws IOException {
- for (int i = start; i < end; i++) {
- char ch = str.charAt(i);
- String special = getSpecial(ch);
- if (special != null) {
- writer.write(special);
- } else {
- if ((ch & 0xff) != 0) {
- writer.write("&#"); //$NON-NLS-1$
- writer.write(Integer.toString(ch));
- writer.write(";"); //$NON-NLS-1$
- } else {
- writer.write(ch);
- }
- }
- }
- }
-
- /**
- * @param str
- * @param result
- * @return the encoded string buffer
- */
- public static StringBuffer encode(String str, StringBuffer result) {
- return encode(str, 0, str.length(), result);
- }
-
- /**
- * @param str
- * @param start
- * @param end
- * @param result
- * @return the encoded string buffer
- */
- public static StringBuffer encode(String str, int start, int end,
- StringBuffer result) {
- for (int i = start; i < end; i++) {
- char ch = str.charAt(i);
- String special = getSpecial(ch);
- if (special != null) {
- result.append(special);
- } else {
- if ((ch & 0xff00) != 0) {
- result.append("&#"); //$NON-NLS-1$
- result.append(Integer.toString(ch));
- result.append(";"); //$NON-NLS-1$
- } else {
- result.append(ch);
- }
- }
- }
- return result;
- }
-
- /**
- * @param str
- * @param buffer
- * @return the decoded string buffer
- * @throws RuntimeException
- */
- public static StringBuffer decode(String str, StringBuffer buffer)
- throws RuntimeException {
- return decode(str, 0, str.length(), buffer);
- }
-
- /**
- * @param str
- * @param start
- * @param end
- * @param buffer
- * @return the decoded string buffer
- * @throws RuntimeException
- */
- public static StringBuffer decode(String str, int start, int end,
- StringBuffer buffer) throws RuntimeException {
- int pos = start;
- do {
- char ch = str.charAt(pos);
- if (ch == '&') {
- int stop = str.indexOf(';', pos + 1);
- if (stop < 0 || stop >= end) {
- _log.error("HTMLSpecialCharHelper.3"); //$NON-NLS-1$
- throw new RuntimeException("HTMLSpecialCharHelper.2"); //$NON-NLS-1$
- }
- String sp = str.substring(pos, stop + 1);
- int special = getSpecial(sp);
- if (special != -1) {
- buffer.append((char) special);
- } else {
- ch = sp.charAt(1);
- if (ch != '#')
- throw new RuntimeException("HTMLSpecialCharHelper.1"); //$NON-NLS-1$
- try {
- buffer.append((char) Integer.parseInt(sp.substring(2,
- sp.length() - 1)));
- } catch (NumberFormatException ex) {
- _log.info("HTMLSpecialCharHelper.0", ex); //$NON-NLS-1$
- throw new RuntimeException("illegal: " + sp); //$NON-NLS-1$
- }
- }
- pos = stop + 1;
- } else {
- buffer.append(ch);
- pos++;
- }
- } while (pos < end);
- return buffer;
- }
-
- /**
- * @param entityRef
- * @return the code for the decoded entity reference
- */
- public static int decodeEntity(String entityRef) {
- Integer result = (Integer) _reverse.get(entityRef);
- if (result != null) {
- return result.intValue();
- }
- if (entityRef.length() >= 2 && entityRef.charAt(1) == '#') {
- String s = entityRef.substring(2);
- if (s.endsWith(";")) {
- s = s.substring(0, s.length() - 1);
- }
- try {
- return Integer.parseInt(s);
- } catch (Exception ex) {
- // ignore
- }
- }
- return -1;
- }
-}
-
-// FIXME: will it better to use Character instead of Integer ? (yang)
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLUtil.java
deleted file mode 100644
index a4400d21c..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/HTMLUtil.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.Arrays;
-
-import org.eclipse.jst.pagedesigner.IHTMLConstants;
-import org.w3c.dom.Text;
-
-/**
- * @author mengbo
- */
-public class HTMLUtil {
- /**
- * check whether a char is a HTML whitespace.
- *
- * @param ch
- * @return true if ch is considered to be HTML whitespace
- * @see <a href="http://www.w3.org/TR/html4/struct/text.html#h-9.1">white
- * space </a>
- */
- public static boolean isHTMLWhitespace(char ch) {
- return ch == ' ' || ch == 0x09 || ch == 0x0c || ch == 0x0d
- || ch == 0x0a || ch == 0x200b;
- }
-
- /**
- * @param text
- * @return true if the entire string is considered to be HTML whitespace
- */
- public static boolean isHTMLWhitespaceString(String text) {
- for (int i = 0, size = text.length(); i < size; i++) {
- if (!isHTMLWhitespace(text.charAt(i))) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * the HTML tags considered to be hidden
- */
- static final String[] HiddenTags = new String[] {
- IHTMLConstants.TAG_APPLET, IHTMLConstants.TAG_AREA,
- IHTMLConstants.TAG_BASE, IHTMLConstants.TAG_BASEFONT,
- IHTMLConstants.TAG_HEAD, IHTMLConstants.TAG_IFRAME,
- IHTMLConstants.TAG_ISINDEX, IHTMLConstants.TAG_META,
- IHTMLConstants.TAG_NOEMBED, IHTMLConstants.TAG_NOFRAMES,
- IHTMLConstants.TAG_NOSCRIPT, IHTMLConstants.TAG_SCRIPT,
- IHTMLConstants.TAG_STYLE, IHTMLConstants.TAG_TITLE,
- IHTMLConstants.TAG_PARAM };
-
- /**
- * @param tag
- * @return true if the tag name is not in the list of hidden tags
- */
- public static boolean isVisualHtmlElement(String tag) {
- return !Arrays.asList(HiddenTags).contains(tag.toLowerCase());
- }
-
- /**
- * Handling white space. Basically, for leading and trailing whitespace,
- * will handle according whether the text is just after tag start or before
- * tag close.
- * <p>
- * For consequent whitespace, will compact them.
- * @param textNode
- * @param s
- * @return the compacted string
- * see http://www.w3.org/TR/html4/struct/text.html#h-9.1
- */
- // XXX: currently, the whitespace handling is in this class, in the future
- // may consider move it
- // into lower layer (display/CSS layer)
- public static String compactWhitespaces(Text textNode, String s) {
- char[] array = s.toCharArray();
- StringBuffer buffer = new StringBuffer(array.length);
- int posi = 0;
- int len = array.length;
-
- while (posi < len) {
- if (HTMLUtil.isHTMLWhitespace(array[posi])) {
- while (++posi < len && HTMLUtil.isHTMLWhitespace(array[posi]))
- {
- // no body
- // loop until we have find non-whitepspace or endof array
- }
-
- buffer.append(' ');
- continue;
- }
- buffer.append(array[posi++]);
- continue;
- }
- return buffer.toString();
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ICacheEntryCreator.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ICacheEntryCreator.java
deleted file mode 100644
index a63faee26..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ICacheEntryCreator.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-/**
- * Identifies a factory/dispose advisor for cache entries
- * @param <KEY>
- * @param <ENTRY>
- */
-public interface ICacheEntryCreator<KEY,ENTRY> {
- /**
- * @param key
- * @return the created entry
- */
- public ENTRY createEntry(KEY key);
-
- /**
- * @param key
- * @param entry
- */
- public void dispose(KEY key, ENTRY entry);
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java
deleted file mode 100644
index 29305bf9f..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ImageResolver.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.util.URIResolver;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Element;
-
-/**
- * @author mengbo
- * @version 1.5
- */
-public class ImageResolver {
- /**
- *
- * @param element
- * @param attrName
- * @return
- */
- static String getResolvedURL(Element element, String attrName) {
- URIResolver resolver = null;
- if (element instanceof IDOMNode) {
- resolver = ((IDOMNode) element).getModel().getResolver();
- }
- if (null == resolver) {
- return null;
- }
- String src = DOMUtil.getAttributeIgnoreCase(element, attrName);
- if (src != null && src.length() > 0) {
- return resolver.getLocationByURI(src);
- }
- return null;
- }
-
- /**
- * given the element and an attribute name identifying the src of the image,
- * create a image.
- *
- * @param element
- * @param attrName
- * @return the new image
- */
- public static Image initializeImage(Element element, String attrName) {
- String url = getResolvedURL(element, attrName);
- if (url == null) {
- return null;
- }
- Image img = null;
- int colonIndex = url.indexOf(":");
- int slashIndex = url.indexOf("/");
- if (colonIndex != -1 && (slashIndex != -1 && colonIndex < slashIndex)) {
- //the url seems to have a protocol, so try to load it as a URL
- try {
- URL urlObj = new URL(url);
- ImageDescriptor imgDesc = ImageDescriptor.createFromURL(urlObj);
- img = imgDesc.createImage(false);
- } catch(MalformedURLException mfe) {
- //attempt to load as a file
- try {
- img = new Image(null, url);
- } catch(SWTException se) {
- //img remains null on return
- }
- } catch(SWTException se) {
- //img remains null on return
- }
- } else {
- //no protocol, so load it as a file
- try {
- img = new Image(null, url);
- } catch(SWTException se) {
- //img remains null on return
- }
- }
- return img;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/IntFlexArray.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/IntFlexArray.java
deleted file mode 100644
index 4c50dcfa7..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/IntFlexArray.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-/**
- * Flexible int array. You can set/get of any index value. The array size will
- * be automatically adjusted.
- *
- * @author mengbo
- */
-public class IntFlexArray {
- int[] array;
-
- int size = 0;
-
- /**
- * Create a new flex array with default capacity
- */
- public IntFlexArray() {
- this(10);
- }
-
- /**
- * @param initCapacity
- */
- public IntFlexArray(int initCapacity) {
- if (initCapacity <= 0)
- initCapacity = 10;
- array = new int[initCapacity];
- }
-
- /**
- * @param idx
- * @param obj
- */
- public void setAt(int idx, int obj) {
- ensureCapacity(idx + 1);
- array[idx] = obj;
- if (idx + 1 > size)
- size = idx + 1;
- }
-
- /**
- * @param idx
- * @return the value at idx or 0 if idx is out of bounds
- */
- public int getAt(int idx) {
- if (idx < array.length)
- return array[idx];
- return 0;
- }
-
- /**
- * @return the current size of the array
- */
- public int getSize() {
- return size;
- }
-
- private void ensureCapacity(int size1) {
- if (size1 <= array.length)
- return;
- int[] temp = array;
- array = new int[2 * temp.length];
- System.arraycopy(temp, 0, array, 0, temp.length);
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java
deleted file mode 100644
index 99526d923..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JSPUtil.java
+++ /dev/null
@@ -1,286 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
-import org.eclipse.jst.jsp.core.internal.contentmodel.TaglibController;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.TaglibTracker;
-import org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDDocument;
-import org.eclipse.jst.jsp.core.taglib.TaglibIndex;
-import org.eclipse.jst.pagedesigner.css2.property.ICSSPropertyID;
-import org.eclipse.jst.pagedesigner.dom.EditModelQuery;
-import org.eclipse.wst.html.core.internal.format.HTMLFormatProcessorImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * utility class for JSP related information.
- *
- * @author mengbo
- */
-public class JSPUtil {
- /**
- * find out whether the specified taglib has been defined in the IDOMModel.
- * If found, then return the prefix. If can't find, then will try to add a
- * taglib declaration into the model, and try to use the specified default
- * prefix
- *
- * @param model
- * @param uri
- * @param defaultPrefix
- * @return prefix
- */
- public static String getOrCreatePrefix(IDOMModel model, String uri,
- String defaultPrefix) {
- return getOrCreatePrefix(model, uri, defaultPrefix, null);
- }
-
- /**
- *
- * @param model
- * @param uri
- * @param defaultPrefix
- * @param nodes
- * if a taglib node is created, then the created tag lib node is
- * returned in this. In the case of xml format, it is the attribute node on
- * jsp:root
- * @return prefix
- */
- public static String getOrCreatePrefix(IDOMModel model, String uri,
- String defaultPrefix, Node[] nodes) {
-
- String prefix = getPrefix(model, uri);
- if (prefix != null) {
- return prefix;
- }
-
- prefix = findUnusedPrefix(model, defaultPrefix);
-
- //need proper API to determine xml type... this may need to change in future
- if (! model.getDocument().isXMLType()){
- // TODO: should create the taglib inside the IDOMModel
- Node[] ref = new Node[1];
- BodyHelper.findHeaderInsertPosition(ITLDConstants.URI_JSP, "taglib",
- model.getDocument(), ref);
-
- Element ele = model.getDocument().createElement("jsp:directive.taglib");
- ((IDOMElement) ele).setJSPTag(true);
- ele.setAttribute(ICSSPropertyID.ATTR_URI, uri);
- ele.setAttribute(ICSSPropertyID.ATTR_PREFIX, prefix);
- if (nodes != null && nodes.length > 0) {
- nodes[0] = ele;
- }
- model.getDocument().insertBefore(ele, ref[0]);
- new HTMLFormatProcessorImpl().formatNode(ele);
- }
- else {//xml format
- //find root element
- boolean tldRefExists = false;
- Element root = getRootElement(model);
- if (root != null){
- NamedNodeMap attrs = root.getAttributes();
- for (int i=0;i<attrs.getLength();i++){
- Attr a = (Attr)attrs.item(i);
- //is the taglib uri already declared?
- if (a.getValue().equals(uri)){
- tldRefExists = true;
- break;
- }
- }
- if (!tldRefExists){
- //create attribute
- Attr a = model.getDocument().createAttribute("xmlns:"+prefix);
- a.setValue(uri);
- root.setAttributeNode(a);
- new HTMLFormatProcessorImpl().formatNode(root);
-
- //duplicating what non-xml case does... no callerd making use of this currently
- if (nodes != null && nodes.length > 0) {
- nodes[0] = a;
- }
- }
- }
- }
- return prefix;
- }
-
- private static Element getRootElement(IDOMModel model) {
- Document docNode = EditModelQuery.getDocumentNode(model.getDocument());
- return docNode.getDocumentElement();
- }
-
- /**
- * Return prefix for taglib if declared in jsp file
- * @param model
- * @param uri
- * @return null means this is tld is not declared in the jsp file
- */
- public static String getPrefix(IDOMModel model, String uri) {
- TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
- .getStructuredDocument());
- if (m == null) {
- // if the doc manager has nothing but the type is XML,
- // then see if the prefix is encoded as a namespace in
- // the doc root
- if (model.getDocument().isXMLType())
- {
- Element root = getRootElement(model);
- if (root != null){
- NamedNodeMap attrs = root.getAttributes();
- for (int i=0;i<attrs.getLength();i++){
- Attr a = (Attr)attrs.item(i);
- //is the taglib uri already declared?
- if (a.getValue().equals(uri)
- && a.getName().startsWith("xmlns:"))
- {
- String prefix = a.getNodeName().substring("xmlns:".length());
-
- if ("".equals(prefix))
- {
- prefix = null;
- }
- return prefix;
- }
- }
- }
- }
- return null;
- }
- List trackers = m.getTaglibTrackers();
- for (Iterator iter = trackers.iterator(); iter.hasNext();) {
- TaglibTracker tracker = (TaglibTracker) iter.next();
- if (uri.equals(tracker.getURI())) {
- return tracker.getPrefix();
- }
- CMDocument cmdoc = tracker.getDocument();
- if (cmdoc instanceof TLDDocument
- && uri.equals(((TLDDocument) cmdoc).getUri())) {
- return tracker.getPrefix();
- }
- }
- return null;
- }
-
- /**
- * create specified taglib declaration as jsp directive element
- *
- * @param model
- * @param uri
- * @param prefix
- * @return Element
- */
- public static Element createTaglibDeclaration(IDOMModel model, String uri,
- String prefix) {
- Node[] ref = new Node[1];
- BodyHelper.findHeaderInsertPosition(ITLDConstants.URI_JSP, "taglib",
- model.getDocument(), ref);
- Element ele = model.getDocument().createElement("jsp:directive.taglib");
- ((IDOMElement) ele).setJSPTag(true);
- ele.setAttribute("uri", uri);
- ele.setAttribute("prefix", prefix);
- model.getDocument().insertBefore(ele, ref[0]);
- return ele;
- }
-
- /**
- * Return prefix to use based upon the suggestion.
- * Appends an integer until unique, if suggestion was used.
- * @param model
- * @param suggestion
- * @return prefix
- */
- public static String findUnusedPrefix(IDOMModel model, String suggestion) {
- if (suggestion == null) {
- suggestion = "p";
- }
- TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
- .getStructuredDocument());
- if (m == null) {
- return suggestion;
- }
- List trackers = m.getTaglibTrackers();
- Set map = new HashSet();
- for (Iterator iter = trackers.iterator(); iter.hasNext();) {
- TaglibTracker tracker = (TaglibTracker) iter.next();
- map.add(tracker.getPrefix());
- }
- if (!map.contains(suggestion)) {
- return suggestion;
- }
- for (int i = 1;; i++) {
- if (!map.contains(suggestion + i)) {
- return suggestion + i;
- }
- }
- }
-
- /**
- * given the prefix, find the corresponding jsp tld URI.
- *
- * @param model
- * @param prefix
- * @return prefix
- */
- public static String findURIForPrefix(IDOMModel model, String prefix) {
- if (prefix == null || model == null) {
- return null;
- }
- TLDCMDocumentManager m = TaglibController.getTLDCMDocumentManager(model
- .getStructuredDocument());
- if (m == null) {
- return null;
- }
- List trackers = m.getTaglibTrackers();
- for (Iterator iter = trackers.iterator(); iter.hasNext();) {
- TaglibTracker tracker = (TaglibTracker) iter.next();
- if (prefix.equals(tracker.getPrefix())) {
- CMDocument cmdoc = tracker.getDocument();
- if (cmdoc instanceof TLDDocument) {
- return ((TLDDocument) cmdoc).getUri();
- }
- break; // fall out and return null
- }
- }
- return null;
- }
-
- /**
- * judge whether the the baseFile belonged project can support uri specified
- * tag lib
- *
- * @param uri
- * tag lib uri
- * @param baseFile
- * @return boolean
- */
- public static boolean supportTaglib(String uri, IFile baseFile) {
- IPath location = baseFile.getLocation();
- if (location != null) {
- return TaglibIndex.resolve(location.toString(), uri, false) != null;
- }
- return false;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JavaUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JavaUtil.java
deleted file mode 100644
index 17347070f..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/JavaUtil.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jdt.core.IClasspathEntry;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.internal.core.JarEntryFile;
-import org.eclipse.jst.jsf.common.ui.IFileFolderConstants;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-
-/**
- * @author mengbo
- */
-public class JavaUtil {
- /**
- *
- * @param javaProject
- * @param parent
- * @return the path in javaProject or new Path("") if not found on a class path
- * @author mengbo
- */
- public static IPath getPathOnClasspath(IJavaProject javaProject,
- Object parent) {
- IPath result = null;
- if (javaProject == null || parent == null) {
- return new Path("");
- }
- IClasspathEntry[] entries = javaProject.readRawClasspath();
- IPath classPath = null;
- if (parent instanceof IResource) {
- if (((javaProject != null) && !javaProject
- .isOnClasspath((IResource) parent))) {
- return new Path("");
- }
- if (parent instanceof IFile) {
- IPath elementPath = ((IFile) parent).getFullPath();
- if (((IFile) parent).getFileExtension().equalsIgnoreCase(
- IFileFolderConstants.EXT_PROPERTIES)) {
- int machings = 0;
- try {
- for (int i = 0; i < entries.length; i++) {
- // Determine whether on this classentry's path
- machings = entries[i].getPath()
- .matchingFirstSegments(elementPath);
- if (machings > 0) {
- // Get package name
- classPath = elementPath.removeFirstSegments(
- machings).removeLastSegments(1);
- break;
- }
- }
- // Not on the classpath?
- if (classPath == null) {
- return null;
- } else if (classPath.segmentCount() > 0)
- result = javaProject.findElement(classPath)
- .getPath().removeFirstSegments(machings)
- .append(((IFile) parent).getName());
- else
- result = ((IFile) parent).getFullPath()
- .removeFirstSegments(machings);
- } catch (Exception e) {
- // Error.DesignerPropertyTool.NatureQuerying = Error in
- // project java nature querying
- PDPlugin.getLogger(JavaUtil.class).error(
- "Error.DesignerPropertyTool.NatureQuerying", e);
- return null;
- }
- }
- }
- } else if (parent instanceof JarEntryFile) {
- IPath elementPath = ((JarEntryFile) parent).getFullPath();
- if (elementPath.getFileExtension().equalsIgnoreCase(
- IFileFolderConstants.EXT_PROPERTIES)) {
- result = elementPath;
- }
- }
- if (result != null) {
- return result;
- }
- return new Path("");
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/NodeLocationComparator.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/NodeLocationComparator.java
deleted file mode 100644
index 571819a2e..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/NodeLocationComparator.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.w3c.dom.Node;
-
-/**
- * To sort the location of tags, this comparator is used to compare tags' order.
- *
- * @author mengbo
- */
-public class NodeLocationComparator implements Comparator {
- private final static Map orders = new HashMap();
-
- private final static Integer DEFAULT_ORDER = Integer.valueOf(Integer.MAX_VALUE);
-
- private static NodeLocationComparator _instance = new NodeLocationComparator();
- static {
- orders.put("taglib", Integer.valueOf(0));
- orders.put("directive.taglib", Integer.valueOf(0));
- orders.put("head", Integer.valueOf(1));
- }
-
- private NodeLocationComparator() {
- // no external instantiation
- }
-
- /**
- * @return the singleton
- */
- public static NodeLocationComparator getInstance() {
- return _instance;
- }
-
- /**
- * The object to be compared could be Node or tag name.
- *
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object o1, Object o2) {
- Assert.isTrue((o1 instanceof Node || o1 instanceof String)
- && (o2 instanceof Node || o2 instanceof String));
- Integer i1 = getOrder(o1);
- Integer i2 = getOrder(o2);
- return i1.compareTo(i2);
- }
-
- private Integer getOrder(Object n) {
- String name = null;
- if (n instanceof Node) {
- name = ((Node) n).getLocalName();
- } else {
- name = (String) n;
- }
- if (name != null) {
- Object order = orders.get(name);
- if (order != null) {
- return (Integer) order;
- }
- }
- return DEFAULT_ORDER;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/PreviewUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/PreviewUtil.java
deleted file mode 100644
index 1a76abaca..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/PreviewUtil.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.MissingResourceException;
-import java.util.PropertyResourceBundle;
-import java.util.Map.Entry;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jst.jsf.common.ui.IFileFolderConstants;
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.jsf.common.ui.internal.utils.PathUtil;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-import org.eclipse.jst.pagedesigner.css2.property.ICSSPropertyID;
-import org.eclipse.ui.IEditorInput;
-import org.w3c.dom.Attr;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author mengbo
- */
-public class PreviewUtil {
- /** Create the logger for this class */
- private static Logger _log = PDPlugin.getLogger(PreviewUtil.class);
-
- /** line separator */
- public static final String LINE_SEPARATOR = System
- .getProperty("line.separator"); //$NON-NLS-1$
-
- /** web root path */
- private final static String WEBROOT_PATH = null;
-
- /** the file being previewed */
- private static IFile CURRENT_FILE = null;
-
- /** the property bundel */
- private static PropertyResourceBundle BUNDLE = null;
-
- /** the property bundel map used for loadbundle preview action */
- private static Map BUNDLE_MAP = null;
-
- /** the variable name used for loadbundel preview action */
- private static String VAR = null;
-
- /** key is prefix value is uri */
- private static Map _taglibMap = new HashMap();
-
-
- /**
- * @return the current bundle
- */
- public static final PropertyResourceBundle getBUNDLE() {
- return BUNDLE;
- }
-
- /**
- * @param bundle
- */
- public static final void setBUNDLE(PropertyResourceBundle bundle) {
- BUNDLE = bundle;
- }
-
- /**
- * @return the current bundle map
- */
- public static final Map getBUNDLE_MAP() {
- return BUNDLE_MAP;
- }
-
- /**
- * @param bundle_map
- */
- public static final void setBUNDLE_MAP(Map bundle_map) {
- BUNDLE_MAP = bundle_map;
- }
-
- /**
- * @return the current variable
- */
- public static final String getVAR() {
- return VAR;
- }
-
- /**
- * @param var
- */
- public static final void setVAR(String var) {
- VAR = var;
- }
-
- /**
- * @return Returns the _taglibMap.
- */
- public static Map getTaglibMap() {
- return _taglibMap;
- }
-
- /**
- * @param map
- * The _taglibMap to set.
- */
- public static void setTaglibMap(Map map) {
- _taglibMap = map;
- }
-
- /**
- * Get tag attribute string from attribute map
- *
- * @param map
- * tag attribute map
- * @return the attribute string
- */
- public static String getAttributesAsString(Map map) {
- return getAttributesAsString(map, true);
- }
-
- /**
- * Get file path from uri
- *
- * @param uri
- * taglib uri
- * @return the path as a string
- */
- public static String getPathFromURI(String uri) {
- if (uri == null) {
- return uri;
- }
-
- if (uri.startsWith(IFileFolderConstants.PATH_SEPARATOR)) {
- return PreviewUtil.WEBROOT_PATH + uri;
- }
- IFile curFile = PreviewUtil.CURRENT_FILE;
- if (curFile != null) {
- IContainer con = curFile.getParent();
- if (con != null) {
- IPath path = con.getLocation();
- if (path != null) {
- String aPath = path.toString() + File.separator + uri;
-
- aPath = aPath.replace('/', File.separatorChar);
- aPath = aPath.replace('\\', File.separatorChar);
- if (aPath.endsWith(File.separator)) {
- aPath += File.separator;
- }
- File file = new File(aPath);
- if (file.exists()) {
- return aPath;
- }
- return uri;
- }
- }
- }
- return null;
- }
-
- /**
- * Get bundle value for expression
- *
- * @param attrValue
- * expression
- * @return the value
- */
- public static String getValueOFEP(String attrValue) {
- if (attrValue != null) {
- if (attrValue.startsWith("#{")) //$NON-NLS-1$
- {
- String key, value = null;
- int i = attrValue.lastIndexOf("."); //$NON-NLS-1$
- if (i > 0) {
- key = attrValue.substring(i + 1, attrValue.length() - 1)
- .trim();
- String bundleVariable = attrValue.substring(2, i).trim();
- if (BUNDLE_MAP == null) {
- return attrValue; //$NON-NLS-1$
- }
- PropertyResourceBundle bundle = (PropertyResourceBundle) BUNDLE_MAP
- .get(bundleVariable);
-
- if (bundle != null) {
- try {
- value = bundle.getString(key);
- if (value != null) {
- return value;
- }
- return attrValue; //$NON-NLS-1$
- } catch (MissingResourceException e1) {
- // "Error in resource bundle processing:"
- _log.info("PreviewUtil.Error.0", e1); //$NON-NLS-1$
- }
- }
- }
- }
- }
- return attrValue;
- }
-
- /**
- * Get tag attribute string from attribute map
- *
- * @param map
- * tag attribute map
- * @param flag
- * state
- * @return the attributes as a single string
- */
- private static String getAttributesAsString(Map<String, String> map, boolean flag) {
- if (map == null) {
- return null;
- }
-
- StringBuffer stringbuffer = new StringBuffer();
- for (Iterator<Entry<String, String>> e = map.entrySet().iterator(); e.hasNext();) {
- Map.Entry<String,String> entry = e.next();
- String attrName = entry.getKey();
- String attrValue = entry.getValue();
- attrValue = getValueOFEP(attrValue);
- if (ICSSPropertyID.ATTR_SRC.equalsIgnoreCase(attrName)
- || ICSSPropertyID.ATTR_HREF.equalsIgnoreCase(attrName)
- || ICSSPropertyID.ATTR_URI.equalsIgnoreCase(attrName)
- || ICSSPropertyID.ATTR_BINDING.equalsIgnoreCase(attrName)
- || ICSSPropertyID.ATTR_PAGE.equalsIgnoreCase(attrName)) {
- if (PreviewUtil.WEBROOT_PATH != null && attrValue != null
- && !attrValue.startsWith("http") //$NON-NLS-1$
- && !attrValue.startsWith("file")) //$NON-NLS-1$
- {
- attrValue = getPathFromURI(attrValue);
- }
- }
- if (attrValue != null) {
- stringbuffer.append(" ").append(attrName); //$NON-NLS-1$
- if (attrValue.indexOf(34) != -1) {
- StringBuffer stringbuffer1 = new StringBuffer();
- for (int j = 0; j < attrValue.length(); j++) {
- char c = attrValue.charAt(j);
- if (c != '"') {
- stringbuffer1.append(c);
- }
- }
-
- attrValue = stringbuffer1.toString();
- }
- if (attrValue != null && attrValue.startsWith("#{")) //$NON-NLS-1$
- {
- attrValue = ""; //$NON-NLS-1$
- }
- stringbuffer.append("=\"").append(attrValue).append('"'); //$NON-NLS-1$
- }
- }
- // System.out.println("BBBB:" +stringbuffer.toString());
-
- return stringbuffer.toString();
- }
-
- /**
- * Change NamedNodeMap type to Map type
- *
- * @param nodeMap
- * NamedNodeMap type
- * @return the map
- */
- public static Map getAttributeMap(NamedNodeMap nodeMap) {
- if (nodeMap != null) {
- int len = nodeMap.getLength();
- HashMap map = new HashMap();
- for (int i = 0; i < len; i++) {
- Node node = nodeMap.item(i);
- String name = node.getNodeName();
- String value = node.getNodeValue();
- if (name != null
- && !name.trim().equalsIgnoreCase("") && value != null) //$NON-NLS-1$
- {
- map.put(name, value);
- }
- }
- return map;
- }
- return null;
- }
-
- /**
- * @param result
- * @param editorInput
- * @return the file
- */
- public static File toFile(StringBuffer result, IEditorInput editorInput) {
- try {
- File file = File.createTempFile("previewtmp", ".html"); //$NON-NLS-1$ //$NON-NLS-2$
- if (!file.exists()) {
- file.createNewFile();
- }
- FileOutputStream fos = new FileOutputStream(file);
- PrintStream ps = new PrintStream(fos, true, "UTF-8"); //$NON-NLS-1$
- ps.print(result.toString());
- ps.close();
- fos.close();
- return file;
- } catch (IOException e) {
- // "Error in file open:"
- _log.info("PreviewUtil.Error.3", e); //$NON-NLS-1$
- return null;
- }
- }
-
- /**
- * do preivew on Node recursively translate escape char for Node and Node's
- * child translate relative path for Node and Node's child
- *
- * @param node
- * root node that will be previewed
- */
- public static void previewNode(Node node) {
- if (node == null) {
- return;
- }
- NodeList nodeList = node.getChildNodes();
- if (nodeList == null) {
- return;
- }
- NamedNodeMap attrMap = node.getAttributes();
-
- if (attrMap != null) {
- for (int i = 0, n = attrMap.getLength(); i < n; i++) {
- Node attrNode = attrMap.item(i);
- if (attrNode != null && attrNode instanceof Attr) {
- Attr attr = (Attr) attrNode;
- attr.setNodeValue(getValueOFEP(attr.getNodeValue()));
- attr.setNodeValue(PathUtil.convertToAbsolutePath(attr
- .getNodeValue(), null));
- //TODO: dead?
-// StringBuffer buf = new StringBuffer();
-// String attrValue = attr.getNodeValue();
- }
- }
- }
- for (int i = 0, n = nodeList.getLength(); i < n; i++) {
- previewNode(nodeList.item(i));
- }
- }
-
- // /**
- // * handle escape attebute of tag
- // *
- // * @param node
- // * @return
- // */
- // public static boolean escapeFoeNode(Node node)
- // {
- // if (node == null)
- // {
- // return false;
- // }
- // NamedNodeMap attrMap = node.getAttributes();
- // if (attrMap != null)
- // {
- // for (int i = 0, n = attrMap.getLength(); i < n; i++)
- // {
- // Node attrNode = attrMap.item(i);
- // if (attrNode != null && attrNode instanceof Attr)
- // {
- // if ("escape".equalsIgnoreCase(attrNode.getNodeName())
- // && "true".equalsIgnoreCase(attrNode.getNodeValue()))
- // {
- // return true;
- // }
- // }
- // }
- // }
- // return false;
- // }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ProjectResolver.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ProjectResolver.java
deleted file mode 100644
index e18044d97..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/ProjectResolver.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jst.jsf.common.ui.IFileFolderConstants;
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.jsf.common.ui.internal.utils.ResourceUtils;
-import org.eclipse.jst.jsf.common.ui.internal.utils.WebrootUtil;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-import org.eclipse.jst.pagedesigner.css2.property.ICSSPropertyID;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.util.URIResolver;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A URIResolver implementation
- *
- */
-public class ProjectResolver implements URIResolver {
- private static final String TLD_TAG_URI = "uri";
-
- private static final String URI_PREFIX_HTTP = "http";
-
- private static final String FILE_PROTOCOL = "file";
-
- /** Create the logger for this class */
- private static Logger _log = PDPlugin.getLogger(ProjectResolver.class);
-
- private IProject _project = null;
-
- private String _fileBaseLocation = null;
-
- private static Map _uriMap = null;
-
- /**
- * It is strongly recommended that clients use
- * project.getAdapter(URIResolver.class) to obtain a URIResolver aware of
- * the Project's special requirements. Note that a URIResolver may not be
- * returned at all so manually creating this object may still be required.
- * @param project
- */
- public ProjectResolver(IProject project) {
- super();
- _project = project;
- }
-
- /**
- * @param path
- */
- public void seekTld(IFolder path) {
- if (path == null) {
- return;
- }
- if (_uriMap == null) {
- _uriMap = new HashMap();
- }
-
- try {
- IResource[] res = path.members();
- if (null == res) {
- return;
- }
- for (int i = 0; i < res.length; i++) {
- if (res[i] instanceof IFolder) {
- seekTld((IFolder) res[i]);
- }
- String ext = res[i].getFileExtension();
- if (IFileFolderConstants.EXT_TAGLIB.equalsIgnoreCase(ext)) {
- IFile tldFile = (IFile) res[i];
- String uri = getURIfromTLD(tldFile);
- String locate = tldFile.getLocation().toOSString();
- if (uri != null && _uriMap.get(uri) == null) {
- _uriMap.put(uri, locate);
- }
- }
- }
- } catch (CoreException e) {
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e);
- }
- }
-
- /**
- * @param path
- */
- public void seekTld(File path) {
- if (path == null || !path.isDirectory()) {
- return;
- }
- if (_uriMap == null) {
- _uriMap = new HashMap();
- }
-
- try {
- File[] res = path.listFiles();
- if (null == res) {
- return;
- }
- for (int i = 0; i < res.length; i++) {
- if (res[i] instanceof IFolder) {
- seekTld(res[i]);
- }
-
- if (res[i].getName().endsWith(
- IFileFolderConstants.DOT
- + IFileFolderConstants.EXT_TAGLIB)) {
- String uri = getURIfromTLD(res[i]);
- String locate;
-
- locate = res[i].getCanonicalPath();
-
- if (uri != null && _uriMap.get(uri) == null) {
- _uriMap.put(uri, locate);
- }
- }
- }
- } catch (IOException e1) {
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e1);
- }
- }
-
- /**
- * @param tldFile
- * @return the uri for the tld in tldFile or null
- */
- public String getURIfromTLD(File tldFile) {
-
- if (tldFile == null) {
- return null;
- }
- IDOMModel tldModel = null;
-
- InputStream in = null;
- try {
- in = new FileInputStream(tldFile);
- } catch (FileNotFoundException e) {
- _log.error("RenderingTraverser.Error.FileNotFound", e);
- return null;
- }
-// IDOMModel xmlModel = null;
-
- try {
- tldModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(
- tldFile.getAbsolutePath(), in, null);
- NodeList uriList = tldModel.getDocument().getElementsByTagName(
- TLD_TAG_URI);
- for (int i = 0, n = uriList.getLength(); i < n; i++) {
- Node uri = uriList.item(i);
- return uri.getChildNodes().item(0).getNodeValue();
- }
- } catch (UnsupportedEncodingException e1) {
- _log.error("RenderingTraverser.Error.UnsupportedEncoding", e1);
- } catch (IOException e1) {
- _log.error("RenderingTraverser.Error.IO", e1);
- } finally {
- ResourceUtils.ensureClosed(in);
-
- if (tldModel != null)
- {
- tldModel.releaseFromRead();
- }
- }
-
- return null;
- }
-
- /**
- * @param tldFile
- * @return the URI for the TLD in tldFile or null
- */
- public String getURIfromTLD(IFile tldFile) {
- if (tldFile == null) {
- return null;
- }
- IDOMModel tldModel;
-
- try {
- tldModel = (IDOMModel) getModelManager().getModelForRead(tldFile);
- NodeList uriList = tldModel.getDocument().getElementsByTagName(
- TLD_TAG_URI);
- for (int i = 0, n = uriList.getLength(); i < n; i++) {
- Node uri = uriList.item(i);
- return uri.getChildNodes().item(0).getNodeValue();
- }
- } catch (IOException e) {
- // Error in taglib locating.
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e); //$NON-NLS-1$
- } catch (CoreException e1) {
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e1);
- }
- return null;
- }
-
- /**
- * initialize the map of tlds
- */
- public void initTldMap() {
- if (_uriMap == null) {
- _uriMap = new HashMap();
- }
- if (_project == null) {
- return;
- }
- if (WebrootUtil.getWebContentFolder(_project) == null) {
- return;
- }
- IFolder webinf = WebrootUtil.getWebContentFolder(_project).getFolder(
- IFileFolderConstants.FOLDER_WEBINF);
- if (webinf != null && webinf.exists()) {
- seekTld(webinf);
- }
-
- String locate = PDPlugin.getInstallLocation().append("/jsf-tld")
- .toString();
- File jsfDir = new File(locate);
- seekTld(jsfDir);
-
- }
-
- public java.lang.String getFileBaseLocation() {
- return _fileBaseLocation;
- }
-
- public java.lang.String getLocationByURI(String uri) {
- // System.out.println(getLocationByURI(uri, getFileBaseLocation()));
- return getLocationByURI(uri, getFileBaseLocation());
- }
-
- private IModelManager getModelManager() {
- return StructuredModelManager.getModelManager();
- }
-
- private String getLocationFromWEBXML(String uri, String baseReference) {
- if (uri == null) {
- return null;
- }
- try {
- // if (_project.hasNature(ICommonConstants.NATURE_WEBAPP))
- // {
- if (uri.startsWith(IFileFolderConstants.PATH_SEPARATOR)) {
- uri = _project.getProject().getLocation().toString()
- + IFileFolderConstants.PATH_SEPARATOR
- + WebrootUtil.getWebContentFolderName(_project) + uri;
- }
- if (uri.startsWith(URI_PREFIX_HTTP)) {
- IFile webxml = WebrootUtil.getWebContentFolder(_project)
- .getFolder(IFileFolderConstants.FOLDER_WEBINF).getFile(
- IFileFolderConstants.FILE_WEB_XML);
- IDOMModel xmlModel;
-
- if (webxml.exists()) {
- try {
- xmlModel = (IDOMModel) getModelManager()
- .getModelForRead(webxml);
-
- NodeList taglibNodeList = xmlModel
- .getDocument()
- .getElementsByTagName(ICSSPropertyID.TAG_TAGLIB);
-
- for (int i = 0, size = taglibNodeList.getLength(); i < size; i++) {
- Node taglibNode = taglibNodeList.item(i);
-
- NodeList childList = taglibNode.getChildNodes();
- String taguri = "";
- String taglocation = "";
- for (int j = 0, childSize = childList.getLength(); j < childSize; j++) {
- Node childTaglibNode = childList.item(j);
- if (ICSSPropertyID.ATTR_TAGLIB_URI
- .equalsIgnoreCase(childTaglibNode
- .getNodeName())) {
- taguri = childTaglibNode.getChildNodes()
- .item(0).getNodeValue();
- }
- if (ICSSPropertyID.ATTR_TAGLIB_LOCATION
- .equalsIgnoreCase(childTaglibNode
- .getNodeName())) {
- taglocation = childTaglibNode
- .getChildNodes().item(0)
- .getNodeValue();
- }
-
- }
- if (uri.equalsIgnoreCase(taguri))
- uri = _project.getProject().getLocation()
- .toString()
- + IFileFolderConstants.PATH_SEPARATOR
- + WebrootUtil
- .getWebContentFolderName(_project)
- + taglocation;
- }
- xmlModel.releaseFromRead();
- } catch (IOException e) {
-
- // Error in taglib locating.
- _log.error(
- "Error.ProjectResolver.GetlocationByURI.0", e); //$NON-NLS-1$
- } catch (CoreException e1) {
- e1.printStackTrace();
- _log.error("Error.ProjectResolver.GetlocationByURI.0",
- e1);
- }
-
- }
- }
- // }
- } catch (DOMException e1) {
- // Error in taglib locating.
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e1); //$NON-NLS-1$
- }
- // catch (CoreException e1)
- // {
- //
- // _log.error("Error.ProjectResolver.GetlocationByURI.0", e1);
- // }
-
- if (isFileURL(uri)) {
- try {
- URL url = new URL(uri);
- return getPath(url);
- } catch (MalformedURLException e) {
- _log.error("Error.ProjectResolver.GetlocationByURI.0", e);
- }
- }
- // defect 244817 end
- return URIHelper.normalize(uri, baseReference, getRootLocationString());
-
- }
-
- public String getLocationByURI(String uri, String baseReference) {
- // DataWindow may generate URL like "d:\somefile" (dos path). We may
- // need some
- // special support. (lium)
- int columnIndex = uri.indexOf(":");
- int slashIndex = uri.indexOf("/");
- if (columnIndex != -1 && (slashIndex == -1 || columnIndex < slashIndex)) {
- return uri;
- }
-
- String result = getLocationFromWEBXML(uri, baseReference);
- if (result != null && !result.equals(uri)) {
- return result;
- }
- if (_uriMap == null) {
- initTldMap();
- }
- if (_uriMap != null) {
- return (String) _uriMap.get(uri);
- }
- return null;
- }
-
- // defect 244817 start
- /**
- * @param passedSpec
- * @return boolean
- */
- private boolean isFileURL(String passedSpec) {
- if (passedSpec == null) {
- return false;
- }
- final String spec = passedSpec.trim();
- if (spec.length() == 0) {
- return false;
- }
- String newProtocol = null;
- for (int index = 0, limit = spec.length(); index < limit; index++) {
- final char p = spec.charAt(index);
- if (p == '/') {
- //$NON-NLS-1$
- break;
- }
- if (p == ':') {
- //$NON-NLS-1$
- newProtocol = spec.substring(0, index);
- break;
- }
- }
- return (newProtocol != null && newProtocol
- .compareToIgnoreCase(FILE_PROTOCOL) == 0); //$NON-NLS-1$
- }
-
- /**
- * @param url
- * @return String
- */
- private String getPath(URL url) {
- String ref = url.getRef() == null ? "" : "#" + url.getRef(); //$NON-NLS-1$ //$NON-NLS-2$
- String strPath = url.getFile() + ref;
- IPath path;
- if (strPath.length() == 0) {
- path = Path.ROOT;
- } else {
- path = new Path(strPath);
- String query = null;
- StringTokenizer parser = new StringTokenizer(strPath, "?"); //$NON-NLS-1$
- int tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- query = (String) parser.nextElement();
- }
- if (query == null) {
- parser = new StringTokenizer(path.toString(), "#"); //$NON-NLS-1$
- tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- }
- }
- }
- return getPath(path, url.getHost());
- }
-
- /**
- * @param path
- * @param host
- * @return String
- */
- private String getPath(IPath path, String host) {
- IPath newPath = path;
- // They are potentially for only Windows operating system.
- // a.) if path has a device, and if it begins with IPath.SEPARATOR,
- // remove it
- final String device = path.getDevice();
- if (device != null && device.length() > 0) {
- if (device.charAt(0) == IPath.SEPARATOR) {
- final String newDevice = device.substring(1);
- newPath = path.setDevice(newDevice);
- }
- }
- // b.) if it has a hostname, it is UNC name... Any java or eclipse api
- // helps it ??
- if (newPath != null && host != null && host.length() != 0) {
- IPath uncPath = new Path(host);
- uncPath = uncPath.append(path);
- newPath = uncPath.makeUNC(true);
- }
-
- if (newPath != null)
- {
- return newPath.toString();
- }
- return path.toString();
- }
-
- /**
- * Resolve the (possibly relative) URI acording to RFC1808 using the default
- * file base location. Resolves resource references into absolute resource
- * locations without ensuring that the resource actually exists. Note:
- * currently resolveCrossProjectLinks is ignored in this implementation.
- */
- public java.lang.String getLocationByURI(String uri,
- boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, getFileBaseLocation(),
- resolveCrossProjectLinks);
- }
-
- /**
- * Perform the getLocationByURI action using the baseReference as the point
- * of reference instead of the default for this resolver Note: currently
- * resolveCrossProjectLinks is ignored in this implementation.
- */
- public java.lang.String getLocationByURI(String uri, String baseReference,
- boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, baseReference);
- }
-
- public org.eclipse.core.resources.IProject getProject() {
- return _project;
- }
-
- public org.eclipse.core.resources.IContainer getRootLocation() {
- return _project;
- }
-
- private String getRootLocationString() {
- return null;
- }
-
- public void setFileBaseLocation(java.lang.String newFileBaseLocation) {
- _fileBaseLocation = newFileBaseLocation;
- }
-
- public void setProject(org.eclipse.core.resources.IProject newProject) {
- _project = newProject;
- }
-
- public InputStream getURIStream(String uri) {
- return null;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectManyHelper.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectManyHelper.java
deleted file mode 100644
index a7f3ff692..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectManyHelper.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
-import org.eclipse.jst.jsf.core.internal.tld.IJSFConstants;
-import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
-import org.eclipse.jst.pagedesigner.IHTMLConstants;
-import org.eclipse.jst.pagedesigner.css2.property.ICSSPropertyID;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-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;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @author mengbo
- */
-public class SelectManyHelper {
-
- private final static Set<String> JSF_SELECT_TAGS, HTML_SELECT_TAGS;
-
-
- static {
- Set<String> tempSet = new HashSet<String>(4);
- tempSet.add(IHTMLConstants.TAG_SELECT);
- tempSet.add(IHTMLConstants.TAG_OPTGROUP);
- HTML_SELECT_TAGS = Collections.unmodifiableSet(tempSet);
-
- tempSet = new HashSet(8);
- tempSet.add(IJSFConstants.TAG_SELECTONELISTBOX);
- tempSet.add(IJSFConstants.TAG_SELECTONEMENU);
- tempSet.add(IJSFConstants.TAG_SELECTMANYLISTBOX);//
- tempSet.add(IJSFConstants.TAG_SELECTMANYMENU);//
- tempSet.add(IJSFConstants.TAG_SELECTMANYCHECKBOX);
- JSF_SELECT_TAGS = Collections.unmodifiableSet(tempSet);
- }
-
- /**
- * @param node
- * @return the select option children of node
- */
- public static Object[] getSelectOptions(Element node) {
- if (node == null) {
- return null;
- }
- IDOMModel xmlModel = null;
- if (node instanceof IDOMNode) {
- xmlModel = ((IDOMNode) node).getModel();
- }
- if (xmlModel == null) {
- return null;
- }
- // TODO: this query is not cached.
- String prefixNode = JSPUtil.getPrefix(xmlModel,
- ITLDConstants.URI_JSF_HTML);
- if (prefixNode != null && node.getPrefix() != null
- && node.getPrefix().equals(prefixNode)) {
- if (JSF_SELECT_TAGS.contains(node.getLocalName())) {
- String prefixItem = JSPUtil.getPrefix(xmlModel,
- ITLDConstants.URI_JSF_CORE);
- List result = new ArrayList();
- NodeList items = node.getElementsByTagName(prefixItem
- + ":" + IJSFConstants.TAG_SELECTITEM); //$NON-NLS-1$
- for (int i = 0, n = items.getLength(); i < n; i++) {
- result.add(items.item(i));
- }
- items = node.getElementsByTagName(prefixItem
- + ":" + IJSFConstants.TAG_SELECTITEMS); //$NON-NLS-1$
- for (int i = 0, n = items.getLength(); i < n; i++) {
- result.add(items.item(i));
- }
- return result.size() > 0 ? result.toArray(new Node[result
- .size()]) : null;
- }
- }
- if (node.getPrefix() == null) {
- if (HTML_SELECT_TAGS.contains(node.getNodeName().toLowerCase())) {
- List result = new ArrayList();
- NodeList options = node
- .getElementsByTagName(IHTMLConstants.TAG_OPTION);
- NodeList optionGroups = node
- .getElementsByTagName(IHTMLConstants.TAG_OPTGROUP);
- for (int i = 0, n = options.getLength(); i < n; i++) {
- result.add(options.item(i));
- }
- for (int i = 0, n = optionGroups.getLength(); i < n; i++) {
- result.add(optionGroups.item(i));
- }
- return result.toArray(new Node[result.size()]);
- }
- }
- return null;
- }
-
- /**
- * @param node
- * @return the selection option children of node as strings
- */
- public static String[] getSelectOptionsString(Element node) {
- if (node == null) {
- return null;
- }
- Object[] options = getSelectOptions(node);
- if (null == options || options[0] == null) {
- return null;
- }
- List result = new ArrayList();
- for (int i = 0, n = options.length; i < n; i++) {
- if (options[i] instanceof Element) {
- Element element = (Element) options[i];
- Node value = null;
- if (element.getNodeName()
- .indexOf(IJSFConstants.TAG_SELECTITEMS) >= 0) {
- value = element.getAttributeNode(IJSFConstants.ATTR_VALUE);
- } else if (element.getNodeName().indexOf(
- IJSFConstants.TAG_SELECTITEM) >= 0) {
- value = element
- .getAttributeNode(ICSSPropertyID.ATTR_ITEMLABEL);
- }
- if (value != null) {
- result.add(value.getNodeValue());
- }
- }
- }
- return (String[]) result.toArray(new String[] {});
- }
-
- /**
- * @param node
- * @return true if node has select option children
- */
- public static boolean hasSelectOptions(Element node) {
- if (node == null) {
- return false;
- }
- String uri = CMUtil.getElementNamespaceURI(node);
- if (ITLDConstants.URI_JSF_HTML.equals(uri)) {
-
- if (JSF_SELECT_TAGS.contains(node.getLocalName())) {
- IDOMModel model = ((IDOMElement) node).getModel();
- String jsfcorePrefix = JSPUtil.getPrefix(model,
- ITLDConstants.URI_JSF_CORE);
- if (jsfcorePrefix != null) {
- NodeList nl = node.getElementsByTagName(jsfcorePrefix + ":"
- + IJSFConstants.TAG_SELECTITEM);
- NodeList nl1 = node.getElementsByTagName(jsfcorePrefix
- + ":" + IJSFConstants.TAG_SELECTITEMS);
- return nl.getLength() > 0 || nl1.getLength() > 0;
- }
- return false;
- }
- }
- if (ITLDConstants.URI_HTML.equals(uri)) {
- if (HTML_SELECT_TAGS.contains(node.getNodeName().toLowerCase())) {
- NodeList nl = node
- .getElementsByTagName(IHTMLConstants.TAG_OPTION);
- NodeList nl1 = node
- .getElementsByTagName(IHTMLConstants.TAG_OPTGROUP);
- return nl.getLength() > 0 || nl1.getLength() > 0;
- }
- }
- return false;
- }
-
- /**
- * @param node
- * @return true if node is a core or HTML select tag
- */
- public static boolean supportSections(Element node) {
- String uri = CMUtil.getElementNamespaceURI(node);
- if (ITLDConstants.URI_JSF_HTML.equals(uri)) {
- return JSF_SELECT_TAGS.contains(node.getLocalName());
- }
- if (ITLDConstants.URI_HTML.equals(uri)) {
- return HTML_SELECT_TAGS.contains(node.getNodeName().toLowerCase());
- }
- return false;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectionHelper.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectionHelper.java
deleted file mode 100644
index ee93b5827..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/SelectionHelper.java
+++ /dev/null
@@ -1,384 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.gef.EditPart;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jst.jsf.core.internal.tld.CMUtil;
-import org.eclipse.jst.pagedesigner.dom.DOMPosition;
-import org.eclipse.jst.pagedesigner.dom.DOMPositionHelper;
-import org.eclipse.jst.pagedesigner.dom.DOMRefPosition;
-import org.eclipse.jst.pagedesigner.dom.DOMRefPosition2;
-import org.eclipse.jst.pagedesigner.dom.DOMUtil;
-import org.eclipse.jst.pagedesigner.dom.EditValidateUtil;
-import org.eclipse.jst.pagedesigner.dom.IDOMPosition;
-import org.eclipse.jst.pagedesigner.parts.NodeEditPart;
-import org.eclipse.jst.pagedesigner.viewer.DesignPosition;
-import org.eclipse.jst.pagedesigner.viewer.DesignRange;
-import org.eclipse.jst.pagedesigner.viewer.IHTMLGraphicalViewer;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.Text;
-
-/**
- * @author mengbo
- * @version 1.5
- */
-public class SelectionHelper {
- /**
- * convert the text selection to a Node. Will use the start offset of the
- * text selection.
- *
- * @param model
- * @param textSel
- * @return the node for the text selectin in model or null
- */
- public static Node toNode(IStructuredModel model, ITextSelection textSel) {
- // FIXME: currently always normalize to a single node. should also
- // consider change into DesignRange
- // on text selection, find the appropriate Node
- Object inode = model.getIndexedRegion(textSel.getOffset());
- if (inode instanceof Node) {
- return (Node) inode;
- }
- return null;
- }
-
- /**
- * convert a structured selection of NodeEditPart or Node into the first
- * node.
- *
- * @param selection
- * @return the node for the selection or null
- */
- public static Node toNode(IStructuredSelection selection) {
- if (selection.isEmpty()) {
- return null;
- }
- Object first = selection.getFirstElement();
- if (first instanceof Node) {
- return (Node) first;
- } else if (first instanceof NodeEditPart) {
- return ((NodeEditPart) first).getIDOMNode();
- } else {
- return null;
- }
- }
-
- /**
- * convert a DesignRange into a single node.
- *
- * @param range
- * @return the node for the design range or null
- */
- public static Node toNode(DesignRange range) {
- if (range.isValid()) {
- Node node1 = range.getStartPosition().getContainerNode();
- Node node2 = range.getEndPosition().getContainerNode();
- return DOMUtil.findCommonAncester(node1, node2);
- }
- return null;
- }
-
- /**
- * @param model
- * @param region
- * if null, then will calculate it using offset.
- * @param offset
- * offset in source.
- * @return a dom position for the region and offset
- */
- public static IDOMPosition toDOMPosition(IDOMModel model,
- IndexedRegion region, int offset) {
- if (region == null) {
- region = model.getIndexedRegion(offset);
- }
- if (region == null && offset > 0) {
- // in case this is at end of file.
- offset = offset - 1;
- region = model.getIndexedRegion(offset);
- if (region != null) {
- if (region.getEndOffset() >= offset + 1) {
- offset += 1; // restore offset.
- }
- }
- }
- if (region == null) {
- return new DOMPosition(model.getDocument(), 0);
- }
- IDOMNode node = (IDOMNode) region;
- int start = node.getStartOffset();
- if (offset <= start) {
- return new DOMRefPosition(node, false);
- }
- int end = node.getEndOffset();
- if (offset >= end) {
- return new DOMRefPosition(node, true);
- }
- if (node instanceof CharacterData) {
- String data = ((CharacterData) node).getData();
- String source = node.getSource();
- if (data.equals(source)) {
- return new DOMPosition(node, offset - start);
- }
- IStructuredDocumentRegion r = node
- .getFirstStructuredDocumentRegion();
- int countedData = 0;
- // TODO: dead? int offsetInNode = offset - start;
- while (r != null) {
- if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
- || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
- .getType())) {
- countedData += 1; // FIXME: what if the entity reference's
- // corresponding data is more than 1
- // char?
- // where can we get that information?
- if (r.getEnd() >= offset) {
- return new DOMPosition(node, countedData);
- }
- } else {
- if (r.getEnd() >= offset) {
- return new DOMPosition(node, countedData + offset
- - r.getStart());
- }
- countedData += r.getLength();
- }
- r = r.getNext();
- }
- return new DOMRefPosition(node, true);
- } else if (node instanceof Element) {
- CMElementDeclaration cm = CMUtil
- .getElementDeclaration((Element) node);
- if (cm != null && cm.getContentType() == CMElementDeclaration.EMPTY) {
- // this node can't have children.
- return new DOMRefPosition(node, true);
- }
- IStructuredDocumentRegion startRegion = node
- .getStartStructuredDocumentRegion();
- if (startRegion == null) {
- return new DOMRefPosition(node, true);
- }
- int startRegionEnd = node.getStartStructuredDocumentRegion()
- .getEnd();
- if (offset <= startRegionEnd) {
- // it is in the start tag region. So put position at first
- // child position.
- return new DOMRefPosition2(node, false);
- }
- return new DOMRefPosition2(node, true);
- } else {
- return new DOMRefPosition(node, true);
- }
- // XXX: the implementation in EditModelQuery seemed to be very complex.
- // Need revisit that
- // and refactor the implementation to this class later. (lium)
- }
-
- /**
- * Give a text selection with offset and length, convert it into a Designer
- * selection (IStrucuturedSelection of editpart or DesignerRange). If the
- * text selection include just a single element node, we'll create a
- * IStructuredSelection, otherwise we'll create a DesignerRange.
- *
- * @param graphicViewer
- * @param offset
- * @param length
- * @return a selection
- */
- public static ISelection convertToDesignerSelection(
- IHTMLGraphicalViewer graphicViewer, int offset, int length) {
- IDOMModel model = graphicViewer.getModel();
- IndexedRegion region1 = model.getIndexedRegion(offset);
- IndexedRegion region2 = model.getIndexedRegion(offset + length);
- IDOMNode node1 = (IDOMNode) region1;
-
- if (node1 == null) {
- IDOMPosition endOfDoc = new DOMRefPosition2(model.getDocument(),
- true);
- DesignPosition p = DOMPositionHelper.toDesignPosition(endOfDoc);
- return new DesignRange(p, p);
- }
-
- if ((region1 == region2 || node1.getEndOffset() == offset + length)
- && !(node1 instanceof Text)) {
- // ok, we selected a single node.
- EditPart part = (EditPart) node1.getAdapterFor(EditPart.class);
- if (part != null) {
- return new StructuredSelection(part);
- }
- }
-
- // when we reach here, we'll create a DesignerRange
- IDOMPosition position1 = toDOMPosition(model, region1, offset);
- IDOMPosition position2 = (length == 0 ? position1 : toDOMPosition(
- model, region2, offset + length));
-
- if (position1 == null || position2 == null) {
- return new DesignRange(null, null);
- }
- DesignPosition p1 = DOMPositionHelper.toDesignPosition(position1);
- DesignPosition p2 = (length == 0 ? p1 : DOMPositionHelper
- .toDesignPosition(position2));
- if (p1 == null || p2 == null) {
- return new DesignRange(null, null);
- }
-
- return new DesignRange(p1, p2);
-
- }
-
- /**
- * convert a IDOMPosition into index in the source.
- *
- * @param p
- * @return
- */
- private static int getIndexedRegionLocation(IDOMPosition p) {
- if (!EditValidateUtil.validPosition(p)) {
- return 0;
- }
-
- IDOMNode parent = (IDOMNode) p.getContainerNode();
- if (p.isText()) {
- String text = ((CharacterData) parent).getData();
- String source = parent.getSource();
- if (text.length() == source.length()) {
- // no entity reference.
- return parent.getStartOffset() + p.getOffset();
- }
- // CR404708. Need to handle entity reference in the text.
- int offset = p.getOffset();
- int counted = 0;
- IStructuredDocumentRegion r = parent
- .getFirstStructuredDocumentRegion();
- while (r != null && counted < offset) {
- if (DOMRegionContext.XML_CHAR_REFERENCE.equals(r.getType())
- || DOMRegionContext.XML_ENTITY_REFERENCE.equals(r
- .getType())) {
- counted++;
- if (counted >= offset) {
- return r.getEndOffset();
- }
- } else {
- int length = r.getLength();
- if (counted + length >= offset) {
- return r.getStartOffset() + offset - counted;
- }
- counted += length;
- }
- r = r.getNext();
- }
- return parent.getStartOffset() + p.getOffset();
- }
- IDOMNode previous = (IDOMNode) p.getPreviousSiblingNode();
- if (previous != null) {
- return previous.getEndOffset();
- }
- IDOMNode next = (IDOMNode) p.getNextSiblingNode();
- if (next != null) {
- return next.getStartOffset();
- }
- IStructuredDocumentRegion r = parent
- .getStartStructuredDocumentRegion();
- if (r != null) {
- return r.getEnd();
- }
- // r == null normally means the parent is the document node.
- return parent.getEndOffset();
- }
-
- /**
- * convert design selection of structured selection of NodeEditPart into
- * structured selection of Node
- *
- * @param sel
- * @return a structured selectino
- */
- public static IStructuredSelection convertFromDesignSelection(
- IStructuredSelection sel) {
- List list = sel.toList();
- if (list != null) {
- List result = new ArrayList(list.size());
- for (int i = 0, size = list.size(); i < size; i++) {
- NodeEditPart part = (NodeEditPart) list.get(i);
- result.add(part.getIDOMNode());
- }
- return new StructuredSelection(result);
- }
- return new StructuredSelection();
- }
-
- /**
- *
- * @param range
- * selection from designer, could be IStructuredSelection of
- * NodeEditPart, or DesignRange.
- * @return a text selection
- */
- public static ITextSelection convertFromDesignSelection(DesignRange range) {
- if (range.isValid()) {
- IDOMPosition start = DOMPositionHelper.toDOMPosition(range
- .getStartPosition());
- IDOMPosition end = DOMPositionHelper.toDOMPosition(range
- .getEndPosition());
- // We should not encounter invalid position.
- if (EditValidateUtil.validPosition(start)
- && EditValidateUtil.validPosition(end)) {
- int offset = getIndexedRegionLocation(start);
- int endoffset = getIndexedRegionLocation(end);
- if (offset > endoffset) {
- int temp = offset;
- offset = endoffset;
- endoffset = temp;
- }
- return new TextSelection(offset, endoffset - offset);
- }
- }
- return new TextSelection(0, 0);
- }
-
- /**
- * @param selection
- * @return a text selection for the selection or TextSelection(0,0)
- * if nothing can be determined
- */
- public static ITextSelection convertFromDesignSelectionToTextSelection(
- ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection nodes = convertFromDesignSelection((IStructuredSelection) selection);
- IDOMNode node = (IDOMNode) nodes.getFirstElement();
- if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
- return new TextSelection(node.getStartOffset(), node
- .getEndOffset()
- - node.getStartOffset());
- }
- } else if (selection instanceof DesignRange) {
- return convertFromDesignSelection((DesignRange) selection);
- }
- return new TextSelection(0, 0);
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/StructuredModelUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/StructuredModelUtil.java
deleted file mode 100644
index 88539757b..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/StructuredModelUtil.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-
-/**
- * @author mengbo
- */
-public class StructuredModelUtil {
-
- /**
- * this method is copied from ModelManagerImpl of wtp. Because it is
- * internal.
- *
- * @param model
- * @return null if can't get file.
- */
- // TODO: replace (or supplement) this is a "model info" association to the
- // IFile that created the model
- public static IFile getFileFor(IStructuredModel model) {
- if (model == null)
- return null;
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return null;
- path = id.toString();
- }
- // TODO needs rework for linked resources
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- try {
- IFile file = root.getFile(new Path(path));
- // IFile file = root.getFileForLocation(new Path(path));
- return file;
- } catch (Exception ex) {
- return null;
- }
- }
-
- /**
- *
- * @param model
- * @return null if can't find project for the model
- */
- public static IProject getProjectFor(IStructuredModel model) {
- IProject project = null;
-
- IFile file = getFileFor(model);
- if (file != null) {
- project = file.getProject();
- }
- return project;
- }
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/UriAdapterFactory.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/UriAdapterFactory.java
deleted file mode 100644
index 4bad85a5d..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/UriAdapterFactory.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.wst.sse.core.internal.util.URIResolver;
-
-/**
- * @author mengbo comment go to Window - Preferences - Java - Code Style - Code
- * Templates
- */
-public class UriAdapterFactory implements IAdapterFactory {
- /** Create the logger for this class */
- //private static Logger _log = PDPlugin.getLogger(UriAdapterFactory.class);
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
- * java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (URIResolver.class.equals(adapterType)) {
- IProject project = (IProject) adaptableObject;
- URIResolver fProjectResolver = new ProjectResolver(project);
- return fProjectResolver;
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList() {
- Class[] classes = new Class[1];
- classes[0] = URIResolver.class;
- return classes;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/WebAppUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/WebAppUtil.java
deleted file mode 100644
index d3971e26b..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/WebAppUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jst.j2ee.internal.web.deployables.WebDeployableArtifactUtil;
-import org.eclipse.jst.jsf.common.ui.IFileFolderConstants;
-import org.eclipse.jst.jsf.core.internal.tld.ITLDConstants;
-import org.eclipse.wst.common.componentcore.ComponentCore;
-import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
-import org.eclipse.wst.common.componentcore.resources.IVirtualResource;
-
-/**
- * @author mengbo
- * @version 1.5
- */
-public class WebAppUtil {
- private final static String FACES_SERVLET_NAME = "javax.faces.webapp.FacesServlet";
-
- /**
- * @param url
- * @param openedFile
- * @return the transformed url
- */
- public static String transformJSPURL(String url, IFile openedFile) {
- boolean canSupportJSF = JSPUtil.supportTaglib(
- ITLDConstants.URI_JSF_HTML, openedFile);
- if (canSupportJSF
- && url != null
- && url.endsWith(IFileFolderConstants.DOT
- + IFileFolderConstants.EXT_JSP)) {
- String urlPattern = "";
- IVirtualResource[] resources = ComponentCore
- .createResources(openedFile);
- IVirtualComponent component = null;
- if (resources[0] != null) {
- component = resources[0].getComponent();
- }
- if (component != null) {
- urlPattern = WebDeployableArtifactUtil.getServletMapping(
- openedFile.getProject(), true, FACES_SERVLET_NAME,
- component.getName());
- }
- if (urlPattern.lastIndexOf(IFileFolderConstants.DOT) != -1) {
- String extension = urlPattern.substring(urlPattern
- .lastIndexOf(IFileFolderConstants.DOT));
- url = url.substring(0, url.lastIndexOf(IFileFolderConstants.DOT
- + IFileFolderConstants.EXT_JSP))
- + extension;
- }
- }
- return url;
- }
-
-}
diff --git a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/XMLUtil.java b/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/XMLUtil.java
deleted file mode 100644
index 7638cd41d..000000000
--- a/jsf/plugins/org.eclipse.jst.pagedesigner/src/org/eclipse/jst/pagedesigner/utils/XMLUtil.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 Sybase, Inc. and others.
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Sybase, Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.jst.pagedesigner.utils;
-
-/**
- * @author mengbo
- */
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.jst.jsf.common.ui.internal.logging.Logger;
-import org.eclipse.jst.pagedesigner.PDPlugin;
-import org.w3c.dom.Document;
-
-/**
- *
- *
- */
-public class XMLUtil {
- private static Logger _log = PDPlugin.getLogger(XMLUtil.class);
-
- /**
- * Returns a DocumentBuilder capable of creating a DOM Document from input.
- *
- * @return a new instance of a document builder or null if an exception
- * occurs on creation
- */
- public synchronized static DocumentBuilder getDocumentBuilder() {
- DocumentBuilder result = null;
- try {
- result = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- } catch (ParserConfigurationException e) {
- // "Error in create documentBuilder"
- _log.info("XMLUtil.Error.0", e); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Transforms a DOM document into a lightly-formatted UTF-8 represntation
- * and outputs it to an outputstream
- *
- * @param document
- * @param ostream
- * @throws IOException
- */
- public static void serialize(Document document, OutputStream ostream)
- throws IOException {
- Source domSource = new DOMSource(document);
- try {
- Transformer serializer = TransformerFactory.newInstance()
- .newTransformer();
- try {
- serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- serializer.setOutputProperty(
- "{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
- serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$
- } catch (IllegalArgumentException e) {
- // "Error in object persistance:"
- _log.info("XMLUtil.Error.2", e); //$NON-NLS-1$
- }
- serializer.transform(domSource, new StreamResult(ostream));
- } catch (TransformerConfigurationException e) {
- // "Error in object persistance:"
- _log.info("XMLUtil.Error.2", e); //$NON-NLS-1$
- throw new IOException(e.getMessage());
- } catch (TransformerFactoryConfigurationError e) {
- // "Error in object persistance:"
- _log.info("XMLUtil.Error.2", e); //$NON-NLS-1$
- throw new IOException(e.getMessage());
- } catch (TransformerException e) {
- // "Error in object persistance:"
- _log.info("XMLUtil.Error.2", e); //$NON-NLS-1$
- throw new IOException(e.getMessage());
- }
- }
-}

Back to the top