Package net.sf.saxon.java
Class JavaPlatform
- java.lang.Object
-
- net.sf.saxon.java.JavaPlatform
-
- All Implemented Interfaces:
java.io.Serializable,Platform
public class JavaPlatform extends java.lang.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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFunctionLibraries(FunctionLibraryList list, Configuration config, int hostLanguage)Add the platform-specific function libraries to a function library list.booleancanReturnCollationKeys(StringCollator collation)Given a collation, determine whether it is capable of returning collation keys.RegularExpressioncompileRegularExpression(java.lang.CharSequence regex, int xmlVersion, int syntax, java.lang.CharSequence flags)Create a compiled regular expressionvoiddeclareJavaClass(FunctionLibrary library, java.lang.String uri, java.lang.Class theClass)Register a namespace-to-Java-class mapping declared using saxon:script in an XSLT stylesheetjava.lang.ObjectgetCollationKey(NamedCollation namedCollation, java.lang.String value)Given a collation, get a collation key.SchemaTypegetExternalObjectType(Configuration config, java.lang.String uri, java.lang.String localName)Get a SchemaType representing a wrapped external (Java or .NET) objectstatic JavaPlatformgetInstance()Get the singleton instance of this classjavax.xml.transform.SourcegetParserSource(PipelineConfiguration pipe, javax.xml.transform.stream.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 platformjava.lang.StringgetPlatformSuffix()Get a suffix letter to add to the Saxon version number to identify the platformjava.lang.StringgetPlatformVersion()Get the platform versionvoidinitialize(Configuration config)Perform platform-specific initialization of the configurationbooleanisDotNet()Return true if this is the .NET platformbooleanisJava()Return true if this is the Java platformjava.net.URImakeAbsolute(java.lang.String relativeURI, java.lang.String base)Construct an absolute URI from a relative URI and a base URI.StringCollatormakeCollation(Configuration config, java.util.Properties props, java.lang.String uri)Obtain a collation with a given set of properties.voidmakeExtensionLibrary(Configuration config)Make the default extension function factory appropriate to the platform
-
-
-
Method Detail
-
getInstance
public static JavaPlatform getInstance()
Get the singleton instance of this class- Returns:
- the singleton instance
-
initialize
public void initialize(Configuration config)
Perform platform-specific initialization of the configuration- Specified by:
initializein interfacePlatform- Parameters:
config- the Saxon Configuration
-
isJava
public boolean isJava()
Return true if this is the Java platform
-
isDotNet
public boolean isDotNet()
Return true if this is the .NET platform
-
makeAbsolute
public java.net.URI makeAbsolute(java.lang.String relativeURI, java.lang.String base) throws java.net.URISyntaxExceptionConstruct an absolute URI from a relative URI and a base URI. The method uses the resolve method of the java.net.URI class, except where the base URI uses the (non-standard) "jar:" scheme, in which case the method used isnew URL(baseURL, relativeURL).Spaces in either URI are converted to %20
If no base URI is available, and the relative URI is not an absolute URI, then the current directory is used as a base URI.
- Specified by:
makeAbsolutein interfacePlatform- Parameters:
relativeURI- the relative URI. Null is permitted provided that the base URI is an absolute URIbase- the base URI- Returns:
- the absolutized URI
- Throws:
java.net.URISyntaxException- if either of the strings is not a valid URI or if the resolution fails
-
getPlatformVersion
public java.lang.String getPlatformVersion()
Get the platform version- Specified by:
getPlatformVersionin interfacePlatform- Returns:
- the version of the platform, for example "Java version 1.5.09"
-
getPlatformSuffix
public java.lang.String getPlatformSuffix()
Get a suffix letter to add to the Saxon version number to identify the platform- Specified by:
getPlatformSuffixin interfacePlatform- Returns:
- "J" for Java, "N" for .NET
-
getParserSource
public javax.xml.transform.Source getParserSource(PipelineConfiguration pipe, javax.xml.transform.stream.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:
getParserSourcein interfacePlatform- Parameters:
pipe- the pipeline configurationinput- the supplied StreamSourcevalidation- indicates whether schema validation is requireddtdValidation- indicates whether DTD validation is requiredstripspace- 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.
-
compileRegularExpression
public RegularExpression compileRegularExpression(java.lang.CharSequence regex, int xmlVersion, int syntax, java.lang.CharSequence flags) throws XPathException
Create a compiled regular expression- Specified by:
compileRegularExpressionin interfacePlatform- Parameters:
regex- the source text of the regular expression, in XML Schema or XPath syntaxxmlVersion- set to integer 10 for XML 1.0, 11 for XML 1.1syntax- requests XPath or XML Schema regex syntaxflags- the flags argument as supplied to functions such as fn:matches(), in string form @throws XPathException if the syntax of the regular expression or flags is incorrect @return the compiled regular expression- Throws:
XPathException
-
makeCollation
public StringCollator makeCollation(Configuration config, java.util.Properties props, java.lang.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:
makeCollationin interfacePlatform- Parameters:
config- the configuration objectprops- the desired properties of the collationuri- 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:
canReturnCollationKeysin interfacePlatform- Parameters:
collation- the collation, provided as a Comparator- Returns:
- true if this collation can supply collation keys
-
getCollationKey
public java.lang.Object getCollationKey(NamedCollation namedCollation, java.lang.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:
getCollationKeyin interfacePlatform- Parameters:
namedCollation- the collation in usevalue- 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:
java.lang.ClassCastException- if the collation is not one that is capable of supplying collation keys (this should have been checked in advance)
-
makeExtensionLibrary
public void makeExtensionLibrary(Configuration config)
Make the default extension function factory appropriate to the platform- Specified by:
makeExtensionLibraryin interfacePlatform- Parameters:
config- the Saxon Configuration
-
addFunctionLibraries
public void addFunctionLibraries(FunctionLibraryList list, Configuration config, int hostLanguage)
Add the platform-specific function libraries to a function library list. The libraries that are added are those registered with the Configuration usingConfiguration.setExtensionBinder(String, net.sf.saxon.functions.FunctionLibrary)- Specified by:
addFunctionLibrariesin interfacePlatform- Parameters:
list- the function library list that is to be extendedconfig- the ConfigurationhostLanguage- the host language, for example Configuration.XQUERY
-
declareJavaClass
public void declareJavaClass(FunctionLibrary library, java.lang.String uri, java.lang.Class theClass)
Register a namespace-to-Java-class mapping declared using saxon:script in an XSLT stylesheet- Specified by:
declareJavaClassin interfacePlatform- Parameters:
library- the library to contain the function, which must be a JavaExtensionLibraryuri- the namespace of the function nametheClass- the Java class that implements this namespace
-
getExternalObjectType
public SchemaType getExternalObjectType(Configuration config, java.lang.String uri, java.lang.String localName)
Description copied from interface:PlatformGet a SchemaType representing a wrapped external (Java or .NET) object- Specified by:
getExternalObjectTypein interfacePlatform- Parameters:
config- the Saxon Configurationuri- the namespace URI of the schema typelocalName- the local name of the schema type- Returns:
- the SchemaType object representing this type
-
-