Class XMLDocumentIdentifier
- All Implemented Interfaces:
Formattable
,Serializable
,Comparable<XMLDocumentIdentifier>
The "system" part is required, the "public" part is optional.
Some documentation on its role in XML texts (for entity identification)
is at
http://www.w3.org/TR//#NT-ExternalID
The structure of a "system id" is meant to be an URI.
(The XML standard defines "SystemLiteral" as any character sequence framed
by double or single quotes, not containing this kind of quotes.)
The structure of an "public id" is not defined here.
TRADITIONALLY it is a "Formal Public Identifier" as defined in SGML
(= ISO 8879:1986).
(The XML standard defines "PublicLiteral" similar to SystemLiteral, but with
a restricted character set.)
Empty strings are NOT forbidden by the XML spec. They seem sensible only for a
system identifier in presence of a public identifier. But the XML spec does
not forbid »PUBLIC "" ""
«. This code follows that (akward) specification.
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionXMLDocumentIdentifier
(@Opt String publicId, String systemId) Create an instance with given systemId and publicId.XMLDocumentIdentifier
(@Opt String publicId, URI systemId) Currently for convenience only, executes "systemId.toString()".XMLDocumentIdentifier
(@Opt String publicId, URL systemId) Currently for convenience only, executes "systemId.toString()".XMLDocumentIdentifier
(String systemId) Create an instance with given systemId and apublicId==null
-
Method Summary
Modifier and TypeMethodDescriptionint
Auxiliary comparison method, as needed for "sorted Sets" etc.protected boolean
Compares this to another.boolean
format()
CreateFormat
representation needed for XML headers.final String
Evidentfinal String
Evidentint
hashCode()
Is defined according to equality.static boolean
isValidPublicId
(@Opt String publicId) Check if string is a valid public id.static boolean
isValidSystemId
(String systemId) Check if string is a valid system id.toString()
Create string representation needed for XML headers conformant to the standard.
-
Field Details
-
systemLiteral
-
publicLiteral
-
publicIdAlphabet
Contains all characters allowed in public IDs. See definition "PubidChar" in the XML standard
-
-
Constructor Details
-
XMLDocumentIdentifier
Create an instance with given systemId and apublicId==null
- Throws:
IllegalArgumentException
- iff systemId is null.
-
XMLDocumentIdentifier
Create an instance with given systemId and publicId.- Throws:
IllegalArgumentException
- iff systemId is null.
-
XMLDocumentIdentifier
Currently for convenience only, executes "systemId.toString()". -
XMLDocumentIdentifier
Currently for convenience only, executes "systemId.toString()".
-
-
Method Details
-
getPublicId
Evident -
getSystemId
Evident -
equals
- Overrides:
equals
in classObject
- Returns:
- true iff
- the argument "o" is an XMLDocumentIdentifier,
- at least one publicId is present, and both are equal, or
- or no publicId is present and the systemIds are equal.
-
IMPORTANT: Other implementations of the XML specification may come to other
conclusions; therefore it is possibly not portable to hold a document which
is meant to be identical (same public id) at two different file locations
(system ids).
Public Ids need not to be injectiv: A DOI, a URI and another URI can point to the same journal article and thus to the same disk file (system id).
-
equals
Compares this to another. @see #equals(Object). -
hashCode
public int hashCode()Is defined according to equality. @see #equals(Object). -
toString
Create string representation needed for XML headers conformant to the standard. This format is rather awkward:
(a) if there is NO public Id, then print "SYSTEM <systemId>
"
(b) if there IS a public Id, print "PUBLIC <publicId> <systemId>
"
cf. http://www.w3.org/TR/xml11/#NT-ExternalID ATTENTION: both ids may contain EITHER single quote OR double quote, but not both. That will result in an IllegalArgumentException. -
format
CreateFormat
representation needed for XML headers.- Specified by:
format
in interfaceFormattable
- Returns:
- a format that represents this object in a pretty-printable way
-
compareTo
Auxiliary comparison method, as needed for "sorted Sets" etc. Respectsequals(Object)
. First compare the publicIds and, if equal, then the systemIds. An object withpublicId==null
is smaller than one withpublicId!=null
.- Specified by:
compareTo
in interfaceComparable<XMLDocumentIdentifier>
-
isValidSystemId
Check if string is a valid system id. Checks only that not both, single and double quote, are contained. This is not done automatically, e.g. on construction. -
isValidPublicId
Check if string is a valid public id. This is not done automatically, e.g. on construction. Checks only whether all contained characters are allowed. null passes the test.
-