Class DocType
- java.lang.Object
-
- org.jdom.Content
-
- org.jdom.DocType
-
- All Implemented Interfaces:
Serializable,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.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.jdom.Content
Content.CType
-
-
Field Summary
Fields Modifier and Type Field Description protected StringelementNameThe element being constrainedprotected StringinternalSubsetThe internal subset of the DOCTYPEprotected StringpublicIDThe public ID of the DOCTYPEprotected StringsystemIDThe system ID of the DOCTYPE
-
Constructor Summary
Constructors Modifier Constructor Description protectedDocType()Default, no-args constructor for implementations to use if needed.DocType(String elementName)This will create theDocTypewith the specified element nameDocType(String elementName, String systemID)This will create theDocTypewith the specified element name and reference to an external DTD.DocType(String elementName, String publicID, String systemID)This will create theDocTypewith the specified element name and a reference to an external DTD.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DocTypeclone()Return a deep clone of this instance.DocTypedetach()Detaches this child from its parent or does nothing if the child has no parent.StringgetElementName()This will retrieve the element name being constrained.StringgetInternalSubset()This returns the data for the internal subset.DocumentgetParent()Return this child's parent, or null if this child is currently not attached.StringgetPublicID()This will retrieve the public ID of an externally referenced DTD, or an emptyStringif none is referenced.StringgetSystemID()This will retrieve the system ID of an externally referenced DTD, or an emptyStringif none is referenced.StringgetValue()Returns the empty string since doctypes don't have an XPath 1.0 string value.DocTypesetElementName(String elementName)This will set the root element name declared by this DOCTYPE declaration.voidsetInternalSubset(String newData)This sets the data for the internal subset.protected DocTypesetParent(Parent parent)Sets the parent of this Content.DocTypesetPublicID(String publicID)This will set the public ID of an externally referenced DTD.DocTypesetSystemID(String systemID)This will set the system ID of an externally referenced DTD.StringtoString()This returns aStringrepresentation of theDocType, suitable for debugging.-
Methods inherited from class org.jdom.Content
equals, getCType, getDocument, getNamespacesInherited, getNamespacesInScope, getNamespacesIntroduced, getParentElement, hashCode
-
-
-
-
Constructor Detail
-
DocType
protected DocType()
Default, no-args constructor for implementations to use if needed.
-
DocType
public DocType(String elementName, String publicID, String systemID)
This will create theDocTypewith the specified element name and a reference to an external DTD.- Parameters:
elementName-Stringname of element being constrained.publicID-Stringpublic ID of referenced DTDsystemID-Stringsystem 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(String elementName, String systemID)
This will create theDocTypewith the specified element name and reference to an external DTD.- Parameters:
elementName-Stringname of element being constrained.systemID-Stringsystem 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(String elementName)
This will create theDocTypewith the specified element name- Parameters:
elementName-Stringname of element being constrained.- Throws:
IllegalNameException- if the given root element name is not a legal XML element name.
-
-
Method Detail
-
getElementName
public String getElementName()
This will retrieve the element name being constrained.- Returns:
String- element name for DOCTYPE
-
setElementName
public DocType setElementName(String elementName)
This will set the root element name declared by this DOCTYPE declaration.- Parameters:
elementName-Stringname of root element being constrained.- Returns:
- this
DocTypeinstance - Throws:
IllegalNameException- if the given root element name is not a legal XML element name.
-
getPublicID
public String getPublicID()
This will retrieve the public ID of an externally referenced DTD, or an emptyStringif none is referenced.- Returns:
String- public ID of referenced DTD.
-
setPublicID
public DocType setPublicID(String publicID)
This will set the public ID of an externally referenced DTD.- Parameters:
publicID- id to set- Returns:
- DocType
DocTypethis DocType object - Throws:
IllegalDataException- if the given public ID is not a legal public ID.
-
getSystemID
public String getSystemID()
This will retrieve the system ID of an externally referenced DTD, or an emptyStringif none is referenced.- Returns:
String- system ID of referenced DTD.
-
setSystemID
public DocType setSystemID(String systemID)
This will set the system ID of an externally referenced DTD.- Parameters:
systemID- id to set- Returns:
- systemID
Stringsystem ID of referenced DTD. - Throws:
IllegalDataException- if the given system ID is not a legal system literal.
-
getValue
public String getValue()
Returns the empty string since doctypes don't have an XPath 1.0 string value.
-
setInternalSubset
public void setInternalSubset(String newData)
This sets the data for the internal subset.- Parameters:
newData- data for the internal subset, as aString.
-
getInternalSubset
public String getInternalSubset()
This returns the data for the internal subset.- Returns:
String- the internal subset
-
toString
public String toString()
This returns aStringrepresentation of theDocType, suitable for debugging.
-
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.
-
detach
public DocType detach()
Description copied from class:ContentDetaches 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();
-
setParent
protected DocType setParent(Parent parent)
Description copied from class:ContentSets 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);
-
getParent
public Document getParent()
Description copied from class:ContentReturn this child's parent, or null if this child is currently not attached. The parent can be either anElementor aDocument.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();
-
-