Thread: [Jsxe-cvs] SF.net SVN: jsxe: [1240] branches/jsxe2/src/net/sourceforge/jsxe/dom/ XMLDocument.java
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-09-06 19:29:47
|
Revision: 1240 http://svn.sourceforge.net/jsxe/?rev=1240&view=rev Author: ian_lewis Date: 2006-09-06 12:29:43 -0700 (Wed, 06 Sep 2006) Log Message: ----------- Removed commented out code 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:26:53 UTC (rev 1239) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 19:29:43 UTC (rev 1240) @@ -1775,41 +1775,6 @@ //}}} }//}}} - //{{{ ContentManagerOutputStream class - /** - * output stream to write to the content manager when the serialized. Used - * when syncing the source with the current Document. - * Currently not used. - */ - /* - private static class ContentManagerOutputStream extends OutputStream { - - //{{{ ContentManagerOutputStream constructor - public ContentManagerOutputStream(ContentManager content) { - m_m_content = content; - }//}}} - - //{{{ write() - public void write(int b) throws IOException { - byte []barray = { (byte)b }; - m_m_content.insert(m_m_content.getLength(), new String(barray)); - }//}}} - - //{{{ write() - public void write(byte[] b) throws IOException { - m_m_content.insert(m_m_content.getLength(), new String(b)); - }//}}} - - //{{{ write() - public void write(byte[] b, int off, int len) { - m_m_content.insert(m_m_content.getLength(), new String(b, off, len)); - }//}}} - - //{{{ Private members - private ContentManager m_m_content; - //}}} - }*///}}} - //{{{ ContentManagerWriter class /** * Character Stream used to write to the content manager when @@ -1875,134 +1840,6 @@ //}}} }//}}} - //{{{ ContentManagerInputStream class - /** - * Input stream for parsing/reading current text content. Currently not - * used. - */ - /* - private static class ContentManagerInputStream extends InputStream { - - //{{{ ContentManagerInputStream constructor - public ContentManagerInputStream(ContentManager content) { - m_m_content = content; - }//}}} - - //{{{ available() - public int available() { - return m_m_content.getLength() - m_m_index; - }//}}} - - //{{{ read() - public int read() { - if (m_m_index < m_m_content.getLength()) { - char[] text = m_m_content.getText(m_m_index++, 1).toCharArray(); - return (int)text[0]; - } else { - return -1; - } - }//}}} - - //{{{ read() - public int read(byte[] b) throws IOException { - return read(b, 0, b.length); - }//}}} - - //{{{ read() - public int read(byte[]b, int off, int len) { - if (len == 0) { - return 0; - } - - int length = len; - int contentLength = m_m_content.getLength(); - - //TODO this code doesn't support multi-byte characters - //contentLength below is the current number of characters - //what should be used is the total number of bytes in the document - //furthermore m_m_index is an character index into the - //document where it needs to be a byte index - if (m_m_index < contentLength) { - if (m_m_index + length >= contentLength) { - length = contentLength - m_m_index; - } - } else { - length = -1; - } - - //use UTF-8, want to esure it's UTF-8 instead of whatever - //the system default is. We'll only use the specified encoding - //when we write to disk. - if (length != -1) { - try { - - byte[] text = m_m_content.getText(m_m_index, length).getBytes("UTF-8"); - System.arraycopy(text, 0, b, off, length); - m_m_index += length; - - } catch (UnsupportedEncodingException uee) { - //UTF-8 is guaranteed to be supported. - Log.log(Log.ERROR, this, uee); - } - } - - return length; - - }//}}} - - //{{{ skip() - public long skip(long n) { - m_m_index += (int)n; - return n; - }//}}} - - //{{{ Private members - private int m_m_index = 0; - private ContentManager m_m_content; - //}}} - - }*///}}} - - //{{{ XMLDocAdapterListener class - /** - * An AdapterNodeListener is added to each AdapterNode in the tree so that - * the XMLDocument is notified when the structure changes. - */ - /* - private class XMLDocAdapterListener implements AdapterNodeListener { - - // {{{ nodeAdded() - public void nodeAdded(AdapterNode source, AdapterNode added) { - fireStructureChanged(source); - }//}}} - - //{{{ nodeRemoved() - public void nodeRemoved(AdapterNode source, AdapterNode removed) { - fireStructureChanged(source); - }//}}} - - //{{{ localNameChanged() - public void localNameChanged(AdapterNode source) { - fireStructureChanged(source); - }//}}} - - //{{{ namespaceChanged() - public void namespaceChanged(AdapterNode source) { - fireStructureChanged(source); - }//}}} - - //{{{ nodeValueChanged() - public void nodeValueChanged(AdapterNode source) { - fireStructureChanged(source); - }//}}} - - //{{{ attributeChanged() - public void attributeChanged(AdapterNode source, String attr) { - fireStructureChanged(source); - }//}}} - - }//}}}*/ - //{{{ SerializeErrorHandler class /** * Handles when parsing causes changes to the structure of the document. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <ian...@us...> - 2006-09-06 23:23:28
|
Revision: 1243 http://svn.sourceforge.net/jsxe/?rev=1243&view=rev Author: ian_lewis Date: 2006-09-06 16:23:23 -0700 (Wed, 06 Sep 2006) Log Message: ----------- Updated javadoc 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 23:22:12 UTC (rev 1242) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 23:23:23 UTC (rev 1243) @@ -1183,6 +1183,7 @@ /** * The buffer is guaranteed not to change between calls to * {@link #readLock()} and {@link #readUnlock()}. + * @since jsXe XX.XX */ public void readLock() { lock.readLock(); @@ -1192,6 +1193,7 @@ /** * The buffer is guaranteed not to change between calls to * {@link #readLock()} and {@link #readUnlock()}. + * @since jsXe XX.XX */ public void readUnlock() { lock.readUnlock(); @@ -1201,6 +1203,7 @@ /** * Attempting to obtain read lock will block between calls to * {@link #writeLock()} and {@link #writeUnlock()}. + * @since jsXe XX.XX */ public void writeLock() { lock.writeLock(); @@ -1210,6 +1213,7 @@ /** * Attempting to obtain read lock will block between calls to * {@link #writeLock()} and {@link #writeUnlock()}. + * @since jsXe XX.XX */ public void writeUnlock() { lock.writeUnlock(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |