|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.hp.hpl.jena.iri.impl.AbsIRIFactoryImpl
com.hp.hpl.jena.iri.impl.IRIFactoryImpl
com.hp.hpl.jena.iri.IRIFactory
public class IRIFactory
An IRIFactory is the entry point to this module. It allows:
Any configuration of the factory to implement particular standards, or to treat particular violations as warnings or errors, must be completed before using the construct or create methods.
The easiest way to use this class is to use
one of the preconfigured factories:
semanticWebImplementation()
iriImplementation()
,
or
uriImplementation()
.
If none of these meets your application needs
then you have to configure your own factory.
When initializing a factory, the initialization methods should be used in the following order:
It is possible to make these calls in different orders, but the resultant behaviour is likely to be more confusing, and may change in future releases.
The other initialization methods (probably) do not have order dependencies.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.hp.hpl.jena.iri.ViolationCodes |
---|
ViolationCodes.Initialize |
Field Summary |
---|
Fields inherited from class com.hp.hpl.jena.iri.impl.IRIFactoryImpl |
---|
UNKNOWN_SYNTAX |
Fields inherited from interface com.hp.hpl.jena.iri.impl.Force |
---|
dns, DNS, minting, MINTING, must, MUST, security, SECURITY, should, SHOULD, SIZE |
Fields inherited from interface com.hp.hpl.jena.iri.IRIComponents |
---|
AUTHORITY, FRAGMENT, HOST, PATH, PATHQUERY, PORT, QUERY, SCHEME, USER |
Constructor Summary | |
---|---|
IRIFactory()
Create a new IRIFactory without any conformance settings. |
|
IRIFactory(IRIFactory template)
Create a new IRIFactory with the same conformance settings as the template factory. |
Method Summary | |
---|---|
void |
allowUnwiseCharacters()
Allows the unwise characters as optionally permitted by RFC 3987 (IRI). |
IRI |
construct(String scheme,
String userInfo,
String host,
int port,
String path,
String query,
String fragment)
Create an IRI from the given components. |
IRI |
construct(String scheme,
String authority,
String path,
String query,
String fragment)
Create an IRI from the given components. |
IRI |
create(String scheme,
String userInfo,
String host,
int port,
String path,
String query,
String fragment)
Create an IRI from the given components. |
IRI |
create(String scheme,
String authority,
String path,
String query,
String fragment)
Create an IRI from the given components. |
void |
dnsViolation(boolean isError,
boolean isWarning)
The factory will treat violations of statements from the specifications flagged as DNS issues, including Internationalized Domain Name issues, it is enforcing as errors, or warnings, or not at all. |
boolean |
ignoring(int code)
Is condition # code being ignored. |
static IRIFactory |
iriImplementation()
This factory implements RFC 3987 Internationalized Resource Identifiers (IRIs) . |
boolean |
isError(int code)
Is condition # code being treated as an error. |
boolean |
isWarning(int code)
Is condition # code
being treated as a warning. |
static IRIFactory |
jenaImplementation()
For use by Jena team only. |
void |
mintingViolation(boolean isError,
boolean isWarning)
The factory will treat violations of statements from the specifications concerning creating new IRIs it is enforcing as errors, or warnings, or not at all. |
void |
securityViolation(boolean isError,
boolean isWarning)
The factory will treat violations of statements from the specifications flagged as security issues, including weak heuristical suggestions, it is enforcing as errors, or warnings, or not at all. |
static IRIFactory |
semanticWebImplementation()
This factory is a conservative implementation appropriate for Semantic Web applications. |
void |
setEncoding(String enc)
Sets the character encoding to use for decoding and encoding to percent escape sequences. |
static void |
setIriImplementation(IRIFactory iriF)
This globally sets the iriImplementation() ; use with care. |
void |
setIsError(int code,
boolean set)
Set condition # code
to be treated as an error; or clear it as an error condition. |
void |
setIsWarning(int code,
boolean set)
Set condition # code
to be treated as a warning;
or clear it as a warning condition. |
static void |
setJenaImplementation(IRIFactory jf)
This globally sets the jenaImplementation() ; use with care. |
void |
setQueryCharacterRestrictions(boolean restrict)
The character constraints on the query component of an IRI are weaker than on other components. |
void |
setSameSchemeRelativeReferences(String scheme)
Allows scheme:relative-path as a relative reference against a base URI from the same scheme. |
static void |
setSemanticWebImplementation(IRIFactory sw)
This globally sets the semanticWebImplementation() ; use with care. |
static void |
setUriImplementation(IRIFactory uriF)
This globally sets the uriImplementation() ; use with care. |
void |
shouldViolation(boolean isError,
boolean isWarning)
The factory will treat violations of "SHOULD" force statements from the specifications it is enforcing as errors, or warnings, or not at all. |
static IRIFactory |
uriImplementation()
This factory implements RFC 3986 Uniform Resource Identifier (URI): Generic Syntax . |
void |
useSchemeSpecificRules(String scheme,
boolean asErrors)
Use the rules for a given scheme, or use all known scheme specific rules. |
void |
useSpecificationIRI(boolean asErrors)
The factory will check for violations of RFC 3987, IRI. |
void |
useSpecificationRDF(boolean asErrors)
The factory will check for violations of RDF URI Reference. |
void |
useSpecificationURI(boolean asErrors)
The factory will check for violations of RFC 3986, URI. |
void |
useSpecificationXLink(boolean asErrors)
The factory will check for violations of XLink locator: href value. |
void |
useSpecificationXMLSchema(boolean asErrors)
The factory will check for violations of XML Schema anyURI. |
void |
useSpecificationXMLSystemID(boolean asErrors)
The factory will check for violations of XML constraints on system ID. |
Methods inherited from class com.hp.hpl.jena.iri.impl.IRIFactoryImpl |
---|
create, create, getProhibited, getRequired, getScheme, noScheme |
Methods inherited from class com.hp.hpl.jena.iri.impl.AbsIRIFactoryImpl |
---|
construct, construct |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.hp.hpl.jena.iri.IRIFactoryI |
---|
construct, construct, create, create |
Constructor Detail |
---|
public IRIFactory()
useSpecificationIRI(boolean)
,
useSpecificationRDF(boolean)
,
useSpecificationURI(boolean)
,
useSpecificationXMLSchema(boolean)
,
useSpecificationXLink(boolean)
or
useSpecificationXMLSystemID(boolean)
.
public IRIFactory(IRIFactory template)
Method Detail |
---|
public static IRIFactory iriImplementation()
public static IRIFactory uriImplementation()
public static IRIFactory semanticWebImplementation()
ViolationCodes.NON_INITIAL_DOT_SEGMENT
is treated as an error (since
any IRI with this condition cannot be
serialized in RDF/XML, which resolves
all IRIs against the inscope base, and hence uses
the remove_dot_segments algorithm).
This should ensure that any IRI that is
not in error, can be used
interoperably in RDF/XML, SPARQL, N3
and N-Triple.
public static IRIFactory jenaImplementation()
public void setSameSchemeRelativeReferences(String scheme)
Sets the behaviour of the relative reference resolution algorithm to be the backward compatible mode described in the URI specification:
-- A non-strict parser may ignore a scheme in the reference -- if it is identical to the base URI's scheme. -- if ((not strict) and (R.scheme == Base.scheme)) then undefine(R.scheme); endif;
setSameSchemeRelativeReferences
in class IRIFactoryImpl
scheme
- The scheme to enable this behaviour for, or "*" for all schemespublic void allowUnwiseCharacters()
Systems accepting IRIs MAY also deal with the printable characters in US-ASCII that are not allowed in URIs, namely "<", ">", '"', space, "{", "}", "|", "\", "^", and "`", in step 2 above. If these characters are found but are not converted, then the conversion SHOULD fail. Please note that the number sign ("#"), the percent sign ("%"), and the square bracket characters ("[", "]") are not part of the above list
This method is intended to be used
with factories that are using the IRI
specification.
The unwise characters are treated as minting
warnings after this method is called.
This method does not override any setting
from useSpecificationXMLSchema(boolean)
concerning ViolationCodes.DOUBLE_WHITESPACE
.
public void setQueryCharacterRestrictions(boolean restrict)
restrict=false
removes (all?) restrictions, calling this method
with restrict=true
adds restrictions,
specifically disallowing private use codepoints.
restrict
- True to make the query component checking stricter, false to make the query component checking more lenientpublic void setEncoding(String enc) throws UnsupportedEncodingException
Using this method does not conform with the IRI specification, or XLink, XML system identifiers, RDF URI references, or XML Schema anyURI. This method is conformant with the URI specification.
setEncoding
in class IRIFactoryImpl
IllegalStateException
- If this factory has already been used to create an IRI.
UnsupportedEncodingException
- If the encoding is not supported.public IRI create(String scheme, String userInfo, String host, int port, String path, String query, String fragment)
scheme
- userInfo
- host
- Will be encoded using punycode, if necessary.port
- May be 0 for no port.path
- May not be nullquery
- fragment
-
setEncoding(String)
public IRI create(String scheme, String authority, String path, String query, String fragment)
create(String, String, String, int, String, String, String)
when the authority is a DNS hostname, even if
both the user information and the port are unspecified;
this version uses percent escaping as opposed to punycode
for the authority. DNS hostnames should be
escaped in punycode (if necessary).
scheme
- authority
- Will be percent escaped if necessarypath
- May not be nullquery
- fragment
-
setEncoding(String)
public IRI construct(String scheme, String userInfo, String host, int port, String path, String query, String fragment) throws IRIException
scheme
- userInfo
- host
- Will be encoded using punycode, if necessary.port
- May be 0 for no port.path
- May not be nullquery
- fragment
-
IRIException
setEncoding(String)
public IRI construct(String scheme, String authority, String path, String query, String fragment) throws IRIException
construct(String, String, String, int, String, String, String)
when the authority is a DNS hostname, even if
both the user information and the port are unspecified;
this version uses percent escaping as opposed to punycode
for the authority. DNS hostnames should be
escaped in punycode (if necessary).
scheme
- authority
- Will be percent escaped if necessarypath
- May not be nullquery
- fragment
-
IRIException
- If the resulting IRI
has unfixable errors, e.g. non-ascii chars in the scheme namesetEncoding(String)
public boolean isError(int code)
code
being treated as an error.
code
- A condition code from ViolationCodes
.public boolean isWarning(int code)
code
being treated as a warning.
code
- A condition code from ViolationCodes
.public void setIsError(int code, boolean set)
code
to be treated as an error; or clear it as an error condition.
Care must be taken when using this to clear the error behaviour
on a code documented
in ViolationCodes
as having SHOULD force:
see the documentation at shouldViolation(boolean, boolean)
,
concerning the necessary steps.
Using this method with code
being one that is documented as having MUST force
will result in non-conformant behaviour.
code
- A condition code from ViolationCodes
.set
- True to set this as an error, false to clear.
IllegalStateException
- If this factory has already been used to create an IRI.public void setIsWarning(int code, boolean set)
code
to be treated as a warning;
or clear it as a warning condition.
Setting a code to be a warning, clears it from
being an error. Care must be taken
if the code
is one that is documented
in ViolationCodes
has having SHOULD or MUST
force, since ignoring any resulting warning may
result in a nonconformant application.
code
- A condition code from ViolationCodes
.set
- True to set this as a warning, false to clear.
IllegalStateException
- If this factory has already been used to create an IRI.public boolean ignoring(int code)
code
being ignored.
code
- A condition code from ViolationCodes
.public void useSpecificationURI(boolean asErrors)
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSpecificationIRI(boolean asErrors)
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSpecificationRDF(boolean asErrors)
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSpecificationXMLSchema(boolean asErrors)
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSpecificationXMLSystemID(boolean asErrors)
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSpecificationXLink(boolean asErrors)
href
value.
asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public void shouldViolation(boolean isError, boolean isWarning)
From RFC 2119
the full implications must be understood and carefully weighed before
calling this method with isError=false
.
Thus, you MUST have read and understood
the specifications that you are configuring the factory
to use, before switching SHOULDs to warnings or to be
ignored.
An easier path, is to understand a specific error code,
with SHOULD force,
and then use setIsError(int, boolean)
, and
setIsWarning(int, boolean)
to modify the behaviour
of that error code only. The prerequisite for modifiying a
single error code to be ignored, or to be treated as a warning
is to have understood the full implications of that condition,
rather than of all the SHOULD force statements within all
the specifications being used.
isError
- If true, treat violations of SHOULDs as errors.isWarning
- If true, treat violations of SHOULDs as warnings.
IllegalArgumentException
- if isError && isWarning
.
IllegalStateException
- If this factory has already been used to create an IRI.public void securityViolation(boolean isError, boolean isWarning)
isError
- If true, treat security violations as errors.isWarning
- If true, treat security violations as warnings.
IllegalArgumentException
- if isError && isWarning
.public void dnsViolation(boolean isError, boolean isWarning)
isError
- If true, treat DNS violations as errors.isWarning
- If true, treat DNS violations as warnings.
IllegalArgumentException
- if isError && isWarning
.public void mintingViolation(boolean isError, boolean isWarning)
An implementation should accept uppercase letters as equivalent to lowercase in scheme names (e.g., allow "HTTP" as well as "http") for the sake of robustness but should only produce lowercase scheme names for consistency.
isError
- If true, treat violations of minting force statements as errors.isWarning
- If true, treat violations of minting force statements as warnings.
IllegalArgumentException
- if isError && isWarning
.
IllegalStateException
- If this factory has already been used to create an IRI.public void useSchemeSpecificRules(String scheme, boolean asErrors)
The currently implemented schemes are:
Scheme | Level of implementation |
---|---|
none |
useSchemeSpecificRules
in class IRIFactoryImpl
scheme
- The scheme name or "*" to use all implemented scheme specific rules.asErrors
- If true, then violations are treated as errors; if false violations are treated as warnings.
IllegalStateException
- If this factory has already been used to create an IRI.public static void setJenaImplementation(IRIFactory jf)
jenaImplementation()
; use with care.
This should be used before any calls to jenaImplementation()
;
it does not modify the factory returned by any previous calls, but subsequent
calls to jenaImplementation()
will return the new value.
jf
- The new Jena Factorypublic static void setIriImplementation(IRIFactory iriF)
iriImplementation()
; use with care.
This should be used before any calls to iriImplementation()
;
it does not modify the factory returned by any previous calls, but subsequent
calls to iriImplementation()
will return the new value.
iriF
- The new IRI Factorypublic static void setUriImplementation(IRIFactory uriF)
uriImplementation()
; use with care.
This should be used before any calls to uriImplementation()
;
it does not modify the factory returned by any previous calls, but subsequent
calls to uriImplementation()
will return the new value.
uriF
- The new URI Factorypublic static void setSemanticWebImplementation(IRIFactory sw)
semanticWebImplementation()
; use with care.
This should be used before any calls to semanticWebImplementation()
;
it does not modify the factory returned by any previous calls, but subsequent
calls to semanticWebImplementation()
will return the new value.
sw
- The new IRI Factory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |