Class URLFragment
java.lang.Object
org.w3c.epubcheck.util.url.URLFragment
Represents a URL fragment, after parsing micro-syntaxes.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanexists()getId()Returns the element ID represented by this fragment if this is an ID-based fragment, or the empty string otherwise.Returns the scheme represented by this fragment if this is an scheme-based fragment, or the empty string otherwise.inthashCode()booleanisEmpty()booleanbooleanisValid()static URLFragmentparse(io.mola.galimatias.URL url) Parse the fragment of the given URL, according to the default rules (XML MIME type), seeparse(URL, String).static URLFragmentParse the fragment of the given URL, according to the rules defined for the given MIME type.toString()
-
Field Details
-
NONE
Represents a non-existent fragment, for whichexists()returnsfalse -
fragment
-
scheme
-
id
-
isMediaFragment
private final boolean isMediaFragment -
isValid
private final boolean isValid
-
-
Constructor Details
-
URLFragment
-
-
Method Details
-
getId
Returns the element ID represented by this fragment if this is an ID-based fragment, or the empty string otherwise.- Returns:
- an element ID or the empty string.
-
getScheme
Returns the scheme represented by this fragment if this is an scheme-based fragment, or the empty string otherwise.- Returns:
- a scheme name or the empty string.
-
exists
public boolean exists()- Returns:
trueiff the URL from which this was parsed had a fragment.
-
isEmpty
public boolean isEmpty()- Returns:
trueiff this fragment is the empty string or represents a non-existent fragment.
-
isValid
public boolean isValid()- Returns:
trueiff this fragment is valid according to its target MIME type.
-
isMediaFragment
public boolean isMediaFragment()- Returns:
trueiff this fragment is a media fragment.
-
toString
-
hashCode
-
equals
-
parse
Parse the fragment of the given URL, according to the rules defined for the given MIME type. If the URL has no fragment, returnsNONEHTML types "application/xhtml+xml" and "text/html"
The following fragment patterns are supported:
- regular ID-based fragments (`#name`)
- scheme-based fragments (`#name(something)`)
- media fragments (`#name=value`, with name one of `t|xywh|track|id|xyn|xyr`
- fragment directives (`#name:~:text=range`)
Note that this deviates from the HTML standard in the following way:
- HTML does not define specific logic for scheme-based or media fragments, which must be treated like any other IDs. However, EPUB makes use of them notably for EPUB CFI or region-based navigation.
- Fragment directives (as used in text fragments), is an incubating standard (at the time of writing) and is likely not well supported by reading system, but its syntax is specific enough to lower the risk of false-positive.
SVG type "image/svg+xml"
The following fragment patterns are supported:
- shorthand bare form names (
#name). Validation checks that the name is an XML NCName. - SVG view specification (
#svgView(…)). Validation currently does not look into the parenthesis content. - basic media fragments (
#xywh=0,0,50,50). Validation checks the syntax of spatial and temporal dimensions.
Other type
Any other type is assumed to be XML. The following fragment patterns are supported:
- shorthand bare form names (
#name). Validation checks that the name is an XML NCName. - scheme-based fragments (`#name(something)`). No validation of the scheme name or syntax.
- Parameters:
url- a URLmimetype- the MIME type of the URL target- Returns:
- a parsed fragment (cannot be
null)
-
parse
Parse the fragment of the given URL, according to the default rules (XML MIME type), seeparse(URL, String).- Parameters:
url- a URL- Returns:
- a parsed fragment (cannot be
null)
-