org.geotools.styling
Class SLDParser

Object
  extended by SLDParser

public class SLDParser
extends Object

TODO: This really needs to be container ready

Author:
jgarnett
Module:
trunk/gt/modules   (gt-modules.jar) (Maven report) (SVN head)

Field Summary
protected  StyleFactory factory
           
protected  InputSource source
           
 
Constructor Summary
SLDParser(StyleFactory factory)
          Create a Stylereader - use if you already have a dom to parse.
SLDParser(StyleFactory factory, File f)
          Creates a new SLDStyle object.
SLDParser(StyleFactory factory, FilterFactory filterFactory)
           
SLDParser(StyleFactory factory, InputStream s)
          Creates a new SLDStyle object.
SLDParser(StyleFactory factory, Reader r)
          Creates a new SLDStyle object.
SLDParser(StyleFactory factory, String filename)
          Creates a new instance of SLDStyler
SLDParser(StyleFactory factory, URL url)
          Creates a new SLDStyle object.
 
Method Summary
 StyledLayerDescriptor parseDescriptor(Node root)
           
 NamedStyle parseNamedStyle(Node n)
          Parses a NamedStyle from node.
 StyledLayerDescriptor parseSLD()
           
 Style parseStyle(Node n)
          build a style for the Node provided
 Style[] readDOM(Document document)
          Read the DOM provided and create a Style object for each user style found
 Style[] readXML()
          Read the xml inputsource provided and create a Style object for each user style found
 void setInput(File f)
          Sets the file to use to read the SLD from
 void setInput(InputStream in)
          Sets the input stream to read the SLD from
 void setInput(Reader in)
          Sets the input stream to read the SLD from
 void setInput(String filename)
          set the file to read the SLD from
 void setInput(URL url)
          sets an URL to read the SLD from
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected InputSource source

factory

protected StyleFactory factory
Constructor Detail

SLDParser

public SLDParser(StyleFactory factory)
Create a Stylereader - use if you already have a dom to parse.

Parameters:
factory - The StyleFactory to use to build the style

SLDParser

public SLDParser(StyleFactory factory,
                 FilterFactory filterFactory)

SLDParser

public SLDParser(StyleFactory factory,
                 String filename)
          throws FileNotFoundException
Creates a new instance of SLDStyler

Parameters:
factory - The StyleFactory to use to read the file
filename - The file to be read.
Throws:
FileNotFoundException - - if the file is missing

SLDParser

public SLDParser(StyleFactory factory,
                 File f)
          throws FileNotFoundException
Creates a new SLDStyle object.

Parameters:
factory - The StyleFactory to use to read the file
f - the File to be read
Throws:
FileNotFoundException - - if the file is missing

SLDParser

public SLDParser(StyleFactory factory,
                 URL url)
          throws IOException
Creates a new SLDStyle object.

Parameters:
factory - The StyleFactory to use to read the file
url - the URL to be read.
Throws:
IOException - - if something goes wrong reading the file

SLDParser

public SLDParser(StyleFactory factory,
                 InputStream s)
Creates a new SLDStyle object.

Parameters:
factory - The StyleFactory to use to read the file
s - The inputstream to be read

SLDParser

public SLDParser(StyleFactory factory,
                 Reader r)
Creates a new SLDStyle object.

Parameters:
factory - The StyleFactory to use to read the file
r - The inputstream to be read
Method Detail

setInput

public void setInput(String filename)
              throws FileNotFoundException
set the file to read the SLD from

Parameters:
filename - the file to read the SLD from
Throws:
FileNotFoundException - if the file is missing

setInput

public void setInput(File f)
              throws FileNotFoundException
Sets the file to use to read the SLD from

Parameters:
f - the file to use
Throws:
FileNotFoundException - if the file is missing

setInput

public void setInput(URL url)
              throws IOException
sets an URL to read the SLD from

Parameters:
url - the url to read the SLD from
Throws:
IOException - If anything goes wrong opening the url

setInput

public void setInput(InputStream in)
Sets the input stream to read the SLD from

Parameters:
in - the inputstream used to read the SLD from

setInput

public void setInput(Reader in)
Sets the input stream to read the SLD from

Parameters:
in - the inputstream used to read the SLD from

readXML

public Style[] readXML()
Read the xml inputsource provided and create a Style object for each user style found

Returns:
Style[] the styles constructed.
Throws:
RuntimeException - if a parsing error occurs

readDOM

public Style[] readDOM(Document document)
Read the DOM provided and create a Style object for each user style found

Parameters:
document - a dom containing the SLD
Returns:
Style[] the styles constructed.

parseSLD

public StyledLayerDescriptor parseSLD()

parseDescriptor

public StyledLayerDescriptor parseDescriptor(Node root)

parseNamedStyle

public NamedStyle parseNamedStyle(Node n)
Parses a NamedStyle from node.

A NamedStyle is used to refer to a style that has a name in a WMS, and is defined as:


 <xsd:element name="NamedStyle">
  <xsd:annotation>
   <xsd:documentation> A NamedStyle is used to refer to a style that has a name in a WMS. </xsd:documentation>
  </xsd:annotation>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="sld:Name"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 

Parameters:
n -

parseStyle

public Style parseStyle(Node n)
build a style for the Node provided

Parameters:
n - the node which contains the style to be parsed.
Returns:
the Style constructed.
Throws:
RuntimeException - if an error occurs setting up the parser


Copyright © 1996-2009 Geotools. All Rights Reserved.