001 //$HeadURL: $
002 /*---------------- FILE HEADER ------------------------------------------
003 This file is part of deegree.
004 Copyright (C) 2001-2008 by:
005 Department of Geography, University of Bonn
006 http://www.giub.uni-bonn.de/deegree/
007 lat/lon GmbH
008 http://www.lat-lon.de
009
010 This library is free software; you can redistribute it and/or
011 modify it under the terms of the GNU Lesser General Public
012 License as published by the Free Software Foundation; either
013 version 2.1 of the License, or (at your option) any later version.
014 This library is distributed in the hope that it will be useful,
015 but WITHOUT ANY WARRANTY; without even the implied warranty of
016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017 Lesser General Public License for more details.
018 You should have received a copy of the GNU Lesser General Public
019 License along with this library; if not, write to the Free Software
020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021 Contact:
022
023 Andreas Poth
024 lat/lon GmbH
025 Aennchenstr. 19
026 53177 Bonn
027 Germany
028 E-Mail: poth@lat-lon.de
029
030 Prof. Dr. Klaus Greve
031 Department of Geography
032 University of Bonn
033 Meckenheimer Allee 166
034 53115 Bonn
035 Germany
036 E-Mail: greve@giub.uni-bonn.de
037 ---------------------------------------------------------------------------*/
038
039 package org.deegree.owscommon_1_1_0;
040
041 import static org.deegree.framework.xml.XMLTools.getElement;
042 import static org.deegree.framework.xml.XMLTools.getNodesAsStringList;
043 import static org.deegree.ogcbase.CommonNamespaces.OWS_1_1_0PREFIX;
044
045 import java.util.ArrayList;
046 import java.util.List;
047
048 import org.deegree.framework.xml.XMLFragment;
049 import org.deegree.framework.xml.XMLParsingException;
050 import org.w3c.dom.Element;
051
052 /**
053 * <code>GetCapabilitiesDocument</code> parses the OWSCommon 1.1.0 part of a <code>GetCapabilities</code> request.
054 *
055 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
056 *
057 * @author last edited by: $Author:$
058 *
059 * @version $Revision:$, $Date:$
060 *
061 */
062 public class GetCapabilitiesDocument extends XMLFragment {
063
064 private static final long serialVersionUID = -4559202452840295387L;
065
066 private final static String PRE = OWS_1_1_0PREFIX + ":";
067
068 /**
069 *
070 * @return a list of versions the client requested or an empty list if no versions were given.
071 * @throws XMLParsingException
072 * if the node could not be parsed.
073 */
074 public List<String> parseAcceptVersions( )
075 throws XMLParsingException {
076 Element root = getRootElement();
077 List<String> result = new ArrayList<String>();
078 if ( root != null ) {
079 Element acceptVersions = getElement( root, PRE + "AcceptVersions", nsContext );
080 if ( acceptVersions != null ) {
081 result = getNodesAsStringList( acceptVersions, PRE + "Version", nsContext );
082 }
083 }
084 return result;
085 }
086
087 /**
088 * @return a list of sections the client requested or an empty list if no sections were given.
089 * @throws XMLParsingException
090 * if the node could not be parsed.
091 */
092 public List<String> parseSections( )
093 throws XMLParsingException {
094 Element root = getRootElement();
095 List<String> result = new ArrayList<String>();
096 if ( root != null ) {
097 Element sections = getElement( root, PRE + "Sections", nsContext );
098 if ( sections != null ) {
099 result = getNodesAsStringList( sections, PRE + "Section", nsContext );
100 }
101 }
102 return result;
103 }
104
105 /**
106 * @return a list of AcceptedFormats the client requested or an empty list if no AcceptedFormats were given.
107 * @throws XMLParsingException
108 * if the node could not be parsed.
109 */
110 public List<String> parseAcceptFormats( )
111 throws XMLParsingException {
112 Element root = getRootElement();
113 List<String> result = new ArrayList<String>();
114 if ( root != null ) {
115 Element acceptFormats = getElement( root, PRE + "AcceptFormats", nsContext );
116 if ( acceptFormats != null ) {
117 result = getNodesAsStringList( acceptFormats, PRE + "OutputFormat", nsContext );
118 }
119 }
120 return result;
121 }
122
123 /**
124 *
125 * @return the update sequence string or an empty string if not given.
126 */
127 public String parseUpdateSequence( ) {
128 Element root = getRootElement();
129 String result = new String();
130 if ( root != null ) {
131 result = root.getAttribute( "updateSequence" );
132 }
133 return result;
134 }
135
136 }