[Jsxe-cvs] SF.net SVN: jsxe: [1241] branches/jsxe2/src/net/sourceforge/jsxe/dom/ XMLDocument.java
Status: Inactive
Brought to you by:
ian_lewis
|
From: <ian...@us...> - 2006-09-06 19:34:36
|
Revision: 1241
http://svn.sourceforge.net/jsxe/?rev=1241&view=rev
Author: ian_lewis
Date: 2006-09-06 12:34:32 -0700 (Wed, 06 Sep 2006)
Log Message:
-----------
Removed getDocumentCopy() method
Modified Paths:
--------------
branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java
Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java
===================================================================
--- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 19:29:43 UTC (rev 1240)
+++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 19:34:32 UTC (rev 1241)
@@ -447,6 +447,112 @@
//}}}
+ //{{{ Text Methods
+
+ //{{{ getText()
+ /**
+ * Gets the text at a specified location in the document. This method
+ * method should be used sparingly as changes to the properties of this
+ * document or the tree structure could change the location of text
+ * within the document.
+ * @param start the starting index of the text to retrieve
+ * @param length the length of the text needed
+ * @return the text requested
+ */
+ public String getText(int start, int length) throws IOException {
+
+ if (start < 0 || length < 0 || start + length > m_content.getLength()) {
+ throw new ArrayIndexOutOfBoundsException(start + ":" + length);
+ }
+
+ //if the document is well formed we go by the DOM
+ //if it's not we go by the source text.
+ syncContentWithDOM();
+ return m_content.getText(start,length);
+ }//}}}
+
+ //{{{ getSegment()
+ /**
+ * Gets the text at a specified location in the document. This method
+ * method should be used sparingly as changes to the properties of this
+ * document or the tree structure could change the location of text
+ * within the document.
+ * @param start the starting index of the text to retrieve
+ * @param length the length of the text needed
+ * @return the segment representing the text requested
+ */
+ public Segment getSegment(int start, int length) throws IOException {
+
+ if (start < 0 || length < 0 || start + length > m_content.getLength()) {
+ throw new ArrayIndexOutOfBoundsException(start + ":" + length);
+ }
+
+ //if the document is well formed we go by the DOM
+ //if it's not we go by the source text.
+ if (m_parsedMode) {
+ syncContentWithDOM();
+ }
+ Segment seg = new Segment();
+ m_content.getText(start, length, seg);
+ return seg;
+ }//}}}
+
+ //{{{ getLength()
+ /**
+ * Gets the total number of characters in the document.
+ * @return the length of the document
+ */
+ public int getLength() {
+
+ syncContentWithDOM();
+
+ return m_content.getLength();
+ }//}}}
+
+ //{{{ insertText()
+ /**
+ * Inserts text into the document at the specified location
+ * @param offset the character offset where the text should be inserted
+ * @param text the text to insert
+ * @throws IOException if the text could not be inserted
+ */
+ public void insertText(int offset, String text) throws IOException {
+ if (text.length() > 0) {
+ Log.log(Log.DEBUG, this, "insertText: "+offset+": "+text);
+ syncContentWithDOM();
+ m_content.insert(offset, text);
+ m_parsedMode = false;
+ m_adapterNode = null;
+ if (!getFlag(UNDO_IN_PROGRESS)) {
+ addUndoableEdit(new InsertEdit(this, offset, text));
+ }
+ fireStructureChanged(null);
+ }
+ }//}}}
+
+ //{{{ removeText()
+ /**
+ * Removes text at the specifed character offset.
+ * @param offset the character offset where the text is removed form
+ * @param length the length of the text segment to remove
+ * @throws IOException if the text could not be removed
+ */
+ public void removeText(int offset, int length) throws IOException {
+ if (length > 0) {
+ String text = getText(offset,length);
+ Log.log(Log.DEBUG, this, "removeText: "+offset+": "+text);
+ m_content.remove(offset, length);
+ m_parsedMode = false;
+ m_adapterNode = null;
+ if (!getFlag(UNDO_IN_PROGRESS)) {
+ addUndoableEdit(new RemoveEdit(this, offset, text));
+ }
+ fireStructureChanged(null);
+ }
+ }//}}}
+
+ //}}}
+
//{{{ checkWellFormedness()
/**
* Checks the wellformedness of the document and throws appropriate
@@ -468,29 +574,6 @@
return m_parsedMode;
}//}}}
- //{{{ getDocumentCopy()
- /**
- * Gets a copy of the underlying Document object.
- * @return a deep copy of the underlying document object
- */
- public Document getDocumentCopy() {
- //makes a deep copy of the document node
- try {
- checkWellFormedness();
- } catch (SAXParseException e) {
- } catch (SAXException e) {
- } catch (ParserConfigurationException e) {
- } catch (IOException e) {
- //If an error occurs then we're in trouble
- jsXe.exiterror(this, e, 1);
- }
- if (m_document != null) {
- return (Document)m_document.cloneNode(true);
- } else {
- return null;
- }
- }//}}}
-
//{{{ getDocType()
/**
* Returns the document type node for this XMLDocument or null if there is
@@ -608,66 +691,6 @@
return newAdapterNode(parent, newNode);
}//}}}
- //{{{ getText()
- /**
- * Gets the text at a specified location in the document. This method
- * method should be used sparingly as changes to the properties of this
- * document or the tree structure could change the location of text
- * within the document.
- * @param start the starting index of the text to retrieve
- * @param length the length of the text needed
- * @return the text requested
- */
- public String getText(int start, int length) throws IOException {
-
- if (start < 0 || length < 0 || start + length > m_content.getLength()) {
- throw new ArrayIndexOutOfBoundsException(start + ":" + length);
- }
-
- //if the document is well formed we go by the DOM
- //if it's not we go by the source text.
- syncContentWithDOM();
- return m_content.getText(start,length);
- }//}}}
-
- //{{{ getSegment()
- /**
- * Gets the text at a specified location in the document. This method
- * method should be used sparingly as changes to the properties of this
- * document or the tree structure could change the location of text
- * within the document.
- * @param start the starting index of the text to retrieve
- * @param length the length of the text needed
- * @return the segment representing the text requested
- */
- public Segment getSegment(int start, int length) throws IOException {
-
- if (start < 0 || length < 0 || start + length > m_content.getLength()) {
- throw new ArrayIndexOutOfBoundsException(start + ":" + length);
- }
-
- //if the document is well formed we go by the DOM
- //if it's not we go by the source text.
- if (m_parsedMode) {
- syncContentWithDOM();
- }
- Segment seg = new Segment();
- m_content.getText(start, length, seg);
- return seg;
- }//}}}
-
- //{{{ getLength()
- /**
- * Gets the total number of characters in the document.
- * @return the length of the document
- */
- public int getLength() {
-
- syncContentWithDOM();
-
- return m_content.getLength();
- }//}}}
-
//{{{ getErrors()
/**
* Gets a list of non-fatal errors that were encountered
@@ -923,48 +946,6 @@
return m_uri;
}//}}}
- //{{{ insertText()
- /**
- * Inserts text into the document at the specified location
- * @param offset the character offset where the text should be inserted
- * @param text the text to insert
- * @throws IOException if the text could not be inserted
- */
- public void insertText(int offset, String text) throws IOException {
- if (text.length() > 0) {
- Log.log(Log.DEBUG, this, "insertText: "+offset+": "+text);
- syncContentWithDOM();
- m_content.insert(offset, text);
- m_parsedMode = false;
- m_adapterNode = null;
- if (!getFlag(UNDO_IN_PROGRESS)) {
- addUndoableEdit(new InsertEdit(this, offset, text));
- }
- fireStructureChanged(null);
- }
- }//}}}
-
- //{{{ removeText()
- /**
- * Removes text at the specifed character offset.
- * @param offset the character offset where the text is removed form
- * @param length the length of the text segment to remove
- * @throws IOException if the text could not be removed
- */
- public void removeText(int offset, int length) throws IOException {
- if (length > 0) {
- String text = getText(offset,length);
- Log.log(Log.DEBUG, this, "removeText: "+offset+": "+text);
- m_content.remove(offset, length);
- m_parsedMode = false;
- m_adapterNode = null;
- if (!getFlag(UNDO_IN_PROGRESS)) {
- addUndoableEdit(new RemoveEdit(this, offset, text));
- }
- fireStructureChanged(null);
- }
- }//}}}
-
//{{{ setModel()
/**
* Sets up the XMLDocument given a Reader. The existing content is
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|