|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sf.vex.dom.Document
Represents an XML document.
Constructor Summary | |
Document(RootElement rootElement)
Class constructor. |
Method Summary | |
void |
addDocumentListener(DocumentListener listener)
Adds a document listener to the list of listeners to be notified of document changes. |
boolean |
canInsertFragment(int offset,
DocumentFragment fragment)
Returns true if the given document fragment can be inserted at the given offset. |
boolean |
canInsertText(int offset)
Returns true if text can be inserted at the given offset. |
Position |
createPosition(int offset)
Creates a Position object at the given character offset. |
javax.swing.undo.UndoableEdit |
delete(int startOffset,
int endOffset)
Deletes a portion of the document. |
Element |
findCommonElement(int offset1,
int offset2)
Finds the lowest element that contains both of the given offsets. |
char |
getCharacterAt(int offset)
Returns the character at the given offset. |
Element |
getElementAt(int offset)
Returns the element at the given offset. |
java.lang.String |
getEncoding()
Returns the encoding used for this document, or null if no encoding has been declared. |
DocumentFragment |
getFragment(int startOffset,
int endOffset)
Create a DocumentFragment representing the given
range of offsets. |
int |
getLength()
Returns the length of the document in characters, including the null characters that delimit each element. |
java.lang.String[] |
getNodeNames(int startOffset,
int endOffset)
Returns an array of element names and Validator.PCDATA representing the content between the given offsets. |
java.lang.String |
getPublicID()
Returns the public ID of the document type. |
java.lang.String |
getRawText(int startOffset,
int endOffset)
Returns the text between the two given offsets. |
Element |
getRootElement()
Returns the root element of this document. |
java.lang.String |
getSystemID()
Returns the system ID of the document type. |
java.lang.String |
getText(int startOffset,
int endOffset)
Returns the text between the two given offsets. |
Validator |
getValidator()
Returns the validator used to validate the document, or null if a validator has not been set. |
javax.swing.undo.UndoableEdit |
insertElement(int offset,
Element element)
Inserts an element at the given position. |
javax.swing.undo.UndoableEdit |
insertFragment(int offset,
DocumentFragment fragment)
Inserts a document fragment at the given position. |
javax.swing.undo.UndoableEdit |
insertText(int offset,
java.lang.String text)
Inserts text at the given position. |
void |
removeDocumentListener(DocumentListener listener)
Removes a document listener from the list of listeners so that it is no longer notified of document changes. |
void |
setPublicID(java.lang.String publicID)
Sets the public ID for the document's document type. |
void |
setSystemID(java.lang.String systemID)
Sets the system ID for the document's document type. |
void |
setValidator(Validator validator)
Sets the validator to use for this document. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Document(RootElement rootElement)
rootElement
- root element of the document. The
document property of this RootElement is set by this
constructor.Method Detail |
public void addDocumentListener(DocumentListener listener)
listener
- DocumentListener
to add.public boolean canInsertFragment(int offset, DocumentFragment fragment)
offset
- offset where the insertion is to occurfragment
- fragment to be insertedpublic boolean canInsertText(int offset)
offset
- offset where the insertion is to occurpublic Position createPosition(int offset)
Position
object at the given character offset.
offset
- initial character offset of the positionpublic javax.swing.undo.UndoableEdit delete(int startOffset, int endOffset) throws DocumentValidationException
startOffset
- start of the range to deleteendOffset
- end of the range to delete
DocumentValidationException
- if the change would result
in an invalid document.public Element findCommonElement(int offset1, int offset2)
offset1
- the first offsetoffset2
- the second offsetpublic char getCharacterAt(int offset)
public Element getElementAt(int offset)
public java.lang.String getEncoding()
public DocumentFragment getFragment(int startOffset, int endOffset)
DocumentFragment
representing the given
range of offsets.
public int getLength()
public java.lang.String[] getNodeNames(int startOffset, int endOffset)
startOffset
- the offset at which the sequence beginsendOffset
- the offset at which the sequence endspublic java.lang.String getPublicID()
public java.lang.String getRawText(int startOffset, int endOffset)
startOffset
- character offset of the start of the textendOffset
- character offset of the end of the textpublic Element getRootElement()
public java.lang.String getSystemID()
public java.lang.String getText(int startOffset, int endOffset)
startOffset
- character offset of the start of the textendOffset
- character offset of the end of the textpublic Validator getValidator()
public javax.swing.undo.UndoableEdit insertElement(int offset, Element element) throws DocumentValidationException
offset
- character offset at which the element is to be inserted.
Must be greater or equal to 1 and less than the current length of the
document, i.e. it must be within the range of the root element.element
- element to insert
DocumentValidationException
- if the change would result
in an invalid document.public javax.swing.undo.UndoableEdit insertFragment(int offset, DocumentFragment fragment) throws DocumentValidationException
offset
- character offset at which the element is to be inserted.
Must be greater or equal to 1 and less than the current length of the
document, i.e. it must be within the range of the root element.fragment
- fragment to insert
DocumentValidationException
- if the change would result
in an invalid document.public javax.swing.undo.UndoableEdit insertText(int offset, java.lang.String text) throws DocumentValidationException
offset
- character offset at which the text is to be inserted.
Must be greater or equal to 1 and less than the current length of the
document, i.e. it must be within the range of the root element.text
- text to insert
DocumentValidationException
- if the change would result
in an invalid document.public void removeDocumentListener(DocumentListener listener)
listener
- DocumentListener
to remove.public void setPublicID(java.lang.String publicID)
publicID
- New value for the public ID.public void setSystemID(java.lang.String systemID)
systemID
- New value for the system ID.public void setValidator(Validator validator)
validator
- Validator to use for this document.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |