001    /**
002     * Copyright (c) 2000-2013 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            @Override
114            public String formattedString() throws IOException;
115    
116            @Override
117            public String formattedString(String indent) throws IOException;
118    
119            @Override
120            public String formattedString(String indent, boolean expandEmptyElements)
121                    throws IOException;
122    
123            public Object getData();
124    
125            public Namespace getNamespace();
126    
127            public Namespace getNamespaceForPrefix(String prefix);
128    
129            public Namespace getNamespaceForURI(String uri);
130    
131            public String getNamespacePrefix();
132    
133            public List<Namespace> getNamespacesForURI(String uri);
134    
135            public String getNamespaceURI();
136    
137            public QName getQName();
138    
139            public QName getQName(String qualifiedName);
140    
141            public String getQualifiedName();
142    
143            @Override
144            public String getStringValue();
145    
146            @Override
147            public String getText();
148    
149            public String getTextTrim();
150    
151            public Node getXPathResult(int index);
152    
153            public boolean hasMixedContent();
154    
155            public boolean isRootElement();
156    
157            public boolean isTextOnly();
158    
159            public boolean remove(Attribute attribute);
160    
161            public boolean remove(CDATA cdata);
162    
163            public boolean remove(Entity entity);
164    
165            public boolean remove(Namespace namespace);
166    
167            public boolean remove(Text text);
168    
169            public void setAttributes(List<Attribute> attributes);
170    
171            public void setData(Object data);
172    
173            public void setQName(QName qName);
174    
175            public void sortAttributes(boolean recursive);
176    
177            public void sortElementsByAttribute(
178                    String elementName, String attributeName);
179    
180            public void sortElementsByChildElement(
181                    String elementName, String childElementName);
182    
183    }