Debian Codegraph @

net/sf/saxon/Platform.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon;
9
10 import net.sf.saxon.event.PipelineConfiguration;
11 import net.sf.saxon.expr.StaticContext;
12 import net.sf.saxon.expr.parser.RetainedStaticContext;
13 import net.sf.saxon.expr.sort.AtomicMatchKey;
14 import net.sf.saxon.expr.sort.SimpleCollation;
15 import net.sf.saxon.lib.ModuleURIResolver;
16 import net.sf.saxon.lib.StringCollator;
17 import net.sf.saxon.regex.RegularExpression;
18 import net.sf.saxon.trans.XPathException;
19 import net.sf.saxon.type.ExternalObjectType;
20 import org.xml.sax.XMLReader;
21
22 import javax.xml.transform.Source;
23 import javax.xml.transform.stream.StreamSource;
24 import java.util.List;
25 import java.util.Properties;
26
27 /**
28 * This interface provides access to methods whose implementation depends on the chosen platform
29 * (typically Java or .NET)
30 */
31 public interface Platform {
32
33 /**
34 * Perform platform-specific initialization of the configuration
35 *
36 * @param config the Saxon Configuration
37 */
38
39 void initialize(Configuration config);
40
41 /**
42 * Return true if this is the Java platform
43 *
44 * @return true if this is the Java platform
45 */
46
47 boolean isJava();
48
49 /**
50 * Return true if this is the .NET platform
51 *
52 * @return true if this is the .NET platform
53 */
54
55 boolean isDotNet();
56
57 /**
58 * Get the platform version
59 *
60 * @return the version of the platform, for example "Java version 1.5.09"
61 */
62
63 String getPlatformVersion();
64
65 /**
66 * Get a suffix letter to add to the Saxon version number to identify the platform
67 *
68 * @return "J" for Java, "N" for .NET
69 */
70
71 String getPlatformSuffix();
72
73 /**
74 * Get a parser by instantiating the SAXParserFactory
75 *
76 * @return the parser (XMLReader)
77 */
78
79 XMLReader loadParser();
80
81
82 /**
83 * Get a parser by instantiating the SAXParserFactory
84 *
85 * @return the parser (XMLReader)
86 */
87
88 XMLReader loadParserForXmlFragments();
89
90 /**
91 * Convert a StreamSource to either a SAXSource or a PullSource, depending on the native
92 * parser of the selected platform
93 *
94 * @param pipe the pipeline Configuration
95 * @param input the supplied StreamSource
96 * @param validation required validation mode, for example Validation.STRICT
97 * @param dtdValidation true if DTD-based input validation is required
98 * @param stripspace option for whitespace-stripping (ALL, NONE, or IGNORABLE)
99 * @return the PullSource or SAXSource, initialized with a suitable parser, or the original
100 * input Source, if now special handling is required or possible
101 */
102
103 Source getParserSource(PipelineConfiguration pipe, StreamSource input,
104 int validation, boolean dtdValidation, int stripspace);
105
106 /**
107 * Obtain a collation with a given set of properties. The set of properties is extensible
108 * and variable across platforms. Common properties with example values include lang=en-GB,
109 * strength=primary, case-order=upper-first, ignore-modifiers=yes, alphanumeric=yes.
110 * Properties that are not supported are generally ignored; however some errors, such as
111 * failing to load a requested class, are fatal.
112 *
113 * @param config the configuration object
114 * @param props the desired properties of the collation
115 * @param uri the collation URI
116 * @return a collation with these properties
117 * @throws XPathException if a fatal error occurs
118 */
119
120 /*@Nullable*/
121 StringCollator makeCollation(Configuration config, Properties props, String uri) throws XPathException;
122
123 /**
124 * Given a collation, determine whether it is capable of returning collation keys.
125 * The essential property of collation keys
126 * is that if two values are equal under the collation, then the collation keys are
127 * equal under the equals() method.
128 *
129 * @param collation the collation being examined, provided as a Comparator
130 * @return true if this collation can supply collation keys
131 */
132
133 boolean canReturnCollationKeys(StringCollator collation);
134
135 /**
136 * Given a collation, get a collation key. The essential property of collation keys
137 * is that if two values are equal under the collation, then the collation keys are
138 * equal under the equals() method.
139 *
140 * @param namedCollation the collation in use
141 * @param value the string whose collation key is required
142 * @return a representation of the collation key, such that two collation keys are
143 * equal() if and only if the string values they represent are equal under the specified collation.
144 * @throws ClassCastException if the collation is not one that is capable of supplying
145 * collation keys (this should have been checked in advance)
146 */
147
148 AtomicMatchKey getCollationKey(SimpleCollation namedCollation, String value);
149
150
151 /**
152 * Indicate whether the ICU library is available and supports Collations
153 * @return true if the ICU library class for collations appears to be loaded
154 */
155 boolean hasICUCollator();
156
157 /**
158 * Indicate whether the ICU library is available and supports Numberers
159 * @return true if the ICU library class for rule-based numbering appears to be loaded
160 */
161 boolean hasICUNumberer();
162
163 /**
164 * If available, make a UCA collation. Depending on the Saxon edition and licensing,
165 * this will use the ICU-J Library if available, or the built-in Java collation support
166 * otherwise.
167 * @param uri the collation URI (which will always be a UCA collation URI as defined in XSLT 3.0)
168 * @param config the Saxon configuration
169 * @return the collation, or null if not available
170 * @throws XPathException if the URI is malformed in some way
171 */
172
173 StringCollator makeUcaCollator(String uri, Configuration config) throws XPathException;
174
175 /**
176 * Compile a regular expression
177 *
178 *
179 * @param config the Saxon configuration
180 * @param regex the regular expression as a string
181 * @param flags the value of the flags attribute
182 * @param hostLanguage one of "XSD10", "XSD11", XP20" or "XP30". Also allow combinations, e.g. "XP20/XSD11".
183 * @param warnings if non-null, any warnings from the regular expression compiler will be added to this list.
184 * If null, the warnings are ignored.
185 * @return the compiled regular expression
186 * @throws XPathException if the regular expression or the flags are invalid
187 */
188
189 RegularExpression compileRegularExpression(Configuration config, CharSequence regex, String flags, String hostLanguage, List<String> warnings)
190 throws XPathException;
191
192 /**
193 * Get a SchemaType representing a wrapped external (Java or .NET) object
194 *
195 * @param config the Saxon Configuration
196 * @param uri the namespace URI of the schema type
197 * @param localName the local name of the schema type
198 * @return the SchemaType object representing this type
199 */
200
201 ExternalObjectType getExternalObjectType(Configuration config, String uri, String localName);
202
203 /**
204 * Return the name of the directory in which the software is installed (if available)
205 *
206 * @param edition The edition of the software that is loaded ("HE", "PE", or "EE")
207 * @param config the Saxon configuration
208 * @return the name of the directory in which Saxon is installed, if available, or null otherwise
209 */
210
211 String getInstallationDirectory(String edition, Configuration config);
212
213 /**
214 * Register all the external object models that are provided as standard
215 * with the relevant edition of Saxon for this Configuration
216 *
217 * @param config the Saxon configuration
218 * @since 9.3
219 */
220
221 void registerAllBuiltInObjectModels(Configuration config);
222
223 /**
224 * Set the default XML parser to be loaded by the SAXParserFactory on this platform.
225 * Needed because the Apache catalog resolver uses the SAXParserFactory to instantiate
226 * a parser, and if not customized this causes a failure on the .NET platform.
227 *
228 * @param config the Saxon configuration
229 * @since 9.4
230 */
231
232 void setDefaultSAXParserFactory(Configuration config);
233
234
235 /**
236 * Checks if the supplied static context is an instance of the JAXP static context.
237 * On Java we create namespace information from the JAXP XPath static context.
238 * On the .NET platform we do nothing.
239 * @param retainedStaticContext
240 * @param sc
241 * @return boolean
242 * @since 9.7.0.5
243 *
244 */
245
246 boolean JAXPStaticContextCheck(RetainedStaticContext retainedStaticContext, StaticContext sc);
247
248 /**
249 * Make an instance of the default module URI resolver for this platform
250 * @param config the Saxon configuration
251 * @return an instance of ModuleURIResolver
252 * @since 9.7.0.2
253 */
254
255 ModuleURIResolver makeStandardModuleURIResolver(Configuration config);
256
257
258 //#if BYTECODE==true
259 /**
260 * Return the class loader required to load the bytecode generated classes
261 *
262 * @param config The saxon configuration
263 * @param thisClass The class object generated
264 * @return the class loader object
265 * @since 9.6.0.3
266 */
267
268 ClassLoader makeGeneratedClassLoader(Configuration config, Class thisClass);
269 //#endif
270
271 }
272