Class SLDHandler
- java.lang.Object
-
- org.hortonmachine.gears.utils.style.sld.StyleHandler
-
- org.hortonmachine.gears.utils.style.sld.SLDHandler
-
public class SLDHandler extends StyleHandler
SLD style handler.- Author:
- Justin Deoliveira, OpenGeo
-
-
Field Summary
Fields Modifier and Type Field Description static StringFORMATstatic StringMIMETYPE_10static StringMIMETYPE_11static org.geotools.util.VersionVERSION_10static org.geotools.util.VersionVERSION_11-
Fields inherited from class org.hortonmachine.gears.utils.style.sld.StyleHandler
IMAGE_EXTENSIONS, IMAGE_TYPES, styleFactory
-
-
Constructor Summary
Constructors Constructor Description SLDHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidencode(org.geotools.styling.StyledLayerDescriptor sld, org.geotools.util.Version version, boolean pretty, OutputStream output)Encodes a style.StringgetCodeMirrorEditMode()Returns the identifier for the mode used for syntax highlighting in the code mirror editor.StringgetStyle(StyleType type, Color color, String colorName, String layerName)Generates a style from a template using the provided substitutions.List<org.geotools.util.Version>getVersions()Supported format versions.StringinsertImageCode(String imageFileName)StringmimeType(org.geotools.util.Version version)Returns the format mime type for the specified version.org.geotools.styling.StyledLayerDescriptorparse(Object input, org.geotools.util.Version version, org.geotools.styling.ResourceLocator resourceLocator, EntityResolver entityResolver)Parses a style resource.List<Exception>validate(Object input, org.geotools.util.Version version, EntityResolver entityResolver)Validates a style resource.org.geotools.util.Versionversion(Object input)Determines the version of the format/language of the specified style resource.org.geotools.util.VersionversionForMimeType(String mimeType)Returns the format version for the specified mime type.-
Methods inherited from class org.hortonmachine.gears.utils.style.sld.StyleHandler
getFileExtension, getFormat, getName, imageExtensions, toReader
-
-
-
-
Field Detail
-
FORMAT
public static final String FORMAT
- See Also:
- Constant Field Values
-
VERSION_10
public static final org.geotools.util.Version VERSION_10
-
VERSION_11
public static final org.geotools.util.Version VERSION_11
-
MIMETYPE_10
public static final String MIMETYPE_10
- See Also:
- Constant Field Values
-
MIMETYPE_11
public static final String MIMETYPE_11
- See Also:
- Constant Field Values
-
-
Method Detail
-
getVersions
public List<org.geotools.util.Version> getVersions()
Description copied from class:StyleHandlerSupported format versions.- Overrides:
getVersionsin classStyleHandler
-
getCodeMirrorEditMode
public String getCodeMirrorEditMode()
Description copied from class:StyleHandlerReturns the identifier for the mode used for syntax highlighting in the code mirror editor.Defaults to
StyleHandler.getFormat()- Overrides:
getCodeMirrorEditModein classStyleHandler
-
getStyle
public String getStyle(StyleType type, Color color, String colorName, String layerName)
Description copied from class:StyleHandlerGenerates a style from a template using the provided substitutions.- Overrides:
getStylein classStyleHandler- Parameters:
type- the template type, seeorg.geoserver.catalog.StyleType.color- java.aw.Color to use during substitutioncolorName- Human readable color name, for use generating commentslayerName- Layer name, for use generating comments- Returns:
- The text content of the style template after performing substitutions
-
mimeType
public String mimeType(org.geotools.util.Version version)
Description copied from class:StyleHandlerReturns the format mime type for the specified version.- Specified by:
mimeTypein classStyleHandler
-
versionForMimeType
public org.geotools.util.Version versionForMimeType(String mimeType)
Description copied from class:StyleHandlerReturns the format version for the specified mime type.This method should only be overriden by formats that support multiple versions. The default implementation just returns 1.0.0.
- Overrides:
versionForMimeTypein classStyleHandler
-
parse
public org.geotools.styling.StyledLayerDescriptor parse(Object input, org.geotools.util.Version version, org.geotools.styling.ResourceLocator resourceLocator, EntityResolver entityResolver) throws IOException
Description copied from class:StyleHandlerParses a style resource.- Specified by:
parsein classStyleHandler- Parameters:
input- The style input, seeStyleHandler.toReader(Object)for accepted inputs.version- Optional version of the format, maybenullresourceLocator- Optional locator for resources (icons, etc...) referenced by the style, may benull.entityResolver- Optional entity resolver for XML based formats, may benull.- Throws:
IOException
-
encode
public void encode(org.geotools.styling.StyledLayerDescriptor sld, org.geotools.util.Version version, boolean pretty, OutputStream output) throws IOExceptionDescription copied from class:StyleHandlerEncodes a style.Handlers that don't support encoding should throw
UnsupportedOperationException.- Specified by:
encodein classStyleHandler- Parameters:
sld- The style to encode.version- The version of the format to use to encode the style, may benull.pretty- Flag controlling whether or not the style should be encoded in pretty form.output- The stream to write the encoded style to.- Throws:
IOException
-
validate
public List<Exception> validate(Object input, org.geotools.util.Version version, EntityResolver entityResolver) throws IOException
Description copied from class:StyleHandlerValidates a style resource.For handlers that don't support an extended form of validation (like against an XML schema) this implementation should at a minimum attempt to parse the input and return any parsing errors.
- Specified by:
validatein classStyleHandler- Parameters:
input- The style input, seeStyleHandler.toReader(Object)for accepted inputs.version- The version of the format to use to validate the style, may benull.- Returns:
- Any validation errors, or empty list if the style is valid.
- Throws:
IOException
-
version
public org.geotools.util.Version version(Object input) throws IOException
Description copied from class:StyleHandlerDetermines the version of the format/language of the specified style resource.This method should only be overriden by formats that support multiple versions. The default implementation just returns 1.0.0.
- Overrides:
versionin classStyleHandler- Parameters:
input- The style input, seeStyleHandler.toReader(Object)for accepted inputs.- Throws:
IOException
-
insertImageCode
public String insertImageCode(String imageFileName)
- Overrides:
insertImageCodein classStyleHandler
-
-