View Javadoc

1   /*
2    * Copyright 2010 Capgemini
3    * Licensed under the Apache License, Version 2.0 (the "License"); 
4    * you may not use this file except in compliance with the License. 
5    * You may obtain a copy of the License at 
6    * 
7    * http://www.apache.org/licenses/LICENSE-2.0 
8    * 
9    * Unless required by applicable law or agreed to in writing, software 
10   * distributed under the License is distributed on an "AS IS" BASIS, 
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
12   * See the License for the specific language governing permissions and 
13   * limitations under the License. 
14   * 
15   */
16  package org.xmlfield.core.api;
17  
18  import org.xmlfield.core.internal.NamespaceMap;
19  
20  /**
21   * Modifier interface, this interface describe the diffrent operation needed to
22   * be done on an XML document.
23   * 
24   * @author Guillaume Mary <guillaume.mary@capgemini.com>
25   * 
26   */
27  public interface XmlFieldNodeModifier {
28  
29  	/**
30  	 * Create an attribute to a node
31  	 * 
32  	 * @param contextNode
33  	 *            node where the attribute will be created
34  	 * @param attributeName
35  	 *            name of the attribute
36  	 * @param textContent
37  	 *            text content of the attribute
38  	 */
39  	void createAttribute(final XmlFieldNode contextNode,
40  			final String attributeName, final String textContent);
41  
42  	/**
43  	 * Create a new element node at the end of the root node.
44  	 * 
45  	 * @param namespaces
46  	 *            document namespaces
47  	 * @param node
48  	 *            context node
49  	 * @param elementName
50  	 *            element name
51  	 * @return the created element
52  	 */
53  	XmlFieldNode createElement(final NamespaceMap namespaces,
54  			final XmlFieldNode node, final String elementName);
55  
56  	/**
57  	 * Create a new element node at the end of the root node.
58  	 * 
59  	 * @param namespaces
60  	 *            document namespaces
61  	 * @param node
62  	 *            context node
63  	 * @param elementName
64  	 *            element name
65  	 * @param textContent
66  	 *            text content of the new element
67  	 * @return the new element
68  	 */
69  	XmlFieldNode createElement(final NamespaceMap namespaces,
70  			final XmlFieldNode node, final String elementName,
71  			final String textContent);
72  
73  	/**
74  	 * Insert a node before another node.
75  	 * 
76  	 * @param parentNode
77  	 *            parent node of the nodes
78  	 * @param newChild
79  	 *            node to insert
80  	 * @param refChild
81  	 *            reference node where the node should be inserted before
82  	 * @return the inserted node
83  	 */
84  	XmlFieldNode insertBefore(final XmlFieldNode parentNode,
85  			final XmlFieldNode newChild, XmlFieldNode refChild);
86  
87  	/**
88  	 * Remove an attribute from a specified node
89  	 * 
90  	 * @param node
91  	 *            node
92  	 * @param attributeName
93  	 *            attribute name
94  	 * @return the attribute node removed
95  	 */
96  	XmlFieldNode removeAttribute(final XmlFieldNode node,
97  			final String attributeName);
98  
99  	/**
100 	 * Remove a child node
101 	 * 
102 	 * @param contextNode
103 	 *            the context node
104 	 * @param oldChild
105 	 *            child to be removed
106 	 * @return the removed node
107 	 */
108 	XmlFieldNode removeChild(final XmlFieldNode contextNode,
109 			final XmlFieldNode oldChild);
110 
111 	/**
112 	 * Remove a node list
113 	 * 
114 	 * @param contextNode
115 	 *            the context node
116 	 * @param nodesToRemove
117 	 *            node list of children to be removed
118 	 */
119 	void removeChildren(final XmlFieldNodeList nodesToRemove);
120 
121 }