JDOM
2.0.5

org.jdom2
Class DocType

java.lang.Object
  extended by org.jdom2.Content
      extended by org.jdom2.DocType
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, NamespaceAware
Direct Known Subclasses:
LocatedDocType

public class DocType
extends Content

An XML DOCTYPE declaration. Method allow the user to get and set the root element name, public id, system id and internal subset.

Author:
Brett McLaughlin, Jason Hunter
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jdom2.Content
Content.CType
 
Field Summary
protected  java.lang.String elementName
          The element being constrained
protected  java.lang.String internalSubset
          The internal subset of the DOCTYPE
protected  java.lang.String publicID
          The public ID of the DOCTYPE
protected  java.lang.String systemID
          The system ID of the DOCTYPE
 
Fields inherited from class org.jdom2.Content
ctype, parent
 
Constructor Summary
protected DocType()
          Default, no-args constructor for implementations to use if needed.
  DocType(java.lang.String elementName)
          This will create the DocType with the specified element name
  DocType(java.lang.String elementName, java.lang.String systemID)
          This will create the DocType with the specified element name and reference to an external DTD.
  DocType(java.lang.String elementName, java.lang.String publicID, java.lang.String systemID)
          This will create the DocType with the specified element name and a reference to an external DTD.
 
Method Summary
 DocType clone()
          Return a deep clone of this instance.
 DocType detach()
          Detaches this child from its parent or does nothing if the child has no parent.
 java.lang.String getElementName()
          This will retrieve the element name being constrained.
 java.lang.String getInternalSubset()
          This returns the data for the internal subset.
 Document getParent()
          Return this child's parent, or null if this child is currently not attached.
 java.lang.String getPublicID()
          This will retrieve the public ID of an externally referenced DTD, or an empty String if none is referenced.
 java.lang.String getSystemID()
          This will retrieve the system ID of an externally referenced DTD, or an empty String if none is referenced.
 java.lang.String getValue()
          Returns the empty string since doctypes don't have an XPath 1.0 string value.
 DocType setElementName(java.lang.String elementName)
          This will set the root element name declared by this DOCTYPE declaration.
 void setInternalSubset(java.lang.String newData)
          This sets the data for the internal subset.
protected  DocType setParent(Parent parent)
          Sets the parent of this Content.
 DocType setPublicID(java.lang.String publicID)
          This will set the public ID of an externally referenced DTD.
 DocType setSystemID(java.lang.String systemID)
          This will set the system ID of an externally referenced DTD.
 java.lang.String toString()
          This returns a String representation of the DocType, suitable for debugging.
 
Methods inherited from class org.jdom2.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParentElement, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

elementName

protected java.lang.String elementName
The element being constrained


publicID

protected java.lang.String publicID
The public ID of the DOCTYPE


systemID

protected java.lang.String systemID
The system ID of the DOCTYPE


internalSubset

protected java.lang.String internalSubset
The internal subset of the DOCTYPE

Constructor Detail

DocType

protected DocType()
Default, no-args constructor for implementations to use if needed.


DocType

public DocType(java.lang.String elementName,
               java.lang.String publicID,
               java.lang.String systemID)
This will create the DocType with the specified element name and a reference to an external DTD.

Parameters:
elementName - String name of element being constrained.
publicID - String public ID of referenced DTD
systemID - String system ID of referenced DTD
Throws:
IllegalDataException - if the given system ID is not a legal system literal or the public ID is not a legal public ID.
IllegalNameException - if the given root element name is not a legal XML element name.

DocType

public DocType(java.lang.String elementName,
               java.lang.String systemID)
This will create the DocType with the specified element name and reference to an external DTD.

Parameters:
elementName - String name of element being constrained.
systemID - String system ID of referenced DTD
Throws:
IllegalDataException - if the given system ID is not a legal system literal.
IllegalNameException - if the given root element name is not a legal XML element name.

DocType

public DocType(java.lang.String elementName)
This will create the DocType with the specified element name

Parameters:
elementName - String name of element being constrained.
Throws:
IllegalNameException - if the given root element name is not a legal XML element name.
Method Detail

getElementName

public java.lang.String getElementName()
This will retrieve the element name being constrained.

Returns:
String - element name for DOCTYPE

setElementName

public DocType setElementName(java.lang.String elementName)
This will set the root element name declared by this DOCTYPE declaration.

Parameters:
elementName - String name of root element being constrained.
Returns:
this DocType instance
Throws:
IllegalNameException - if the given root element name is not a legal XML element name.

getPublicID

public java.lang.String getPublicID()
This will retrieve the public ID of an externally referenced DTD, or an empty String if none is referenced.

Returns:
String - public ID of referenced DTD.

setPublicID

public DocType setPublicID(java.lang.String publicID)
This will set the public ID of an externally referenced DTD.

Parameters:
publicID - id to set
Returns:
DocType DocType this DocType object
Throws:
IllegalDataException - if the given public ID is not a legal public ID.

getSystemID

public java.lang.String getSystemID()
This will retrieve the system ID of an externally referenced DTD, or an empty String if none is referenced.

Returns:
String - system ID of referenced DTD.

setSystemID

public DocType setSystemID(java.lang.String systemID)
This will set the system ID of an externally referenced DTD.

Parameters:
systemID - id to set
Returns:
systemID String system ID of referenced DTD.
Throws:
IllegalDataException - if the given system ID is not a legal system literal.

getValue

public java.lang.String getValue()
Returns the empty string since doctypes don't have an XPath 1.0 string value.

Specified by:
getValue in class Content
Returns:
the empty string

setInternalSubset

public void setInternalSubset(java.lang.String newData)
This sets the data for the internal subset.

Parameters:
newData - data for the internal subset, as a String.

getInternalSubset

public java.lang.String getInternalSubset()
This returns the data for the internal subset.

Returns:
String - the internal subset

toString

public java.lang.String toString()
This returns a String representation of the DocType, suitable for debugging.

Overrides:
toString in class java.lang.Object
Returns:
String - information about the DocType

clone

public DocType clone()
Return a deep clone of this instance. Even if this instance has a parent, the returned clone will not.

All JDOM core classes are Cloneable, and never throw CloneNotSupportedException. Additionally all Cloneable JDOM classes return the correct type of instance from this method and there is no need to cast the result (co-variant return vaue).

Subclasses of this should still call super.clone() in their clone method.

Overrides:
clone in class Content

detach

public DocType detach()
Description copied from class: Content
Detaches this child from its parent or does nothing if the child has no parent.

This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.detach();

Overrides:
detach in class Content
Returns:
this child detached

setParent

protected DocType setParent(Parent parent)
Description copied from class: Content
Sets the parent of this Content. The caller is responsible for removing any pre-existing parentage.

This method can be overridden by particular Content subclasses to return a specific type of Content (co-variant return type). All overriding subclasses must call super.setParent(Parent);

Overrides:
setParent in class Content
Parameters:
parent - new parent element
Returns:
the target element

getParent

public Document getParent()
Description copied from class: Content
Return this child's parent, or null if this child is currently not attached. The parent can be either an Element or a Document.

This method can be overridden by particular Content subclasses to return a specific type of Parent (co-variant return type). All overriding subclasses must call super.getParent();

Overrides:
getParent in class Content
Returns:
this child's parent or null if none

JDOM
2.0.5

Copyright 2013 Jason Hunter, Brett McLaughlin. All Rights Reserved.