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 /** 19 * Interface used by the framework to access to an xml node. 20 * 21 * @author Guillaume Mary <guillaume.mary@capgemini.com> 22 * 23 * @param <T> 24 * underlying xml node representation type 25 */ 26 public interface XmlFieldNode { 27 28 /** 29 * The node is an <code>Attr</code>. 30 */ 31 static final short ATTRIBUTE_NODE = 2; 32 33 /** 34 * The node is an <code>Element</code>. 35 */ 36 static final short ELEMENT_NODE = 1; 37 /** 38 * The node is a <code>Text</code> node. 39 */ 40 static final short TEXT_NODE = 3; 41 /** 42 * The node is an unknow node. 43 */ 44 static final short UNKNOW_NODE = -1; 45 46 /** 47 * Get the document node 48 * 49 * @return document node 50 */ 51 XmlFieldNode getDocumentNode(); 52 53 /** 54 * Get the underlying node 55 * 56 * @return the underlying node 57 */ 58 Object getNode(); 59 60 /** 61 * Get the xml node name of the underlying node 62 * 63 * @return node name 64 */ 65 String getNodeName(); 66 67 /** 68 * Get the node type. 69 * 70 * @return node type 71 */ 72 short getNodeType(); 73 74 /** 75 * Retrieve the parent node 76 * 77 * @return parent node of this node 78 */ 79 XmlFieldNode getParentNode(); 80 81 /** 82 * Get the node content as string. 83 * 84 * @return node content 85 */ 86 String getTextContent(); 87 88 /** 89 * Check if the current node has attributes 90 * 91 * @return true if the node has attributes 92 */ 93 boolean hasAttributes(); 94 95 /** 96 * Set the node text content 97 * 98 * @param textContent 99 */ 100 void setTextContent(String textContent); 101 }