001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import java.io.IOException;
020    
021    import java.util.Iterator;
022    import java.util.List;
023    import java.util.Map;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    @ProviderType
029    public interface Element extends Branch {
030    
031            public void add(Attribute attribute);
032    
033            public void add(CDATA cdata);
034    
035            public void add(Entity entity);
036    
037            public void add(Namespace namespace);
038    
039            public void add(Text text);
040    
041            public Element addAttribute(QName qName, String value);
042    
043            public Element addAttribute(String name, String value);
044    
045            public Element addCDATA(String cdata);
046    
047            public Element addComment(String comment);
048    
049            public Element addEntity(String name, String text);
050    
051            public List<Namespace> additionalNamespaces();
052    
053            public Element addNamespace(String prefix, String uri);
054    
055            public Element addProcessingInstruction(
056                    String target, Map<String, String> data);
057    
058            public Element addProcessingInstruction(String target, String data);
059    
060            public Element addText(String text);
061    
062            public void appendAttributes(Element element);
063    
064            public Attribute attribute(int index);
065    
066            public Attribute attribute(QName qName);
067    
068            public Attribute attribute(String name);
069    
070            public int attributeCount();
071    
072            public Iterator<Attribute> attributeIterator();
073    
074            public List<Attribute> attributes();
075    
076            public String attributeValue(QName qName);
077    
078            public String attributeValue(QName qName, String defaultValue);
079    
080            public String attributeValue(String name);
081    
082            public String attributeValue(String name, String defaultValue);
083    
084            public Element createCopy();
085    
086            public Element createCopy(QName qName);
087    
088            public Element createCopy(String name);
089    
090            public List<Namespace> declaredNamespaces();
091    
092            public Element element(QName qName);
093    
094            public Element element(String name);
095    
096            public Iterator<Element> elementIterator();
097    
098            public Iterator<Element> elementIterator(QName qName);
099    
100            public Iterator<Element> elementIterator(String name);
101    
102            public List<Element> elements();
103    
104            public List<Element> elements(QName qName);
105    
106            public List<Element> elements(String name);
107    
108            public String elementText(QName qName);
109    
110            public String elementText(String name);
111    
112            public String elementTextTrim(QName qName);
113    
114            public String elementTextTrim(String name);
115    
116            @Override
117            public String formattedString() throws IOException;
118    
119            @Override
120            public String formattedString(String indent) throws IOException;
121    
122            @Override
123            public String formattedString(String indent, boolean expandEmptyElements)
124                    throws IOException;
125    
126            public Object getData();
127    
128            public Namespace getNamespace();
129    
130            public Namespace getNamespaceForPrefix(String prefix);
131    
132            public Namespace getNamespaceForURI(String uri);
133    
134            public String getNamespacePrefix();
135    
136            public List<Namespace> getNamespacesForURI(String uri);
137    
138            public String getNamespaceURI();
139    
140            public QName getQName();
141    
142            public QName getQName(String qualifiedName);
143    
144            public String getQualifiedName();
145    
146            @Override
147            public String getStringValue();
148    
149            @Override
150            public String getText();
151    
152            public String getTextTrim();
153    
154            public Node getXPathResult(int index);
155    
156            public boolean hasMixedContent();
157    
158            public boolean isRootElement();
159    
160            public boolean isTextOnly();
161    
162            public boolean remove(Attribute attribute);
163    
164            public boolean remove(CDATA cdata);
165    
166            public boolean remove(Entity entity);
167    
168            public boolean remove(Namespace namespace);
169    
170            public boolean remove(Text text);
171    
172            public void setAttributes(List<Attribute> attributes);
173    
174            public void setData(Object data);
175    
176            public void setQName(QName qName);
177    
178            public void sortAttributes(boolean recursive);
179    
180            public void sortElementsByAttribute(
181                    String elementName, String attributeName);
182    
183            public void sortElementsByChildElement(
184                    String elementName, String childElementName);
185    
186    }