001    /**
002     * Copyright (c) 2000-2010 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.File;
018    import java.io.InputStream;
019    import java.io.Reader;
020    
021    import java.net.MalformedURLException;
022    import java.net.URL;
023    
024    import java.util.List;
025    import java.util.Map;
026    
027    /**
028     * @author Brian Wing Shun Chan
029     */
030    public interface SAXReader {
031    
032            public Attribute createAttribute(
033                    Element element, QName qName, String value);
034    
035            public Attribute createAttribute(
036                    Element element, String name, String value);
037    
038            public Document createDocument();
039    
040            public Document createDocument(Element rootElement);
041    
042            public Document createDocument(String encoding);
043    
044            public Element createElement(QName qName);
045    
046            public Element createElement(String name);
047    
048            public Entity createEntity(String name, String text);
049    
050            public ProcessingInstruction createProcessingInstruction(
051                    String target, Map<String, String> data);
052    
053            public ProcessingInstruction createProcessingInstruction(
054                    String target, String data);
055    
056            public Namespace createNamespace(String uri);
057    
058            public Namespace createNamespace(String prefix, String uri);
059    
060            public QName createQName(String localName);
061    
062            public QName createQName(String localName, Namespace namespace);
063    
064            public Text createText(String text);
065    
066            public XPath createXPath(String xpathExpression);
067    
068            public Document read(File file) throws DocumentException;
069    
070            public Document read(File file, boolean validate)
071                    throws DocumentException;
072    
073            public Document read(InputStream is) throws DocumentException;
074    
075            public Document read(InputStream is, boolean validate)
076                    throws DocumentException;
077    
078            public Document read(Reader reader) throws DocumentException;
079    
080            public Document read(Reader reader, boolean validate)
081                    throws DocumentException;
082    
083            public Document read(String xml) throws DocumentException;
084    
085            public Document read(String xml, boolean validate)
086                    throws DocumentException;
087    
088            public Document read(URL url) throws DocumentException;
089    
090            public Document read(URL url, boolean validate) throws DocumentException;
091    
092            public Document readURL(String url)
093                    throws DocumentException, MalformedURLException;
094    
095            public Document readURL(String url, boolean validate)
096                    throws DocumentException, MalformedURLException;
097    
098            public List<Node> selectNodes(
099                    String xpathFilterExpression, List<Node> nodes);
100    
101            public List<Node> selectNodes(String xpathFilterExpression, Node node);
102    
103            public void sort(List<Node> nodes, String xpathExpression);
104    
105            public void sort(
106                    List<Node> nodes, String xpathExpression, boolean distinct);
107    
108    }