001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/graphics/sld/RemoteOWS.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035    ----------------------------------------------------------------------------*/
036    package org.deegree.graphics.sld;
037    
038    import static org.deegree.framework.xml.XMLTools.escape;
039    
040    import java.net.URL;
041    
042    import org.deegree.framework.xml.Marshallable;
043    
044    /**
045     * Since a layer is defined as a collection of potentially mixed-type features, the UserLayer
046     * element must provide the means to identify the features to be used. All features to be rendered
047     * are assumed to be fetched from a Web Feature Server (WFS) or a Web Coverage CapabilitiesService
048     * (WCS, in which case the term features is used loosely).
049     * <p>
050     * </p>
051     * The remote server to be used is identified by RemoteOWS (OGC Web CapabilitiesService) element.
052     *
053     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
054     * @author last edited by: $Author: apoth $
055     * @version $Revision: 24806 $ $Date: 2010-06-09 16:41:16 +0200 (Mi, 09 Jun 2010) $
056     */
057    public class RemoteOWS implements Marshallable {
058    
059        /**
060         * WFS
061         */
062        final static public String WFS = "WFS";
063    
064        /**
065         * WCS
066         */
067        final static public String WCS = "WCS";
068    
069        private String service = null;
070    
071        private URL onlineResource = null;
072    
073        /**
074         * Creates a new RemoteOWS object.
075         *
076         * @param service
077         * @param onlineResource
078         */
079        RemoteOWS( String service, URL onlineResource ) {
080            setService( service );
081            setOnlineResource( onlineResource );
082        }
083    
084        /**
085         * type of service that is represented by the remote ows. at the moment <tt>WFS</tt> and
086         * <tt>WCS</tt> are possible values.
087         *
088         * @return the type of the services
089         *
090         */
091        public String getService() {
092            return service;
093        }
094    
095        /**
096         * @see RemoteOWS#getService()
097         * @param service
098         *            the type of the services
099         *
100         */
101        public void setService( String service ) {
102            this.service = service;
103        }
104    
105        /**
106         * address of the the ows as URL
107         *
108         * @return the adress of the ows as URL
109         *
110         */
111        public URL getOnlineResource() {
112            return onlineResource;
113        }
114    
115        /**
116         * @see RemoteOWS#getOnlineResource()
117         * @param onlineResource
118         *            the adress of the ows as URL
119         *
120         */
121        public void setOnlineResource( URL onlineResource ) {
122            this.onlineResource = onlineResource;
123        }
124    
125        /**
126         * exports the content of the RemoteOWS as XML formated String
127         *
128         * @return xml representation of the RemoteOWS
129         */
130        public String exportAsXML() {
131    
132            StringBuffer sb = new StringBuffer( 200 );
133            sb.append( "<RemoteOWS>" );
134            sb.append( "<Service>" ).append( escape( service ) ).append( "</Service>" );
135            sb.append( "<OnlineResource xmlns:xlink='http://www.w3.org/1999/xlink' " );
136            sb.append( "xlink:type='simple' xlink:href='" );
137            sb.append( escape( onlineResource.toExternalForm() ) + "'/>" );
138            sb.append( "</RemoteOWS>" );
139    
140            return sb.toString();
141        }
142    }