org.attoparser.markup
Class MarkupParsingConfiguration.PrologParsingConfiguration

Object
  extended by org.attoparser.markup.MarkupParsingConfiguration.PrologParsingConfiguration
All Implemented Interfaces:
Serializable
Enclosing class:
MarkupParsingConfiguration

public static class MarkupParsingConfiguration.PrologParsingConfiguration
extends Object
implements Serializable

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 tt>getPrologPresence(), getXmlDeclarationPresence() and getDoctypePresence() are considered valid. See validateConfiguration() for details.

Since:
1.1
Author:
Daniel Fernández
See Also:
Serialized Form

Constructor Summary
protected MarkupParsingConfiguration.PrologParsingConfiguration()
           Creates a MarkupParsingConfiguration.PrologParsingConfiguration instance with a default configuration.
 
Method Summary
 MarkupParsingConfiguration.PrologParsingConfiguration clone()
           
 MarkupParsingConfiguration.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.
 MarkupParsingConfiguration.PrologPresence getPrologPresence()
           This flag indicates the level of presence desired for the prolog in the document, in case isValidateProlog() has been set to true.
 MarkupParsingConfiguration.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.
 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(MarkupParsingConfiguration.PrologPresence doctypePresence)
           
 void setPrologPresence(MarkupParsingConfiguration.PrologPresence prologPresence)
           
 void setRequireDoctypeKeywordsUpperCase(boolean requireDoctypeKeywordsUpperCase)
           
 void setValidateProlog(boolean validateProlog)
           
 void setXmlDeclarationPresence(MarkupParsingConfiguration.PrologPresence xmlDeclarationPresence)
           
 void validateConfiguration()
           Checks that the combination of values in the getPrologPresence(), getXmlDeclarationPresence() and getDoctypePresence() parameters makes sense.
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MarkupParsingConfiguration.PrologParsingConfiguration

protected MarkupParsingConfiguration.PrologParsingConfiguration()

Creates a MarkupParsingConfiguration.PrologParsingConfiguration 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 to MarkupParsingConfiguration.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 MarkupParsingConfiguration.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(MarkupParsingConfiguration.PrologPresence prologPresence)

getXmlDeclarationPresence

public MarkupParsingConfiguration.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(MarkupParsingConfiguration.PrologPresence xmlDeclarationPresence)

getDoctypePresence

public MarkupParsingConfiguration.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(MarkupParsingConfiguration.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() and getDoctypePresence() parameters makes sense.

  1. If getPrologPresence() is MarkupParsingConfiguration.PrologPresence.FORBIDDEN, then getXmlDeclarationPresence() and getDoctypePresence() must be MarkupParsingConfiguration.PrologPresence.FORBIDDEN too.
  2. Else if at least one of getXmlDeclarationPresence() or getDoctypePresence() is MarkupParsingConfiguration.PrologPresence.REQUIRED, the configuration is considered valid.
  3. Else if getPrologPresence() is MarkupParsingConfiguration.PrologPresence.ALLOWED, the configuration is considered valid as long as not both getXmlDeclarationPresence() and getDoctypePresence() are MarkupParsingConfiguration.PrologPresence.FORBIDDEN.

Throws:
IllegalArgumentException - if the combination of values is not correct.

clone

public MarkupParsingConfiguration.PrologParsingConfiguration clone()
                                                            throws CloneNotSupportedException
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


Copyright © 2013 The ATTOPARSER team. All Rights Reserved.