Class SLDHandler


  • public class SLDHandler
    extends StyleHandler
    SLD style handler.
    Author:
    Justin Deoliveira, OpenGeo
    • Constructor Detail

      • SLDHandler

        public SLDHandler()
    • Method Detail

      • getStyle

        public String getStyle​(StyleType type,
                               Color color,
                               String colorName,
                               String layerName)
        Description copied from class: StyleHandler
        Generates a style from a template using the provided substitutions.
        Overrides:
        getStyle in class StyleHandler
        Parameters:
        type - the template type, see org.geoserver.catalog.StyleType.
        color - java.aw.Color to use during substitution
        colorName - Human readable color name, for use generating comments
        layerName - 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: StyleHandler
        Returns the format mime type for the specified version.
        Specified by:
        mimeType in class StyleHandler
      • versionForMimeType

        public org.geotools.util.Version versionForMimeType​(String mimeType)
        Description copied from class: StyleHandler
        Returns 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:
        versionForMimeType in class StyleHandler
      • 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: StyleHandler
        Parses a style resource.
        Specified by:
        parse in class StyleHandler
        Parameters:
        input - The style input, see StyleHandler.toReader(Object) for accepted inputs.
        version - Optional version of the format, maybe null
        resourceLocator - Optional locator for resources (icons, etc...) referenced by the style, may be null.
        entityResolver - Optional entity resolver for XML based formats, may be null .
        Throws:
        IOException
      • encode

        public void encode​(org.geotools.styling.StyledLayerDescriptor sld,
                           org.geotools.util.Version version,
                           boolean pretty,
                           OutputStream output)
                    throws IOException
        Description copied from class: StyleHandler
        Encodes a style.

        Handlers that don't support encoding should throw UnsupportedOperationException.

        Specified by:
        encode in class StyleHandler
        Parameters:
        sld - The style to encode.
        version - The version of the format to use to encode the style, may be null .
        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: StyleHandler
        Validates 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:
        validate in class StyleHandler
        Parameters:
        input - The style input, see StyleHandler.toReader(Object) for accepted inputs.
        version - The version of the format to use to validate the style, may be null .
        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: StyleHandler
        Determines 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:
        version in class StyleHandler
        Parameters:
        input - The style input, see StyleHandler.toReader(Object) for accepted inputs.
        Throws:
        IOException