Class ParseConfiguration.PrologParseConfiguration
- java.lang.Object
-
- org.attoparser.config.ParseConfiguration.PrologParseConfiguration
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
- Enclosing class:
- ParseConfiguration
public static class ParseConfiguration.PrologParseConfiguration extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable
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()
andgetDoctypePresence()
are considered valid. SeevalidateConfiguration()
for details.- Since:
- 2.0.0
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private ParseConfiguration.PrologPresence
doctypePresence
private ParseConfiguration.PrologPresence
prologPresence
private boolean
requireDoctypeKeywordsUpperCase
private static long
serialVersionUID
private boolean
validateProlog
private ParseConfiguration.PrologPresence
xmlDeclarationPresence
-
Constructor Summary
Constructors Modifier Constructor Description protected
PrologParseConfiguration()
Creates aParseConfiguration.PrologParseConfiguration
instance with a default configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ParseConfiguration.PrologParseConfiguration
clone()
ParseConfiguration.PrologPresence
getDoctypePresence()
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.ParseConfiguration.PrologPresence
getPrologPresence()
This flag indicates the level of presence desired for the prolog in the document, in caseisValidateProlog()
has been set to true.ParseConfiguration.PrologPresence
getXmlDeclarationPresence()
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.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).boolean
isValidateProlog()
This flag indicates whether the document's prolog should be validated at all or not.void
setDoctypePresence(ParseConfiguration.PrologPresence doctypePresence)
void
setPrologPresence(ParseConfiguration.PrologPresence prologPresence)
void
setRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase)
void
setValidateProlog(boolean validateProlog)
void
setXmlDeclarationPresence(ParseConfiguration.PrologPresence xmlDeclarationPresence)
void
validateConfiguration()
Checks that the combination of values in thegetPrologPresence()
,getXmlDeclarationPresence()
andgetDoctypePresence()
parameters makes sense.
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
validateProlog
private boolean validateProlog
-
prologPresence
private ParseConfiguration.PrologPresence prologPresence
-
xmlDeclarationPresence
private ParseConfiguration.PrologPresence xmlDeclarationPresence
-
doctypePresence
private ParseConfiguration.PrologPresence doctypePresence
-
requireDoctypeKeywordsUpperCase
private boolean requireDoctypeKeywordsUpperCase
-
-
Constructor Detail
-
PrologParseConfiguration
protected PrologParseConfiguration()
Creates a
ParseConfiguration.PrologParseConfiguration
instance with a default configuration.Default values are:
-
-
Method Detail
-
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
public ParseConfiguration.PrologPresence 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
public void setPrologPresence(ParseConfiguration.PrologPresence prologPresence)
-
getXmlDeclarationPresence
public ParseConfiguration.PrologPresence 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
public void setXmlDeclarationPresence(ParseConfiguration.PrologPresence xmlDeclarationPresence)
-
getDoctypePresence
public ParseConfiguration.PrologPresence 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
public void setDoctypePresence(ParseConfiguration.PrologPresence doctypePresence)
-
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.FORBIDDEN
too. - 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:
java.lang.IllegalArgumentException
- if the combination of values is not correct.
- If
-
clone
public ParseConfiguration.PrologParseConfiguration clone() throws java.lang.CloneNotSupportedException
- Overrides:
clone
in classjava.lang.Object
- Throws:
java.lang.CloneNotSupportedException
-
-