001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.xml;
016    
017    import java.io.IOException;
018    
019    import java.util.Iterator;
020    import java.util.List;
021    import java.util.Map;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public interface Element extends Branch {
027    
028            public void add(Attribute attribute);
029    
030            public void add(CDATA cdata);
031    
032            public void add(Entity entity);
033    
034            public void add(Namespace namespace);
035    
036            public void add(Text text);
037    
038            public Element addAttribute(QName qName, String value);
039    
040            public Element addAttribute(String name, String value);
041    
042            public Element addCDATA(String cdata);
043    
044            public Element addComment(String comment);
045    
046            public Element addEntity(String name, String text);
047    
048            public List<Namespace> additionalNamespaces();
049    
050            public Element addNamespace(String prefix, String uri);
051    
052            public Element addProcessingInstruction(
053                    String target, Map<String, String> data);
054    
055            public Element addProcessingInstruction(String target, String data);
056    
057            public Element addText(String text);
058    
059            public void appendAttributes(Element element);
060    
061            public Attribute attribute(int index);
062    
063            public Attribute attribute(QName qName);
064    
065            public Attribute attribute(String name);
066    
067            public int attributeCount();
068    
069            public Iterator<Attribute> attributeIterator();
070    
071            public List<Attribute> attributes();
072    
073            public String attributeValue(QName qName);
074    
075            public String attributeValue(QName qName, String defaultValue);
076    
077            public String attributeValue(String name);
078    
079            public String attributeValue(String name, String defaultValue);
080    
081            public Element createCopy();
082    
083            public Element createCopy(QName qName);
084    
085            public Element createCopy(String name);
086    
087            public List<Namespace> declaredNamespaces();
088    
089            public Element element(QName qName);
090    
091            public Element element(String name);
092    
093            public Iterator<Element> elementIterator();
094    
095            public Iterator<Element> elementIterator(QName qName);
096    
097            public Iterator<Element> elementIterator(String name);
098    
099            public List<Element> elements();
100    
101            public List<Element> elements(QName qName);
102    
103            public List<Element> elements(String name);
104    
105            public String elementText(QName qName);
106    
107            public String elementText(String name);
108    
109            public String elementTextTrim(QName qName);
110    
111            public String elementTextTrim(String name);
112    
113            public String formattedString() throws IOException;
114    
115            public String formattedString(String indent) throws IOException;
116    
117            public String formattedString(String indent, boolean expandEmptyElements)
118                    throws IOException;
119    
120            public Object getData();
121    
122            public Namespace getNamespace();
123    
124            public Namespace getNamespaceForPrefix(String prefix);
125    
126            public Namespace getNamespaceForURI(String uri);
127    
128            public String getNamespacePrefix();
129    
130            public List<Namespace> getNamespacesForURI(String uri);
131    
132            public String getNamespaceURI();
133    
134            public QName getQName();
135    
136            public QName getQName(String qualifiedName);
137    
138            public String getQualifiedName();
139    
140            public String getStringValue();
141    
142            public String getText();
143    
144            public String getTextTrim();
145    
146            public Node getXPathResult(int index);
147    
148            public boolean hasMixedContent();
149    
150            public boolean isRootElement();
151    
152            public boolean isTextOnly();
153    
154            public boolean remove(Attribute attribute);
155    
156            public boolean remove(CDATA cdata);
157    
158            public boolean remove(Entity entity);
159    
160            public boolean remove(Namespace namespace);
161    
162            public boolean remove(Text text);
163    
164            public void setAttributes(List<Attribute> attributes);
165    
166            public void setData(Object data);
167    
168            public void setQName(QName qName);
169    
170            public void sortAttributes(boolean recursive);
171    
172            public void sortElementsByAttribute(
173                    String elementName, String attributeName);
174    
175            public void sortElementsByChildElement(
176                    String elementName, String childElementName);
177    
178    }