001: /*
002:
003: Licensed to the Apache Software Foundation (ASF) under one or more
004: contributor license agreements. See the NOTICE file distributed with
005: this work for additional information regarding copyright ownership.
006: The ASF licenses this file to You under the Apache License, Version 2.0
007: (the "License"); you may not use this file except in compliance with
008: the License. You may obtain a copy of the License at
009:
010: http://www.apache.org/licenses/LICENSE-2.0
011:
012: Unless required by applicable law or agreed to in writing, software
013: distributed under the License is distributed on an "AS IS" BASIS,
014: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015: See the License for the specific language governing permissions and
016: limitations under the License.
017:
018: */
019: package org.apache.batik.dom.xbl;
020:
021: import org.apache.batik.dom.AbstractNode;
022:
023: import org.w3c.dom.Element;
024: import org.w3c.dom.Node;
025: import org.w3c.dom.NodeList;
026:
027: /**
028: * An XBL manager that performs no XBL processing.
029: *
030: * @author <a href="mailto:cam%40mcc%2eid%2eau">Cameron McCormack</a>
031: * @version $Id: GenericXBLManager.java 475477 2006-11-15 22:44:28Z cam $
032: */
033: public class GenericXBLManager implements XBLManager {
034:
035: /**
036: * Whether XBL processing is currently taking place.
037: */
038: protected boolean isProcessing;
039:
040: /**
041: * Starts XBL processing on the document.
042: */
043: public void startProcessing() {
044: isProcessing = true;
045: }
046:
047: /**
048: * Stops XBL processing on the document.
049: */
050: public void stopProcessing() {
051: isProcessing = false;
052: }
053:
054: /**
055: * Returns whether XBL processing is currently enabled.
056: */
057: public boolean isProcessing() {
058: return isProcessing;
059: }
060:
061: /**
062: * Get the parent of a node in the fully flattened tree.
063: */
064: public Node getXblParentNode(Node n) {
065: return n.getParentNode();
066: }
067:
068: /**
069: * Get the list of child nodes of a node in the fully flattened tree.
070: */
071: public NodeList getXblChildNodes(Node n) {
072: return n.getChildNodes();
073: }
074:
075: /**
076: * Get the list of child nodes of a node in the fully flattened tree
077: * that are within the same shadow scope.
078: */
079: public NodeList getXblScopedChildNodes(Node n) {
080: return n.getChildNodes();
081: }
082:
083: /**
084: * Get the first child node of a node in the fully flattened tree.
085: */
086: public Node getXblFirstChild(Node n) {
087: return n.getFirstChild();
088: }
089:
090: /**
091: * Get the last child node of a node in the fully flattened tree.
092: */
093: public Node getXblLastChild(Node n) {
094: return n.getLastChild();
095: }
096:
097: /**
098: * Get the node which directly precedes a node in the xblParentNode's
099: * xblChildNodes list.
100: */
101: public Node getXblPreviousSibling(Node n) {
102: return n.getPreviousSibling();
103: }
104:
105: /**
106: * Get the node which directly follows a node in thexblParentNode's
107: * xblChildNodes list.
108: */
109: public Node getXblNextSibling(Node n) {
110: return n.getNextSibling();
111: }
112:
113: /**
114: * Get the first element child of a node in the fully flattened tree.
115: */
116: public Element getXblFirstElementChild(Node n) {
117: Node m = n.getFirstChild();
118: while (m != null && m.getNodeType() != Node.ELEMENT_NODE) {
119: m = m.getNextSibling();
120: }
121: return (Element) m;
122: }
123:
124: /**
125: * Get the last element child of a node in the fully flattened tree.
126: */
127: public Element getXblLastElementChild(Node n) {
128: Node m = n.getLastChild();
129: while (m != null && m.getNodeType() != Node.ELEMENT_NODE) {
130: m = m.getPreviousSibling();
131: }
132: return (Element) m;
133: }
134:
135: /**
136: * Get the first element that precedes the a node in the
137: * xblParentNode's xblChildNodes list.
138: */
139: public Element getXblPreviousElementSibling(Node n) {
140: Node m = n;
141: do {
142: m = m.getPreviousSibling();
143: } while (m != null && m.getNodeType() != Node.ELEMENT_NODE);
144: return (Element) m;
145: }
146:
147: /**
148: * Get the first element that follows a node in the
149: * xblParentNode's xblChildNodes list.
150: */
151: public Element getXblNextElementSibling(Node n) {
152: Node m = n;
153: do {
154: m = m.getNextSibling();
155: } while (m != null && m.getNodeType() != Node.ELEMENT_NODE);
156: return (Element) m;
157: }
158:
159: /**
160: * Get the bound element whose shadow tree a node resides in.
161: */
162: public Element getXblBoundElement(Node n) {
163: return null;
164: }
165:
166: /**
167: * Get the shadow tree of a node.
168: */
169: public Element getXblShadowTree(Node n) {
170: return null;
171: }
172:
173: /**
174: * Get the xbl:definition elements currently binding an element.
175: */
176: public NodeList getXblDefinitions(Node n) {
177: return AbstractNode.EMPTY_NODE_LIST;
178: }
179: }
|