Class ParseConfiguration.PrologParseConfiguration
- All Implemented Interfaces:
Serializable,Cloneable
- Enclosing class:
ParseConfiguration
Class encapsulating the configuration parameters used for parsing and validating the "prolog" section of a markup document. The prolog is the section of an XML/HTML document containing the XML declaration and the DOCTYPE clause (if these exist).
If validateProlog is set to false, all other parameters should be ignored.
If validateProlog is true, then the rest of the parameters will be considered.
Not all combinations of values of the getPrologPresence(),
getXmlDeclarationPresence() and getDoctypePresence()
are considered valid. See validateConfiguration() for details.
- Since:
- 2.0.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate static final longprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates aParseConfiguration.PrologParseConfigurationinstance with a default configuration. -
Method Summary
Modifier and TypeMethodDescriptionclone()This flag indicates the level of presence desired for the DOCTYPE clause (a part of the prolog) in the document, in caseisValidateProlog()has been set to true.This flag indicates the level of presence desired for the prolog in the document, in caseisValidateProlog()has been set to true.This flag indicates the level of presence desired for the XML Declaration (a part of the prolog) in the document, in caseisValidateProlog()has been set to true.booleanThis configuration parameter allows to check that all keywords in a DOCTYPE clause ('DOCTYPE', 'SYSTEM', 'PUBLIC') are in upper-case as required by the XML specification (and not by the HTML5 one, for example).booleanThis flag indicates whether the document's prolog should be validated at all or not.voidsetDoctypePresence(ParseConfiguration.PrologPresence doctypePresence) voidsetPrologPresence(ParseConfiguration.PrologPresence prologPresence) voidsetRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase) voidsetValidateProlog(boolean validateProlog) voidsetXmlDeclarationPresence(ParseConfiguration.PrologPresence xmlDeclarationPresence) voidChecks that the combination of values in thegetPrologPresence(),getXmlDeclarationPresence()andgetDoctypePresence()parameters makes sense.
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
validateProlog
private boolean validateProlog -
prologPresence
-
xmlDeclarationPresence
-
doctypePresence
-
requireDoctypeKeywordsUpperCase
private boolean requireDoctypeKeywordsUpperCase
-
-
Constructor Details
-
PrologParseConfiguration
protected PrologParseConfiguration()Creates a
ParseConfiguration.PrologParseConfigurationinstance with a default configuration.Default values are:
-
-
Method Details
-
isValidateProlog
public boolean isValidateProlog()This flag indicates whether the document's prolog should be validated at all or not.
If not validated, prolog-specific structures (XML Declaration and DOCTYPE) will be allowed to appear anywhere in the document. All other configuration paramters in this object will be ignored.
If validated, prolog-specific structures will only be allowed to appear (under the conditions established in this object) at the beginning of the document, before the element root. Or if
getPrologPresence()is set toParseConfiguration.PrologPresence.FORBIDDEN, it will be validated that such structures do not appear at all.Also, if validated and a DOCTYPE is present, it will be checked that there is only one root element in the document and its name matches the root element name in the DOCTYPE clause.
Default value is false.
- Returns:
- whether prolog is to be validated or not.
-
setValidateProlog
public void setValidateProlog(boolean validateProlog) -
getPrologPresence
This flag indicates the level of presence desired for the prolog in the document, in case
isValidateProlog()has been set to true.- Returns:
- the level of presence desired for the prolog.
-
setPrologPresence
-
getXmlDeclarationPresence
This flag indicates the level of presence desired for the XML Declaration (a part of the prolog) in the document, in case
isValidateProlog()has been set to true.- Returns:
- the level of presence desired for the XML Declaration.
-
setXmlDeclarationPresence
-
getDoctypePresence
This flag indicates the level of presence desired for the DOCTYPE clause (a part of the prolog) in the document, in case
isValidateProlog()has been set to true.- Returns:
- the level of presence desired for the DOCTYPE clause.
-
setDoctypePresence
-
isRequireDoctypeKeywordsUpperCase
public boolean isRequireDoctypeKeywordsUpperCase()This configuration parameter allows to check that all keywords in a DOCTYPE clause ('DOCTYPE', 'SYSTEM', 'PUBLIC') are in upper-case as required by the XML specification (and not by the HTML5 one, for example).
Default value is true, but it will apply only if
isValidateProlog()is true.- Returns:
- whether keywords in the DOCTYPE clause will be forced to be in upper-case.
-
setRequireDoctypeKeywordsUpperCase
public void setRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase) -
validateConfiguration
public void validateConfiguration()Checks that the combination of values in the
getPrologPresence(),getXmlDeclarationPresence()andgetDoctypePresence()parameters makes sense.- If
getPrologPresence()isParseConfiguration.PrologPresence.FORBIDDEN, thengetXmlDeclarationPresence()andgetDoctypePresence()must beParseConfiguration.PrologPresence.FORBIDDENtoo. - Else if at least one of
getXmlDeclarationPresence()orgetDoctypePresence()isParseConfiguration.PrologPresence.REQUIRED, the configuration is considered valid. - Else if
getPrologPresence()isParseConfiguration.PrologPresence.ALLOWED, the configuration is considered valid as long as not bothgetXmlDeclarationPresence()andgetDoctypePresence()areParseConfiguration.PrologPresence.FORBIDDEN.
- Throws:
IllegalArgumentException- if the combination of values is not correct.
- If
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-