net.sf.saxon.java

## Class JavaPlatform

- java.lang.Object
- - net.sf.saxon.java.JavaPlatform

- All Implemented Interfaces:
    Serializable, Platform
  Direct Known Subclasses:
    JavaPlatformPE

      public class JavaPlatform
      extends Object
      implements Platform

  Implementation of the Platform class containing methods specific to the Java platform (as distinct from .NET). This is a singleton class with no instance data.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaPlatform()` The constructor is called during the static initialization of the Configuration

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addFunctionLibraries(FunctionLibraryList list, Configuration config, int hostLanguage)` Add the platform-specific function libraries to a function library list.
    `boolean` | `canReturnCollationKeys(StringCollator collation)` Given a collation, determine whether it is capable of returning collation keys.
    `RegularExpression` | `compileRegularExpression(CharSequence regex, String flags, String hostLanguage, List<String> warnings)` Compile a regular expression
    `ClassLoader` | `getClassLoaderForGeneratedClass(String definedClassName, byte[] classFile, Configuration config, Class thisClass)` Return the class loader required to load the bytecode generated classes
    `Object` | `getCollationKey(SimpleCollation namedCollation, String value)` Given a collation, get a collation key.
    `SchemaType` | `getExternalObjectType(Configuration config, String uri, String localName)` Get a SchemaType representing a wrapped external (Java or .NET) object
    `String` | `getInstallationDirectory(String edition, Configuration config)` Return the name of the directory in which the software is installed (if available)
    `Source` | `getParserSource(PipelineConfiguration pipe, StreamSource input, int validation, boolean dtdValidation, int stripspace)` Convert a StreamSource to either a SAXSource or a PullSource, depending on the native parser of the selected platform
    `String` | `getPlatformSuffix()` Get a suffix letter to add to the Saxon version number to identify the platform
    `String` | `getPlatformVersion()` Get the platform version
    `void` | `initialize(Configuration config)` Perform platform-specific initialization of the configuration
    `boolean` | `isDotNet()` Return true if this is the .NET platform
    `boolean` | `isJava()` Return true if this is the Java platform
    `XMLReader` | `loadParser()` Get a parser by instantiating the SAXParserFactory
    `StringCollator` | `makeCollation(Configuration config, Properties props, String uri)` Obtain a collation with a given set of properties.
    `void` | `registerAllBuiltInObjectModels(Configuration config)` Register all the external object models that are provided as standard with the relevant edition of Saxon for this Configuration
    `void` | `setDefaultSAXParserFactory()` Set the default XML parser to be loaded by the SAXParserFactory on this platform.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### JavaPlatform

          public JavaPlatform()

      The constructor is called during the static initialization of the Configuration

  - ### Method Detail

    - #### initialize

          public void initialize(Configuration config)

      Perform platform-specific initialization of the configuration
      Specified by:
        `initialize` in interface `Platform`
      Parameters:
        `config` - the Saxon Configuration

    - #### isJava

          public boolean isJava()

      Return true if this is the Java platform
      Specified by:
        `isJava` in interface `Platform`
      Returns:
        true if this is the Java platform

    - #### isDotNet

          public boolean isDotNet()

      Return true if this is the .NET platform
      Specified by:
        `isDotNet` in interface `Platform`
      Returns:
        true if this is the .NET platform

    - #### getPlatformVersion

          public String getPlatformVersion()

      Get the platform version
      Specified by:
        `getPlatformVersion` in interface `Platform`
      Returns:
        the version of the platform, for example "Java version 1.5.09"

    - #### getPlatformSuffix

          public String getPlatformSuffix()

      Get a suffix letter to add to the Saxon version number to identify the platform
      Specified by:
        `getPlatformSuffix` in interface `Platform`
      Returns:
        "J" for Java, "N" for .NET

    - #### loadParser

          public XMLReader loadParser()

      Get a parser by instantiating the SAXParserFactory
      Specified by:
        `loadParser` in interface `Platform`
      Returns:
        the parser (XMLReader)

    - #### getParserSource

          public Source getParserSource(PipelineConfiguration pipe,
                               StreamSource input,
                               int validation,
                               boolean dtdValidation,
                               int stripspace)

      Convert a StreamSource to either a SAXSource or a PullSource, depending on the native parser of the selected platform
      Specified by:
        `getParserSource` in interface `Platform`
      Parameters:
        `pipe` - the pipeline configuration
        `input` - the supplied StreamSource
        `validation` - indicates whether schema validation is required
        `dtdValidation` - indicates whether DTD validation is required
        `stripspace` - indicates whether whitespace text nodes should be stripped
      Returns:
        the PullSource or SAXSource, initialized with a suitable parser, or the original input Source, if now special handling is required or possible. This implementation always returns the original input unchanged.

    - #### makeCollation

          public StringCollator makeCollation(Configuration config,
                                     Properties props,
                                     String uri)
                                       throws XPathException

      Obtain a collation with a given set of properties. The set of properties is extensible and variable across platforms. Common properties with example values include lang=ed-GB, strength=primary, case-order=upper-first, ignore-modifiers=yes, alphanumeric=yes. Properties that are not supported are generally ignored; however some errors, such as failing to load a requested class, are fatal.
      Specified by:
        `makeCollation` in interface `Platform`
      Parameters:
        `config` - the configuration object
        `props` - the desired properties of the collation
        `uri` - the collation URI
      Returns:
        a collation with these properties
      Throws:
        `XPathException` - if a fatal error occurs

    - #### canReturnCollationKeys

          public boolean canReturnCollationKeys(StringCollator collation)

      Given a collation, determine whether it is capable of returning collation keys. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are equal under the equals() method.
      Specified by:
        `canReturnCollationKeys` in interface `Platform`
      Parameters:
        `collation` - the collation, provided as a Comparator
      Returns:
        true if this collation can supply collation keys

    - #### getCollationKey

          public Object getCollationKey(SimpleCollation namedCollation,
                               String value)

      Given a collation, get a collation key. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are compare correctly under the equals() method.
      Specified by:
        `getCollationKey` in interface `Platform`
      Parameters:
        `namedCollation` - the collation in use
        `value` - the string whose collation key is required
      Returns:
        a representation of the collation key, such that two collation keys are equal() if and only if the string values they represent are equal under the specified collation.
      Throws:
        `ClassCastException` - if the collation is not one that is capable of supplying collation keys (this should have been checked in advance)

    - #### compileRegularExpression

          public RegularExpression compileRegularExpression(CharSequence regex,
                                                   String flags,
                                                   String hostLanguage,
                                                   List<String> warnings)
                                                     throws XPathException

      Compile a regular expression
      Specified by:
        `compileRegularExpression` in interface `Platform`
      Parameters:
        `regex` - the regular expression as a string
        `flags` - the value of the flags attribute
        `hostLanguage` - one of "XSD10", "XSD11", "XP20" or "XP30"
        `warnings` -
      Returns:
        the compiled regular expression
      Throws:
        `XPathException` - if the regular expression or the flags are invalid

    - #### addFunctionLibraries

          public void addFunctionLibraries(FunctionLibraryList list,
                                  Configuration config,
                                  int hostLanguage)

      Add the platform-specific function libraries to a function library list. This version of the method does nothing
      Parameters:
        `list` - the function library list that is to be extended
        `config` - the Configuration
        `hostLanguage` - the host language, for example Configuration.XQUERY

    - #### getExternalObjectType

          public SchemaType getExternalObjectType(Configuration config,
                                         String uri,
                                         String localName)

      Description copied from interface: `Platform`
      Get a SchemaType representing a wrapped external (Java or .NET) object
      Specified by:
        `getExternalObjectType` in interface `Platform`
      Parameters:
        `config` - the Saxon Configuration
        `uri` - the namespace URI of the schema type
        `localName` - the local name of the schema type
      Returns:
        the SchemaType object representing this type

    - #### getInstallationDirectory

          public String getInstallationDirectory(String edition,
                                        Configuration config)

      Return the name of the directory in which the software is installed (if available)
      Specified by:
        `getInstallationDirectory` in interface `Platform`
      Parameters:
        `edition` -
        `config` - the Saxon configuration
      Returns:
        the name of the directory in which Saxon is installed, if available, or null otherwise

    - #### registerAllBuiltInObjectModels

          public void registerAllBuiltInObjectModels(Configuration config)

      Register all the external object models that are provided as standard with the relevant edition of Saxon for this Configuration
      Specified by:
        `registerAllBuiltInObjectModels` in interface `Platform`
      Since:
        9.3

    - #### setDefaultSAXParserFactory

          public void setDefaultSAXParserFactory()

      Set the default XML parser to be loaded by the SAXParserFactory on this platform. Needed because the Apache catalog resolver uses the SAXParserFactory to instantiate a parser, and if not customized this causes a failure on the .NET platform.
      Specified by:
        `setDefaultSAXParserFactory` in interface `Platform`
      Since:
        9.4

    - #### getClassLoaderForGeneratedClass

          public ClassLoader getClassLoaderForGeneratedClass(String definedClassName,
                                                    byte[] classFile,
                                                    Configuration config,
                                                    Class thisClass)

      Description copied from interface: `Platform`
      Return the class loader required to load the bytecode generated classes
      Specified by:
        `getClassLoaderForGeneratedClass` in interface `Platform`
      Parameters:
        `definedClassName` - The generated class name
        `classFile` - The bytecode of the generated class
        `config` - The cThe saxon configuration
        `thisClass` - The class object generated
      Returns:
        the class loader object

Copyright (c) 2004-2013 Saxonica Limited. All rights reserved.