Thread: [Jsxe-cvs] SF.net SVN: jsxe: [893] branches/jsxe2/src/net/sourceforge/jsxe
Status: Inactive
Brought to you by:
ian_lewis
From: <ian...@us...> - 2006-06-02 03:27:05
|
Revision: 893 Author: ian_lewis Date: 2006-06-01 20:26:57 -0700 (Thu, 01 Jun 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=893&view=rev Log Message: ----------- Updated the listener event model to make use of the new document listeners which now support insert and remove updates. Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentListener.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-01 04:21:50 UTC (rev 892) +++ branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-06-02 03:26:57 UTC (rev 893) @@ -481,6 +481,35 @@ super.fireStructureChanged(location); }//}}} + //{{{ DocumentBufferResolver class + /** + * <p>The DocumentBufferResolver class is the default class that is used + * for resolving external entities in documents that jsXe is editing. + * It implements caching external entities to the local disk and finding + * the cached version later for faster retrieval.</p> + * <p>The external entities are searched for in locations relative to the + * opened document or if they are URLs then they are retrieved from the + * network resource.</p> + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @since jsXe 0.5 pre1 + */ + public class DocumentBufferResolver implements EntityResolver { + + //{{{ resolveEntity() + public InputSource resolveEntity(String publicId, String systemId) throws SAXException { + try { + if (isUntitled()) { + return CatalogManager.resolve(null, publicId, systemId); + } else { + return CatalogManager.resolve(getFile().toURI().toString(), publicId, systemId); + } + } catch (Exception e) { + throw new SAXException(e); + } + }//}}} + + }//}}} + //{{{ Private members //{{{ setDirty() @@ -830,56 +859,6 @@ } }//}}} - //{{{ DocumentBufferResolver class - - private class DocumentBufferResolver implements EntityResolver { - - //{{{ resolveEntity() - - public InputSource resolveEntity(String publicId, String systemId) throws SAXException { - - // String entity = systemId; - // InputSource source = null; - // - // if (m_file != null) { - // - // try { - // String filePathURI = m_file.toURL().toExternalForm(); - // int index = filePathURI.lastIndexOf("/")+1; - // if (index != -1) { - // filePathURI = filePathURI.substring(0, index); - // } - // - // index = entity.lastIndexOf("/")+1; - // if (index != -1) { - // entity = entity.substring(index); - // } - // - // //create the path to the entity relative to the document - // filePathURI += entity; - // source = new InputSource((new URL(filePathURI)).openStream()); - // - // } catch (MalformedURLException e) { - // //Do nothing and try to open this entity normally - // } catch (IOException e) { - // //Probobly file not found. - // //Do nothing and try to open this entity normally - // } - // } - // return source; - try { - if (isUntitled()) { - return CatalogManager.resolve(null, publicId, systemId); - } else { - return CatalogManager.resolve(getFile().toURI().toString(), publicId, systemId); - } - } catch (Exception e) { - throw new SAXException(e); - } - }//}}} - - }//}}} - private String m_name; private File m_file; private ArrayList m_listeners = new ArrayList(); Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-06-01 04:21:50 UTC (rev 892) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-06-02 03:26:57 UTC (rev 893) @@ -36,6 +36,7 @@ import net.sourceforge.jsxe.util.Log; import net.sourceforge.jsxe.util.MiscUtilities; import net.sourceforge.jsxe.dom.completion.*; +import net.sourceforge.jsxe.dom.event.*; //}}} //{{{ DOM classes @@ -81,6 +82,9 @@ * @version $Id$ * @see AdapterNode */ + /* + TODO: XMLDocument should extend AdapterNode + */ public class XMLDocument { //{{{ XMLDocument defined properties @@ -271,27 +275,27 @@ }//}}} //{{{ 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; - } - }//}}} + // /** + // * 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() /** @@ -407,7 +411,7 @@ */ public AdapterNode newAdapterNode(AdapterNode parent, String name, String value, short type) { Node newNode = null; - + //TODO: creating adapter nodes needs to be reworked. //Only handle text and element nodes right now. switch(type) { case Node.ELEMENT_NODE: @@ -721,6 +725,7 @@ String value = null; try { LSSerializer serializer = getSerializer(); + //TODO: this call to writeToString() should change value = serializer.writeToString(node.getNode()); } catch (DOMException e) {} return value; @@ -771,7 +776,7 @@ m_adapterNode = null; //may have some algorithm to determine the modified node(s) in the //future - fireStructureChanged(null); + fireInsert(offset, text); } }//}}} @@ -785,12 +790,13 @@ public void removeText(int offset, int length) throws IOException { if (length > 0) { syncContentWithDOM(); + String text = getText(offset, length); m_content.remove(offset, length); m_parsedMode = false; m_adapterNode = null; //may have some algorithm to determine the modified node(s) in the //future - fireStructureChanged(null); + fireRemove(offset, text); } }//}}} @@ -993,6 +999,7 @@ * in the event that specs that will alter how the document is serialized or * parsed are changed. * @param location the location of the change. null if unknown + * @deprecated structureCHange */ protected void fireStructureChanged(AdapterNode location) { ListIterator iterator = listeners.listIterator(); @@ -1003,6 +1010,38 @@ m_syncedWithContent = false; }//}}} + //{{{ fireInsert() + /** + * Called when the a text insert into the document has been made. This + * can occur when structural changes have been made as well, such as a + * node insertion. + * @param offset the offset into the document where the text was inserted + * @param text the text that was inserted + */ + protected void fireInsert(int offset, String text) { + ListIterator iterator = listeners.listIterator(); + while (iterator.hasNext()) { + XMLDocumentListener listener = (XMLDocumentListener)iterator.next(); + listener.insertUpdate(new XMLDocumentInsertEvent(this, offset, text)); + } + }//}}} + + //{{{ fireRemove() + /** + * Called when text is removed from the document. This + * can occur when structural changes have been made as well, such as a + * node removal. + * @param offset the offset into the document where the text was inserted + * @param text the text that was inserted + */ + protected void fireRemove(int offset, String text) { + ListIterator iterator = listeners.listIterator(); + while (iterator.hasNext()) { + XMLDocumentListener listener = (XMLDocumentListener)iterator.next(); + listener.removeUpdate(new XMLDocumentRemoveEvent(this, offset, text)); + } + }//}}} + //{{{ getCompletionInfoMappings() /** * Gets the namespace uri to CompletionInfo Mappings for this document. @@ -1047,6 +1086,9 @@ * Write the DOM to the content manager given the current serialization and * formatting options. */ + /* + TODO: update serialization + */ private void syncContentWithDOM() { if (m_parsedMode) { if (!m_syncedWithContent) { @@ -1128,6 +1170,9 @@ * m_adapterNode and m_parsedMode must be updated. * @since jsXe 0.4 pre1 */ + /* + * TODO: Update parsing + */ public void parseDocument() throws SAXParseException, SAXException, ParserConfigurationException, IOException { Log.log(Log.MESSAGE, this, (m_uri != null ? "Parsing Document: "+m_uri.toString() : "Parsing Document")); Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentListener.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentListener.java 2006-06-01 04:21:50 UTC (rev 892) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocumentListener.java 2006-06-02 03:26:57 UTC (rev 893) @@ -24,16 +24,20 @@ package net.sourceforge.jsxe.dom; + /** * XMLDocumentListener is used to notify objects of a change to the XMLDocument. + * These changes can occur via changes to the text or document structure. Both + * are maintained by the XMLDocument class. + * * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id$ + * @since jsXe 0.5 pre1 * @see XMLDocument */ public interface XMLDocumentListener { //{{{ propertyChanged() - /** * Called when a property associated with the XMLDocument has changed. * @param source The source XMLDocument @@ -43,7 +47,6 @@ public void propertyChanged(XMLDocument source, String key, String oldValue);//}}} //{{{ structureChanged() - /** * Called when the structure of the XMLDocument has changed. * @param source The source XMLDocument @@ -51,7 +54,34 @@ * If a node was removed then this is the parent of the * node that was removed. This could be null if the location * is unknown. + * @deprecated insertUpdate and removeUpdate will be used instead. */ public void structureChanged(XMLDocument source, AdapterNode location);//}}} + //{{{ insertUpdate() + /** + * Called when text is inserted into the XML document. This will called + * whenever text is inserted into the document via a normal text update or + * a change to the document structure, such as a node insertion. + * @param event the document update event. + */ + public void insertUpdate(XMLDocumentEvent event);//}}} + + //{{{ removeUpdate() + /** + * Called when text is removed from the document. This will be whenever + * text is removed directly or when a change to the document structure is + * made such as a node is removal. + * @param event the document update event. + */ + public void removeUpdate(XMLDocumentEvent event);//}}} + + //{{{ changeUpdate() + /** + * Called when a part of the XMLDocument is changed in some way. This may + * occur with changes to properties or attributes within the document + * structure. + * @param event the document update event. + */ + public void changeUpdate(XMLDocumentEvent event);//}}} } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-07 23:54:29
|
Revision: 1000 Author: ian_lewis Date: 2006-07-07 16:54:05 -0700 (Fri, 07 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1000&view=rev Log Message: ----------- updated the new document model and gave it it's own package Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java Removed Paths: ------------- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLElement.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLException.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNodeListener.java Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLElement.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLElement.java 2006-07-07 20:59:23 UTC (rev 999) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLElement.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -1,57 +0,0 @@ -/* -XMLElement.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -//{{{ Imports -import org.w3c.dom.*; -import org.w3c.dom.events.*; -//}}} - -/** - * The XMLElement class represents an element in the XMLDocument tree. It allows - * attibute modifications which will translate to text modifications in the - * XMLDocument. - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @see XMLDocument - * @since jsXe 0.5 pre2 - */ -public class XMLElement extends XMLNode { - - //{{{ XMLElement constructor - /** - * Creates a new XMLElement - * @param element the element node that this node wraps. - */ - XMLElement(Element element) { - super(element); - }//}}} - - //{{{ getNodeType() - public int getNodeType() { - return Node.ELEMENT_NODE; - }//}}} - -} Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLException.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLException.java 2006-07-07 20:59:23 UTC (rev 999) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLException.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -1,122 +0,0 @@ -/* -XMLException.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -/** - * XMLExceptions represent any type of exception that may occur when editing - * an XML document. This can include when the document would cause the - * structure to be non-well-formed though a method call. Operations on - * the structure of the XMLDocument should always result in a well-formed - * document. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @see XMLDocument - * @see XMLNode - * @since jsXe 0.5 pre2 - */ -public class XMLException extends RuntimeException { - - //{{{ Exception types - /** - * Indicates a Node is inserted somewhere it doesn't belong. - */ - public static final short HIERARCHY_REQUEST_ERR = 1; - - /** - * If index or size is negative, or greater than the allowed value. - */ - public static final short INDEX_SIZE_ERR = 2; - /** - * If an invalid or illegal character is specified, such as in an XML name. - */ - public static final short INVALID_CHARACTER_ERR = 3; - /** - * If an attempt is made to modify the type of the underlying object. - */ - public static final short INVALID_MODIFICATION_ERR = 4; - /** - * If an attempt is made to use an object that is not, or is no longer, usable. - */ - public static final short INVALID_STATE_ERR = 5; - /** - * If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces. - */ - public static final short NAMESPACE_ERR = 6; - /** - * If data is specified for a Node which does not support data. - */ - public static final short NO_DATA_ALLOWED_ERR = 7; - /** - * If an attempt is made to modify an object where modifications are not allowed. - */ - public static final short NO_MODIFICATION_ALLOWED_ERR = 8; - /** - * If an attempt is made to reference a Node in a context where it does not exist. - */ - //public static final short NOT_FOUND_ERR = 9; - /** - * If an invalid or illegal string is specified. - */ - //public static final short SYNTAX_ERR = 10; - /** - * If the type of an object is incompatible with the expected type of the parameter associated to the object. - */ - public static final short TYPE_MISMATCH_ERR = 11; - /** - * If a call to a method such as insertBefore or removeChild would make the - * Node invalid with respect to "partial validity", this exception would be - * raised and the operation would not be done. - */ - //public static final short VALIDATION_ERR = 12; - /** - * If a Node is used in a different document than the one that created it (that doesn't support it). - */ - public static final short WRONG_DOCUMENT_ERR = 13; - //}}} - - //{{{ XMLException constructor - /** - * Creates a new XMLException with the given message. - * @param type The exception type - * @param message The message - */ - public XMLException(short type, String message) { - super(message); - m_type = type; - }//}}} - - //{{{ getType() - /** - * Returts the type of the exception - */ - public short getType() { - return m_type; - }//}}} - - //{{{ Private Members - private short m_type; - //}}} -} Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNode.java 2006-07-07 20:59:23 UTC (rev 999) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNode.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -1,102 +0,0 @@ -/* -XMLNode.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -//{{{ imports - -//{{{ jsXe classes -import net.sourceforge.jsxe.jsXe; -import net.sourceforge.jsxe.util.Log; -import net.sourceforge.jsxe.dom.completion.*; -//}}} - -//{{{ DOM classes -import org.w3c.dom.*; -import org.w3c.dom.events.*; -//}}} - -//}}} - -/** - * <p>The XMLNode class is meant to represent an XMLNode in a XMLDocument tree - * but also as a section of text within that document tree. It - * allows tree modifications only, however these modifications - * will correspond to text modifications to the XMLDocument. Direct text - * modifications are only allowed at the XMLDocument level.</p> - * - * <p>It implements a subset of the support offered by standard w3c DOM - * interfaces.</p> - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @see XMLDocument - * @since jsXe 0.5 pre2 - */ -public abstract class XMLNode { - - private static final String USER_DATA_KEY = "net.sourceforge.jsxe.dom.XMLNode"; - - //{{{ Private members - - /** - * The w3c Node that this node wraps. It must support the EventTarget - * interface in org.w3c.dom.events - */ - private Node m_domNode; - - //}}} - - //{{{ XMLNode constructor - XMLNode(Node node) { - m_domNode = node; - }//}}} - - //{{{ addEventListener() - public void addEventListener(java.lang.String type, EventListener listener, boolean useCapture) { - ((EventTarget)m_domNode).addEventListener(type, listener, useCapture); - }//}}} - - //{{{ removeEventListener() - public void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture) { - ((EventTarget)m_domNode).removeEventListener(type, listener, useCapture); - }//}}} - - //{{{ appendNode() - public XMLNode appendChild(XMLNode newChild) { - - m_domNode.appendChild(newChild.getNode()); - - return newChild; - }//}}} - - //{{{ Protected Members - - //{{{ getNode() - protected Node getNode() { - return m_domNode; - }//}}} - - //}}} -} Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNodeListener.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNodeListener.java 2006-07-07 20:59:23 UTC (rev 999) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNodeListener.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -1,39 +0,0 @@ -/* -XMLNodeListener.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2006 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -/** - * XMLNodeListener is used to notify objects of a change to a specific XMLNode. - * These changes can occur via changes to the text or document structure. Both - * are maintained by the XMLDocument class. - * - * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id$ - * @since jsXe 0.5 pre2 - * @see XMLDocument - */ -public interface XMLNodeListener { - -} Added: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -0,0 +1,502 @@ +/* +XMLDocument.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2; + +//{{{ imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.util.MiscUtilities; +//}}} + +//{{{ DOM classes +import org.w3c.dom.*; +import org.w3c.dom.events.*; +//}}} + +//{{{ Java base classes +import java.io.IOException; +import java.io.Writer; +import java.util.ArrayList; +import java.util.HashMap; +//}}} + +//{{{ Swing classes +import javax.swing.text.*; +import javax.swing.event.DocumentListener; +import javax.swing.event.UndoableEditListener; +//}}} + +//}}} + +/** + * The XMLDocument class represents an XML document as a tree structure + * that has nodes, implemented as AdapterNodes, as well as text. Methods are + * provided to allow user objects to interact with the XML document as text + * or as a tree structure seamlessly. + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id: XMLDocument.java 999 2006-07-07 20:59:23Z ian_lewis $ + * @see AdapterNode + */ +public class XMLDocument /* implements javax.swing.text.Document */ { + + //{{{ XMLDocument constructor + XMLDocument() { + + }//}}} + + //{{{ swing.text.Document methods + + //{{{ addDocumentListener + /** + * Registers a change listener with the XMLDocument + * @param listener the listener to register with this document + */ + public void addDocumentListener(DocumentListener listener) { + if (listener != null) { + m_docListeners.add(listener); + } + }//}}} + + //{{{ addUndoableEditListener() + + public void addUndoableEditListener(UndoableEditListener listener) { + if (listener != null) { + m_undoListeners.add(listener); + } + }//}}} + + //{{{ createPosition() + + public Position createPosition(int offs) throws BadLocationException { + if (offs < 0 || offs > m_content.getLength()) { + //TODO: fix error messages + throw new BadLocationException("createPosition(): Bad offset", offs); + } + + final int offset = offs; + return new Position() { + public int getOffset() { + return offset; + } + }; + }//}}} + + //{{{ getDefaultRootElement() + + public javax.swing.text.Element getDefaultRootElement() { + //TODO: return root element + return null; + }//}}} + + //{{{ getEndPosition() + + public Position getEndPosition() { + try { + return createPosition(getLength()-1); + } catch (BadLocationException e) { + //Guaranteed to be good. + return null; + } + }//}}} + + //{{{ getLength() + /** + * Gets the total number of characters in the document. + * @return the length of the document + */ + public int getLength() { + return m_content.getLength(); + }//}}} + + //{{{ getProperty() + + public Object getProperty(Object key) { + return m_properties.get(key); + }//}}} + + //{{{ getRootElements() + + public javax.swing.text.Element[] getRootElements() { + //TODO: return root nodes + return null; + }//}}} + + //{{{ getStartPosition() + + public Position getStartPosition() { + try { + return createPosition(0); + } catch (BadLocationException e) { + //Guaranteed to be good. + return null; + } + }//}}} + + //{{{ getText() + public String getText(int offset, int length) throws BadLocationException { + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + //TODO: fix error messages + throw new BadLocationException("insertString(): Bad Offset", offset); + } + + return m_content.getText(offset,length); + }//}}} + + //{{{ getText() + + public void getText(int offset, int length, Segment txt) throws BadLocationException { + + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + //TODO: fix error messages + throw new BadLocationException("insertString(): Bad Offset", offset); + } + + m_content.getText(offset, length, txt); + }//}}} + + //{{{ insertString() + /** + * <p>Inserts a string of content. This will cause a DocumentEvent of type + * DocumentEvent.EventType.INSERT to be sent to the registered + * DocumentListers, unless an exception is thrown. The DocumentEvent will + * be delivered by calling the insertUpdate method on the + * DocumentListener. The offset and length of the generated DocumentEvent + * will indicate what change was actually made to the Document.</p> + * + * <p>If the Document structure changed as result of the insertion, the + * details of what Elements were inserted and removed in response to the + * change will also be contained in the generated DocumentEvent. It is up + * to the implementation of a Document to decide how the structure should + * change in response to an insertion.</p> + * + * <p>If the Document supports undo/redo, an UndoableEditEvent will also be + * generated.</p> + * @param offset the offset into the document to insert the content >= 0. + * All positions that track change at or after the given + * location will move. + * @param str the string to insert + * @param a the attributes to associate with the inserted content. + * This attribute is ignored by XMLDocuments. + */ + public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { + if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { + //TODO: fix error messages + throw new BadLocationException("insertString(): Bad Offset", offset); + } + + m_content.insert(offset, str); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + }//}}} + + //{{{ putProperty() + + public void putProperty(Object key, Object value) { + m_properties.put(key, value); + }//}}} + + //{{{ remove() + + public void remove(int offs, int len) throws BadLocationException { + if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { + //TODO: fix error messages + throw new BadLocationException("insertString(): Bad Offset", offs); + } + + m_content.remove(offs, len); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + }//}}} + + //{{{ removeDocumentListener() + + public void removeDocumentListener(DocumentListener listener) { + if (listener != null) { + m_docListeners.remove(listener); + } + }//}}} + + //{{{ removeUndoableEditListener() + + public void removeUndoableEditListener(UndoableEditListener listener) { + if (listener != null) { + m_undoListeners.remove(listener); + } + }//}}} + + //{{{ render() + + public void render(Runnable r) { + //TODO: implement concurrency support. + }//}}} + + //}}} + + //{{{ Private members + + //{{{ ContentManager class + /** + * Text content manager based off of jEdit's ContentManager class. + */ + private static class ContentManager { + + // {{{ ContentManager constructor + public ContentManager() { + text = new char[1024]; + } //}}} + + //{{{ getLength() + + public final int getLength() { + return length; + } //}}} + + //{{{ getCharAt() + public char getCharAt(int start) { + if(start >= gapStart) { + return text[start + gapEnd - gapStart]; + } else { + if(start + 1 <= gapStart) { + return text[start]; + } else { + if (gapStart - start > 0) { + return text[start]; + } else { + return text[gapEnd + start - 1]; + } + } + } + }//}}} + + //{{{ getText() + public String getText(int start, int len) { + if(start >= gapStart) { + return new String(text,start + gapEnd - gapStart,len); + } else { + if(start + len <= gapStart) { + return new String(text,start,len); + } else { + return new String(text,start,gapStart - start).concat(new String(text,gapEnd,start + len - gapStart)); + } + } + } //}}} + + //{{{ getText() + public void getText(int start, int len, Segment seg) { + if(start >= gapStart) { + seg.array = text; + seg.offset = start + gapEnd - gapStart; + seg.count = len; + } else { + if(start + len <= gapStart) { + seg.array = text; + seg.offset = start; + seg.count = len; + } else { + seg.array = new char[len]; + + // copy text before gap + System.arraycopy(text,start,seg.array,0,gapStart - start); + + // copy text after gap + System.arraycopy(text,gapEnd,seg.array,gapStart - start, + len + start - gapStart); + + seg.offset = 0; + seg.count = len; + } + } + } //}}} + + //{{{ insert() + public void insert(int start, String str) { + int len = str.length(); + moveGapStart(start); + + if(gapEnd - gapStart < len) { + ensureCapacity(length + len + 1024); + moveGapEnd(start + len + 1024); + } + + str.getChars(0,len,text,start); + gapStart += len; + length += len; + } //}}} + + //{{{ insert() + public void insert(int start, Segment seg) { + moveGapStart(start); + + if(gapEnd - gapStart < seg.count) { + ensureCapacity(length + seg.count + 1024); + moveGapEnd(start + seg.count + 1024); + } + + System.arraycopy(seg.array,seg.offset,text,start,seg.count); + gapStart += seg.count; + length += seg.count; + } //}}} + + //{{{ _setContent() + public void _setContent(char[] text, int length) { + this.text = text; + this.gapStart = this.gapEnd = 0; + this.length = length; + } //}}} + + //{{{ remove() + public void remove(int start, int len) { + moveGapStart(start); + gapEnd += len; + length -= len; + } //}}} + + //{{{ Private members + private char[] text; + private int gapStart = 0; + private int gapEnd = 0; + private int length = 0; + + private void moveGapStart(int newStart) {//{{{ + int newEnd = gapEnd + (newStart - gapStart); + + if(newStart == gapStart) { + // nothing to do + } else { + if(newStart > gapStart) { + System.arraycopy(text,gapEnd,text,gapStart, newStart - gapStart); + } else { + if(newStart < gapStart) { + System.arraycopy(text,newStart,text,newEnd, gapStart - newStart); + } + } + } + + gapStart = newStart; + gapEnd = newEnd; + } //}}} + + private void moveGapEnd(int newEnd) {//{{{ + System.arraycopy(text,gapEnd,text,newEnd,length - gapStart); + gapEnd = newEnd; + } //}}} + + private void ensureCapacity(int capacity) {//{{{ + + if(capacity >= text.length) { + char[] textN = new char[capacity * 2]; + System.arraycopy(text,0,textN,0,length + (gapEnd - gapStart)); + text = textN; + } + + } //}}} + + //}}} + }//}}} + + //{{{ ContentManagerWriter class + /** + * Character Stream used to write to the content manager when + * serialized. Used when syncing the source with the current Document. + */ + private static class ContentManagerWriter extends Writer { + + //{{{ ContentManagerWriter constructor + public ContentManagerWriter(ContentManager content) { + m_m_content = content; + }//}}} + + //{{{ write() + public void write(char[] cbuf) throws IOException { + if (m_m_closed) { + throw new IOException("ContentManagerWriter is closed"); + } + m_m_content.insert(m_m_content.getLength(), new String(cbuf)); + }//}}} + + //{{{ write() + public void write(char[] cbuf, int off, int len) throws IOException { + if (m_m_closed) { + throw new IOException("ContentManagerWriter is closed"); + } + m_m_content.insert(m_m_content.getLength(), new String(cbuf, off, len)); + }//}}} + + //{{{ write() + public void write(int b) throws IOException { + if (m_m_closed) { + throw new IOException("ContentManagerWriter is closed"); + } + char []carray = { (char)b }; + m_m_content.insert(m_m_content.getLength(), new String(carray)); + }//}}} + + //{{{ write() + public void write(String str) throws IOException { + if (m_m_closed) { + throw new IOException("ContentManagerWriter is closed"); + } + m_m_content.insert(m_m_content.getLength(), str); + }//}}} + + //{{{ flush() + public void flush() throws IOException { + if (m_m_closed) { + throw new IOException("ContentManagerWriter is closed"); + } + //writes happen immediately so this does nothing. + }//}}} + + //{{{ close() + public void close() { + //honoring the contract for Writer class + m_m_closed = true; + }//}}} + + //{{{ Private members + private ContentManager m_m_content; + private boolean m_m_closed = false; + //}}} + }//}}} + + private org.w3c.dom.Document m_document; + + private ContentManager m_content; + + private HashMap m_properties = new HashMap(); + + private ArrayList m_docListeners = new ArrayList(); + private ArrayList m_undoListeners = new ArrayList(); + + //}}} + +} Copied: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java (from rev 999, branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLElement.java) =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -0,0 +1,57 @@ +/* +XMLElement.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2; + +//{{{ Imports +import org.w3c.dom.*; +import org.w3c.dom.events.*; +//}}} + +/** + * The XMLElement class represents an element in the XMLDocument tree. It allows + * attibute modifications which will translate to text modifications in the + * XMLDocument. + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see XMLDocument + * @since jsXe 0.5 pre2 + */ +public class XMLElement extends XMLNode { + + //{{{ XMLElement constructor + /** + * Creates a new XMLElement + * @param element the element node that this node wraps. + */ + XMLElement(Element element) { + super(element); + }//}}} + + //{{{ getNodeType() + public int getNodeType() { + return Node.ELEMENT_NODE; + }//}}} + +} Copied: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java (from rev 999, branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLNode.java) =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-07 23:54:05 UTC (rev 1000) @@ -0,0 +1,102 @@ +/* +XMLNode.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2006 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom2; + +//{{{ imports + +//{{{ jsXe classes +import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.util.Log; +import net.sourceforge.jsxe.dom.completion.*; +//}}} + +//{{{ DOM classes +import org.w3c.dom.*; +import org.w3c.dom.events.*; +//}}} + +//}}} + +/** + * <p>The XMLNode class is meant to represent an XMLNode in a XMLDocument tree + * but also as a section of text within that document tree. It + * allows tree modifications only, however these modifications + * will correspond to text modifications to the XMLDocument. Direct text + * modifications are only allowed at the XMLDocument level.</p> + * + * <p>It implements a subset of the support offered by standard w3c DOM + * interfaces.</p> + * + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @version $Id$ + * @see XMLDocument + * @since jsXe 0.5 pre2 + */ +public abstract class XMLNode /* implements javax.swing.text.Element */ { + + private static final String USER_DATA_KEY = "net.sourceforge.jsxe.dom.XMLNode"; + + //{{{ Private members + + /** + * The w3c Node that this node wraps. It must support the EventTarget + * interface in org.w3c.dom.events + */ + private Node m_domNode; + + //}}} + + //{{{ XMLNode constructor + XMLNode(Node node) { + m_domNode = node; + }//}}} + + //{{{ addEventListener() + public void addEventListener(java.lang.String type, EventListener listener, boolean useCapture) { + ((EventTarget)m_domNode).addEventListener(type, listener, useCapture); + }//}}} + + //{{{ removeEventListener() + public void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture) { + ((EventTarget)m_domNode).removeEventListener(type, listener, useCapture); + }//}}} + + //{{{ appendNode() + public XMLNode appendChild(XMLNode newChild) { + + m_domNode.appendChild(newChild.getNode()); + + return newChild; + }//}}} + + //{{{ Protected Members + + //{{{ getNode() + protected Node getNode() { + return m_domNode; + }//}}} + + //}}} +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-27 17:50:21
|
Revision: 1075 Author: ian_lewis Date: 2006-07-27 10:50:10 -0700 (Thu, 27 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1075&view=rev Log Message: ----------- updated format of headers Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/CatalogManager.java branches/jsxe2/src/net/sourceforge/jsxe/action/ActivityLogAction.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/CatalogManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/CatalogManager.java 2006-07-27 02:05:24 UTC (rev 1074) +++ branches/jsxe2/src/net/sourceforge/jsxe/CatalogManager.java 2006-07-27 17:50:10 UTC (rev 1075) @@ -3,9 +3,9 @@ :tabSize=4:indentSize=4:noTabs=true: :folding=explicit:collapseFolds=1: - * Copyright (C) 2001, 2003 Slava Pestov - * Portions copyright (C) 2002 Chris Stevenson - * Portions copyright (C) 2005 Ian Lewis (Ian...@me...) +Copyright (C) 2001, 2003 Slava Pestov +Portions copyright (C) 2002 Chris Stevenson +Portions copyright (C) 2005 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License Modified: branches/jsxe2/src/net/sourceforge/jsxe/action/ActivityLogAction.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-07-27 02:05:24 UTC (rev 1074) +++ branches/jsxe2/src/net/sourceforge/jsxe/action/ActivityLogAction.java 2006-07-27 17:50:10 UTC (rev 1075) @@ -4,6 +4,7 @@ :folding=explicit:collapseFolds=1: Copyright (C) 2005 Trish Harnett (tri...@me...) +Portions Copyright (C) 2005 Ian Lewis (Ian...@me...) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -54,7 +55,8 @@ /** * The action that is executed when the clicks on the Activity Log option under the Help Menu * - * @author Trish Hartnett + * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) + * @author Trish Hartnett (<a href="mailto:tri...@me...">tri...@me...</a>) * @version $Id$ */ public class ActivityLogAction extends AbstractAction { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-28 22:46:33
|
Revision: 1082 Author: ian_lewis Date: 2006-07-28 15:46:19 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1082&view=rev Log Message: ----------- Added new multi-threading support. XMLDocuments and XMLNodes no longer implement the Document and Element interfaces respectively. The source tree will not currently compile Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java branches/jsxe2/src/net/sourceforge/jsxe/properties Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -59,19 +59,23 @@ //}}} /** - * The XMLDocument class represents an XML document as a tree structure + * <p>The XMLDocument class represents an XML document as a tree structure * that has nodes, implemented as XMLNodes, as well as text. Methods are * provided to allow user objects to interact with the XML document as text - * or as a tree structure seamlessly. + * or as a tree structure seamlessly.</p> * - * Properties of XMLDocuments are saved by jsXe as string values. And are loaded - * later when if the document was loaded recently. + * <p>It is implemented in the spirit of the {@link javax.swing.text.Document} + * class in that it represents a piece of structured text that can be + * viewed and edited via the text or document structure</p> * + * <p>Properties of XMLDocuments are saved by jsXe as string values. And are loaded + * later when if the document was loaded recently.</p> + * * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) * @version $Id: XMLDocument.java 999 2006-07-07 20:59:23Z ian_lewis $ * @see XMLNode */ -public class XMLDocument implements javax.swing.text.Document { +public class XMLDocument { //{{{ XMLDocument defined properties /** @@ -152,7 +156,6 @@ */ public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Map properties) throws IOException { m_entityResolver = resolver; - setDefaultProperties(); setURI(uri); //add properties one by one @@ -168,14 +171,13 @@ reader.close(); }//}}} - //{{{ swing.text.Document methods - //{{{ addDocumentListener /** * Registers a change listener with the XMLDocument * @param listener the listener to register with this document */ public void addDocumentListener(DocumentListener listener) { + //TODO: Create XMLDocumentListeners if (listener != null) { m_docListeners.add(listener); } @@ -189,90 +191,47 @@ } }//}}} - //{{{ createPosition() - - public Position createPosition(int offs) throws BadLocationException { - if (offs < 0 || offs > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("createPosition(): Bad offset", offs); - } - - final int offset = offs; - return new Position() { - public int getOffset() { - return offset; - } - }; - }//}}} - //{{{ getDefaultRootElement() - - public javax.swing.text.Element getDefaultRootElement() { + /** + * Gets the root document element. + */ + public XMLElement getRootElement() { //TODO: return root element return null; }//}}} - //{{{ getEndPosition() - - public Position getEndPosition() { - try { - return createPosition(getLength()-1); - } catch (BadLocationException e) { - //Guaranteed to be good. - return null; - } - }//}}} - //{{{ getLength() /** - * Gets the total number of characters in the document. + * Gets the total number of characters in the document. This method is + * thread-safe. * @return the length of the document */ public int getLength() { + // no need to lock since this just returns a value and that's it return m_content.getLength(); }//}}} - //{{{ getProperty() + //{{{ getRootNodes() - public Object getProperty(Object key) { - return m_properties.get(key); - }//}}} - - //{{{ getRootElements() - - public javax.swing.text.Element[] getRootElements() { + public XMLNode[] getRootNodes() { //TODO: return root nodes return null; }//}}} - //{{{ getStartPosition() - - public Position getStartPosition() { - try { - return createPosition(0); - } catch (BadLocationException e) { - //Guaranteed to be good. - return null; - } - }//}}} - //{{{ getText() - public String getText(int offset, int length) throws BadLocationException { + public String getText(int offset, int length) { if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } return m_content.getText(offset,length); }//}}} //{{{ getText() - - public void getText(int offset, int length, Segment txt) throws BadLocationException { + public void getText(int offset, int length, Segment txt) { if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } m_content.getText(offset, length, txt); @@ -302,10 +261,9 @@ * @param a the attributes to associate with the inserted content. * This attribute is ignored by XMLDocuments. */ - public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { + public void insertString(int offset, String str) { if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offset); + throw new ArrayIndexOutOfBoundsException(offset); } m_content.insert(offset, str); @@ -315,24 +273,11 @@ //TODO: implement undo }//}}} - //{{{ putProperty() - /** - * Add a property to the XMLDocument. - * They are saved in memory as objects however, jsXe saves properties as - * Strings when saving the Document to the recent buffers file, and when - * the document is opened later the property will be loaded as a String. - * Generally String properties are stored here. - */ - public void putProperty(Object key, Object value) { - m_properties.put(key, value); - }//}}} - //{{{ remove() - public void remove(int offs, int len) throws BadLocationException { + public void remove(int offs, int len) { if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { - //TODO: fix error messages - throw new BadLocationException("insertString(): Bad Offset", offs); + throw new ArrayIndexOutOfBoundsException(offs); } m_content.remove(offs, len); @@ -359,12 +304,60 @@ }//}}} //{{{ render() - public void render(Runnable r) { - //TODO: implement concurrency support. + VFSManager.runInWorkThread(new Runnable() { + public void run() { + try { + readLock(); + + r.run(); + + } finally { + readUnlock(); + } + } + }); }//}}} - //}}} + //{{{ Thread safety + + //{{{ readLock() method + /** + * The buffer is guaranteed not to change between calls to + * {@link #readLock()} and {@link #readUnlock()}. + */ + public void readLock() { + lock.readLock(); + } //}}} + + //{{{ readUnlock() method + /** + * The buffer is guaranteed not to change between calls to + * {@link #readLock()} and {@link #readUnlock()}. + */ + public void readUnlock() { + lock.readUnlock(); + } //}}} + + //{{{ writeLock() method + /** + * Attempting to obtain read lock will block between calls to + * {@link #writeLock()} and {@link #writeUnlock()}. + */ + public void writeLock() { + lock.writeLock(); + } //}}} + + //{{{ writeUnlock() method + /** + * Attempting to obtain read lock will block between calls to + * {@link #writeLock()} and {@link #writeUnlock()}. + */ + public void writeUnlock() { + lock.writeUnlock(); + } //}}} + + //}}} //{{{ getDocumentType() @@ -383,6 +376,114 @@ return m_properties; }//}}} + //{{{ getProperty() + + public String getProperty(String key) { + synchronized(propertyLock) { + // First try the buffer-local properties + String o = m_properties.getProperty(key); + if (o == null) { + // Now try xml.document.<property> + o = jsXe.getProperty("xml.document." + name); + } + return o; + } + }//}}} + + //{{{ setProperty() + public void settProperty(String key, String value) { + synchronized(propertyLock) { + if (value == null) { + m_properties.remove(key); + } else { + m_properties.setProperty(key, value); + } + } + }//}}} + + //{{{ getStringProperty() method + /** + * Returns the value of a string property. This method is thread-safe. + * @param name The property name + */ + public String getStringProperty(String name) { + Object obj = getProperty(name); + if (obj != null) { + return obj.toString(); + } else { + return null; + } + } //}}} + + //{{{ setStringProperty() method + /** + * Sets a string property. + * @param name The property name + * @param value The value + */ + public void setStringProperty(String name, String value) { + setProperty(name,value); + } //}}} + + //{{{ getBooleanProperty() method + /** + * Returns the value of a boolean property. This method is thread-safe. + * @param name The property name + */ + public boolean getBooleanProperty(String name) { + Object obj = getProperty(name); + if (obj == null) { + return null; + } + + if (obj instanceof Boolean) { + return ((Boolean)obj).booleanValue(); + } else { + return Boolean.valueOf(obj.toString()).booleanValue(); + } + } //}}} + + //{{{ setBooleanProperty() method + /** + * Sets a boolean property. + * @param name The property name + * @param value The value + */ + public void setBooleanProperty(String name, boolean value) { + setProperty(name, Boolean.valueOf(value)); + } //}}} + + //{{{ getIntegerProperty() method + /** + * Returns the value of an integer property. This method is thread-safe. + * @param name The property name + */ + public int getIntegerProperty(String name, int defaultValue) { + + boolean defaultValueFlag; + Object obj = getProperty(); + + if (obj == null) { + return defaultValue; + } else { + if (obj instanceof Number) { + return ((Number)obj).intValue(); + } else { + return defaultValue; + } + } + } //}}} + + //{{{ setIntegerProperty() method + /** + * Sets an integer property. + * @param name The property name + * @param value The value + */ + public void setIntegerProperty(String name, int value) { + setProperty(name, new Integer(value)); + } //}}} + //{{{ setURI() /** * Sets the URI for the location of this document. @@ -473,16 +574,6 @@ //{{{ Private members - //{{{ setDefaultProperties() - private void setDefaultProperties() { - putProperty(FORMAT_XML, "false"); - putProperty(IS_USING_SOFT_TABS, "false"); - putProperty(WS_IN_ELEMENT_CONTENT, "true"); - putProperty(ENCODING, "UTF-8"); - putProperty(INDENT, "4"); - putProperty(IS_VALIDATING, "false"); - }//}}} - //{{{ ContentManager class /** * Text content manager based off of jEdit's ContentManager class. @@ -712,11 +803,14 @@ private ContentManager m_content; - private HashMap m_properties = new HashMap(); + private Properties m_properties = new Properties(); private ArrayList m_docListeners = new ArrayList(); private ArrayList m_undoListeners = new ArrayList(); + private Object propertyLock = new Object(); + private ReadWriteLock lock = new ReadWriteLock(); + /** * The entity resolver to use when resolving external entities * in this document. Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -53,6 +53,10 @@ * will correspond to text modifications to the XMLDocument. Direct text * modifications are only allowed at the XMLDocument level.</p> * + * <p>It is implement in the spirit of the {@link javax.swing.text.Element} + * class as it represents a piece of text as well as a structural element + * in the document.</p> + * * <p>It implements a subset of the support offered by standard w3c DOM * interfaces.</p> * @@ -61,7 +65,7 @@ * @see XMLDocument * @since jsXe 0.5 pre2 */ -public abstract class XMLNode implements javax.swing.text.Element { +public abstract class XMLNode { protected static final String USER_DATA_KEY = "net.sourceforge.jsxe.dom.XMLNode"; Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -23,22 +23,22 @@ from http://www.fsf.org/copyleft/gpl.txt */ -package org.gjt.sp.jedit.buffer; +package net.sourceforge.jsxe.dom2.ls; //{{{ Imports import javax.swing.text.Segment; import java.io.*; import java.util.zip.*; import java.util.Vector; -import org.gjt.sp.jedit.io.*; -import org.gjt.sp.jedit.*; -import org.gjt.sp.util.*; +import net.sourceforge.jsxe.io.*; +import net.sourceforge.jsxe.*; +import net.sourceforge.jsxe.util.*; //}}} /** * A document I/O request. * @author Slava Pestov - * @version $Id: BufferIORequest.java,v 1.28 2004/08/29 02:58:43 spestov Exp $ + * @version $Id$ */ public class XMLDocumentIORequest extends WorkRequest { @@ -53,12 +53,12 @@ */ public static final int PROGRESS_INTERVAL = 300; - public static final String LOAD_DATA = "BufferIORequest__loadData"; - public static final String END_OFFSETS = "BufferIORequest__endOffsets"; - public static final String NEW_PATH = "BufferIORequest__newPath"; + public static final String LOAD_DATA = "XMLDocumentIORequest__loadData"; + public static final String END_OFFSETS = "XMLDocumentIORequest__endOffsets"; + public static final String NEW_PATH = "XMLDocumentIORequest__newPath"; /** - * Buffer boolean property set when an error occurs. + * Boolean property set when an error occurs. */ public static final String ERROR_OCCURRED = "XMLDocumentIORequest__error"; @@ -173,7 +173,7 @@ //{{{ Instance variables private int type; private View view; - private Buffer buffer; + private XMLDocument buffer; private Object session; private VFS vfs; private String path; @@ -288,110 +288,96 @@ * Tries to detect if the stream is gzipped, and if it has an encoding * specified with an XML PI. */ - private Reader autodetect(InputStream in) throws IOException - { + private Reader autodetect(InputStream in) throws IOException { in = new BufferedInputStream(in); String encoding = buffer.getStringProperty(Buffer.ENCODING); - if(!in.markSupported()) + if (!in.markSupported()) { Log.log(Log.WARNING,this,"Mark not supported: " + in); - else if(buffer.getBooleanProperty(Buffer.ENCODING_AUTODETECT)) - { - in.mark(XML_PI_LENGTH); - int b1 = in.read(); - int b2 = in.read(); - int b3 = in.read(); - - if(encoding.equals(MiscUtilities.UTF_8_Y)) - { - // Java does not support this encoding so - // we have to handle it manually. - if(b1 != UTF8_MAGIC_1 || b2 != UTF8_MAGIC_2 - || b3 != UTF8_MAGIC_3) - { - // file does not begin with UTF-8-Y - // signature. reset stream, read as - // UTF-8. - in.reset(); - } - else - { - // file begins with UTF-8-Y signature. - // discard the signature, and read - // the remainder as UTF-8. - } - - encoding = "UTF-8"; - } - else if(b1 == GZIP_MAGIC_1 && b2 == GZIP_MAGIC_2) - { - in.reset(); - in = new GZIPInputStream(in); - buffer.setBooleanProperty(Buffer.GZIPPED,true); - // auto-detect encoding within the gzip stream. - return autodetect(in); - } - else if((b1 == UNICODE_MAGIC_1 - && b2 == UNICODE_MAGIC_2) - || (b1 == UNICODE_MAGIC_2 - && b2 == UNICODE_MAGIC_1)) - { - in.reset(); - encoding = "UTF-16"; - buffer.setProperty(Buffer.ENCODING,encoding); - } - else if(b1 == UTF8_MAGIC_1 && b2 == UTF8_MAGIC_2 - && b3 == UTF8_MAGIC_3) - { - // do not reset the stream and just treat it - // like a normal UTF-8 file. - buffer.setProperty(Buffer.ENCODING, - MiscUtilities.UTF_8_Y); - - encoding = "UTF-8"; - } - else - { - in.reset(); - - byte[] _xmlPI = new byte[XML_PI_LENGTH]; - int offset = 0; - int count; - while((count = in.read(_xmlPI,offset, - XML_PI_LENGTH - offset)) != -1) - { - offset += count; - if(offset == XML_PI_LENGTH) - break; - } - - String xmlPI = new String(_xmlPI,0,offset, - "ASCII"); - if(xmlPI.startsWith("<?xml")) - { - int index = xmlPI.indexOf("encoding="); - if(index != -1 - && index + 9 != xmlPI.length()) - { - char ch = xmlPI.charAt(index - + 9); - int endIndex = xmlPI.indexOf(ch, - index + 10); - encoding = xmlPI.substring( - index + 10,endIndex); - - if(MiscUtilities.isSupportedEncoding(encoding)) + } else { + if(buffer.getBooleanProperty(Buffer.ENCODING_AUTODETECT)) { + in.mark(XML_PI_LENGTH); + int b1 = in.read(); + int b2 = in.read(); + int b3 = in.read(); + + if (encoding.equals(MiscUtilities.UTF_8_Y)) { + // Java does not support this encoding so + // we have to handle it manually. + if (b1 != UTF8_MAGIC_1 || b2 != UTF8_MAGIC_2 || b3 != UTF8_MAGIC_3) { + // file does not begin with UTF-8-Y + // signature. reset stream, read as + // UTF-8. + in.reset(); + } else { + // file begins with UTF-8-Y signature. + // discard the signature, and read + // the remainder as UTF-8. + } + + encoding = "UTF-8"; + } else { + if (b1 == GZIP_MAGIC_1 && b2 == GZIP_MAGIC_2) { + in.reset(); + in = new GZIPInputStream(in); + buffer.setBooleanProperty(Buffer.GZIPPED,true); + // auto-detect encoding within the gzip stream. + return autodetect(in); + } else { + if ((b1 == UNICODE_MAGIC_1 + && b2 == UNICODE_MAGIC_2) + || (b1 == UNICODE_MAGIC_2 + && b2 == UNICODE_MAGIC_1)) { + in.reset(); + encoding = "UTF-16"; buffer.setProperty(Buffer.ENCODING,encoding); + } else { + if (b1 == UTF8_MAGIC_1 && b2 == UTF8_MAGIC_2 + && b3 == UTF8_MAGIC_3) + { + // do not reset the stream and just treat it + // like a normal UTF-8 file. + buffer.setProperty(Buffer.ENCODING, + MiscUtilities.UTF_8_Y); + + encoding = "UTF-8"; + } else { + in.reset(); + + byte[] _xmlPI = new byte[XML_PI_LENGTH]; + int offset = 0; + int count; + while((count = in.read(_xmlPI,offset, + XML_PI_LENGTH - offset)) != -1) + { + offset += count; + if(offset == XML_PI_LENGTH) + break; + } + + String xmlPI = new String(_xmlPI,0,offset, + "ASCII"); + if (xmlPI.startsWith("<?xml")) { + int index = xmlPI.indexOf("encoding="); + if (index != -1 && index + 9 != xmlPI.length()) { + char ch = xmlPI.charAt(index + 9); + int endIndex = xmlPI.indexOf(ch, index + 10); + encoding = xmlPI.substring(index + 10,endIndex); + + if (MiscUtilities.isSupportedEncoding(encoding)) { + buffer.setProperty(Buffer.ENCODING,encoding); + } else { + Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); + } + } + } + + in.reset(); + } } - else - { - Log.log(Log.WARNING,this,"XML PI specifies unsupported encoding: " + encoding); - } } } - - in.reset(); } } Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-07-28 22:46:19 UTC (rev 1082) @@ -57,13 +57,13 @@ * * @author Slava Pestov * @author Ian Lewis (<a href="mailto:Ian...@me...">Ian...@me...</a>) - * @version $Id: VFSManager.java,v 1.15 2004/05/10 03:21:11 spestov Exp $ + * @version $Id$ */ public class VFSManager { /** * The service type. See {@link org.gjt.sp.jedit.ServiceManager}. */ - public static final String SERVICE = "org.gjt.sp.jedit.io.VFS"; + public static final String SERVICE = "net.sourceforge.jsxe.io.VFS"; //{{{ init() method /** @@ -95,7 +95,6 @@ //{{{ getFileVFS() method /** * Returns the local filesystem VFS. - * @since jEdit 2.5pre1 */ public static VFS getFileVFS() { @@ -105,7 +104,6 @@ //{{{ getUrlVFS() method /** * Returns the URL VFS. - * @since jEdit 2.5pre1 */ public static VFS getUrlVFS() { @@ -130,7 +128,6 @@ /** * Returns the VFS for the specified protocol. * @param protocol The protocol - * @since jEdit 2.5pre1 */ public static VFS getVFSForProtocol(String protocol) { @@ -153,7 +150,6 @@ /** * Returns the VFS for the specified path. * @param path The path - * @since jEdit 2.6pre4 */ public static VFS getVFSForPath(String path) { @@ -189,7 +185,6 @@ //{{{ getVFSs() method /** * Returns a list of all registered filesystems. - * @since jEdit 4.2pre1 */ public static String[] getVFSs() { @@ -227,7 +222,6 @@ //{{{ waitForRequests() method /** * Returns when all pending requests are complete. - * @since jEdit 2.5pre1 */ public static void waitForRequests() { @@ -256,7 +250,6 @@ /** * Executes the specified runnable in the AWT thread once all * pending I/O requests are complete. - * @since jEdit 2.5pre1 */ public static void runInAWTThread(Runnable run) { @@ -266,7 +259,6 @@ //{{{ runInWorkThread() method /** * Executes the specified runnable in one of the I/O threads. - * @since jEdit 2.6pre2 */ public static void runInWorkThread(Runnable run) { @@ -318,7 +310,6 @@ * @param path The path name that caused the error * @param messageProp The error message property name * @param args Positional parameters - * @since jEdit 4.0pre3 */ public static void error(Component comp, final String path, @@ -367,7 +358,6 @@ * @param path The path that changed * @param parent True if an update should be sent for the path's * parent too - * @since jEdit 2.6pre4 */ public static void sendVFSUpdate(VFS vfs, String path, boolean parent) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/properties =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-28 20:04:32 UTC (rev 1081) +++ branches/jsxe2/src/net/sourceforge/jsxe/properties 2006-07-28 22:46:19 UTC (rev 1082) @@ -45,4 +45,11 @@ metal.secondary.fontstyle=0 #}}} - +#{{{ XMLDocument default properties +xml.document.encoding=UTF-8 +xml.document.element-content-whitespace=true +xml.document.format-pretty-print=false +xml.document.soft-tabs=false +xml.document.indent=4 +xml.document.validating=false +#}}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-07-29 05:49:10
|
Revision: 1090 Author: ian_lewis Date: 2006-07-28 22:48:54 -0700 (Fri, 28 Jul 2006) ViewCVS: http://svn.sourceforge.net/jsxe/?rev=1090&view=rev Log Message: ----------- Updated multi-threaded support. Added new constructor methods for document nodes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java 2006-07-29 04:42:42 UTC (rev 1089) +++ branches/jsxe2/src/net/sourceforge/jsxe/ActionManager.java 2006-07-29 05:48:54 UTC (rev 1090) @@ -254,9 +254,9 @@ */ public static void handleKey(KeyEvent event) { KeyEventTranslator.Key key = KeyEventTranslator.translateKeyEvent(event); - Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); - Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); - Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); + // Log.log(Log.DEBUG, ActionManager.class, "Key: "+key.toString()); + // Log.log(Log.DEBUG, ActionManager.class, "key.key: "+key.key); + // Log.log(Log.DEBUG, ActionManager.class, "key.input: "+key.input); //Gets the action for the Key. Action action = (Action)m_keyBindingMap.get(key); Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 04:42:42 UTC (rev 1089) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-07-29 05:48:54 UTC (rev 1090) @@ -206,71 +206,79 @@ //{{{ getText() public String getText(int offset, int length) { - if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); + try { + + readLock(); + + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + return m_content.getText(offset,length); + } finally { + readUnlock(); } - - return m_content.getText(offset,length); }//}}} //{{{ getText() public void getText(int offset, int length, Segment txt) { - if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); + try { + + readLock(); + + if (offset < 0 || length < 0 || offset + length > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + m_content.getText(offset, length, txt); + + } finally { + readUnlock(); } - - m_content.getText(offset, length, txt); }//}}} //{{{ insertString() - /** - * <p>Inserts a string of content. This will cause a DocumentEvent of type - * DocumentEvent.EventType.INSERT to be sent to the registered - * DocumentListers, unless an exception is thrown. The DocumentEvent will - * be delivered by calling the insertUpdate method on the - * DocumentListener. The offset and length of the generated DocumentEvent - * will indicate what change was actually made to the Document.</p> - * - * <p>If the Document structure changed as result of the insertion, the - * details of what Elements were inserted and removed in response to the - * change will also be contained in the generated DocumentEvent. It is up - * to the implementation of a Document to decide how the structure should - * change in response to an insertion.</p> - * - * <p>If the Document supports undo/redo, an UndoableEditEvent will also be - * generated.</p> - * @param offset the offset into the document to insert the content >= 0. - * All positions that track change at or after the given - * location will move. - * @param str the string to insert - * @param a the attributes to associate with the inserted content. - * This attribute is ignored by XMLDocuments. - */ public void insertString(int offset, String str) { - if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offset); - } - m_content.insert(offset, str); + try { + + writeLock(); - //TODO: document structure must change - //TODO: notify listeners - //TODO: implement undo + if (offset < 0 || str.length() < 0 || offset + str.length() > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offset); + } + + m_content.insert(offset, str); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + } finally { + writeUnlock(); + } }//}}} //{{{ remove() public void remove(int offs, int len) { - if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { - throw new ArrayIndexOutOfBoundsException(offs); + + try { + + writeLock(); + + if (offs < 0 || len < 0 || offs + len > m_content.getLength()) { + throw new ArrayIndexOutOfBoundsException(offs); + } + + m_content.remove(offs, len); + + //TODO: document structure must change + //TODO: notify listeners + //TODO: implement undo + } finally { + writeUnlock(); } - - m_content.remove(offs, len); - - //TODO: document structure must change - //TODO: notify listeners - //TODO: implement undo }//}}} //{{{ removeDocumentListener() @@ -349,9 +357,8 @@ }//}}} //{{{ getProperties() - - public Map getProperties() { - return m_properties; + public Enumeration getProperties() { + return m_properties.propertyNames(); }//}}} //{{{ getProperty() @@ -363,7 +370,7 @@ if (o == null) { // Now try xml.document.<property> o = jsXe.getProperty("xml.document." + name); - } + } return o; } }//}}} @@ -409,16 +416,12 @@ * @param name The property name */ public boolean getBooleanProperty(String name) { - Object obj = getProperty(name); + String obj = getProperty(name); if (obj == null) { return null; } - if (obj instanceof Boolean) { - return ((Boolean)obj).booleanValue(); - } else { - return Boolean.valueOf(obj.toString()).booleanValue(); - } + return Boolean.valueOf(obj).booleanValue(); } //}}} //{{{ setBooleanProperty() method @@ -428,7 +431,7 @@ * @param value The value */ public void setBooleanProperty(String name, boolean value) { - setProperty(name, Boolean.valueOf(value)); + setProperty(name, Boolean.toString(value)); } //}}} //{{{ getIntegerProperty() method @@ -439,14 +442,14 @@ public int getIntegerProperty(String name, int defaultValue) { boolean defaultValueFlag; - Object obj = getProperty(); + String obj = getProperty(); if (obj == null) { return defaultValue; } else { - if (obj instanceof Number) { - return ((Number)obj).intValue(); - } else { + try { + return Integer.parseInt(obj); + } catch (NumberFormatException e) { return defaultValue; } } @@ -459,7 +462,7 @@ * @param value The value */ public void setIntegerProperty(String name, int value) { - setProperty(name, new Integer(value)); + setProperty(name, Integer.toString(value)); } //}}} //{{{ setURI() @@ -486,7 +489,14 @@ * document is standalone. This is false when unspecified. */ public void setStandalone(boolean standalone) throws DOMException { - m_document.setXmlStandalone(standalone); + try { + writeLock(); + + m_document.setXmlStandalone(standalone); + //TODO: update text + } finally { + writeUnlock(); + } }//}}} //{{{ isStandalone() @@ -495,7 +505,13 @@ * document is standalone. This is false when unspecified. */ public boolean isStandalone() { - return m_document.getXmlStandalone(); + try { + readLock(); + + return m_document.getXmlStandalone(); + } finally { + readUnlock(); + } }//}}} //{{{ isReadOnly() @@ -523,7 +539,23 @@ //{{{ newElementNode() /** * Create a new XMLElement node with the given name. + * * @param name the qualified name of the new node. + * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified + * qualifiedName is not an XML name according to the + * XML version in use specified in the xml version + * attribute. + * @throws DOMException NAMESPACE_ERR: Raised if the qualifiedName is a + * malformed qualified name, if the qualifiedName has + * a prefix and the namespaceURI is null, or if the + * qualifiedName has a prefix that is "xml" and the + * namespaceURI is different from " + * http://www.w3.org/XML/1998/namespace" + * [XML Namespaces] , or if the qualifiedName or its + * prefix is "xmlns" and the namespaceURI is different + * from "http://www.w3.org/2000/xmlns/", or if the + * namespaceURI is "http://www.w3.org/2000/xmlns/" and + * neither the qualifiedName nor its prefix is "xmlns". */ public XMLElement newElementNode(String name) throws DOMException { return new XMLElement(m_document.createElementNS("", name)); @@ -538,6 +570,48 @@ return new XMLAttribute(m_document.createAttributeNS("", name)); }//}}} + //{{{ newCDATASection() + /** + * Creates a CDATASection node whose value is the specified string. + * @param data The data for the CDATASection contents. + */ + public XMLCDATASection newCDATASection(String data) { + return new XMLCDATASection(m_document.createCDATASection(data)); + }//}}} + + //{{{ newCommentNode() + /** + * Creates a Comment node given the specified string. + * @param data the text contents of the comment + */ + public XMLComment newCommentNode(String data) { + return new XMLComment(m_document.createCommentNode(data)); + }//}}} + + //{{{ newProcessingInstruction() + /** + * Creates a ProcessingInstruction node given the specified name and data strings. + * @param target The target part of the processing instruction. + * @param data The data for the node. + * @throws DOMException INVALID_CHARACTER_ERR: Raised if the specified + * target is not an XML name according to the XML + * version in use specified in the xml version + * attribute. + */ + public XMLProcessingInstruction newProcessingInstruction(String target, String data) throws DOMException { + //TODO: make sure the target is namespace-well-formed + return new XMLProcessingInstruction(m_document.createProcessingInstruction(target, data)); + }//}}} + + //{{{ newTextNode() + /** + * Creates a Text node given the specified string. + * @param data the text contents of this node + */ + public XMLText newTextNode(String data) { + return new XMLText(m_document.createTextNode(data)); + }//}}} + //{{{ newErrorNode() /** * Creates a new error node. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-09-02 16:17:52
|
Revision: 1228 http://svn.sourceforge.net/jsxe/?rev=1228&view=rev Author: ian_lewis Date: 2006-09-02 09:17:37 -0700 (Sat, 02 Sep 2006) Log Message: ----------- More compatibility changes Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLDocument.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -154,7 +154,7 @@ * @param properties the properties to assign this XMLDocument on creation. * @throws IOException if there was a problem reading the document */ - public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Map properties) throws IOException { + public XMLDocument(String uri, InputStream reader, EntityResolver resolver, Properties properties) throws IOException { m_entityResolver = resolver; setURI(uri); @@ -162,8 +162,8 @@ if (properties != null) { Iterator propertyNames = properties.keySet().iterator(); while (propertyNames.hasNext()) { - Object key = propertyNames.next(); - putProperty(key, properties.get(key)); + String key = propertyNames.next().toString(); + setProperty(key, properties.getProperty(key)); } } @@ -358,7 +358,7 @@ String o = m_properties.getProperty(key); if (o == null) { // Now try xml.document.<property> - o = jsXe.getProperty("xml.document." + name); + o = jsXe.getProperty("xml.document." + key); } return o; } @@ -380,10 +380,10 @@ * Returns the value of a boolean property. This method is thread-safe. * @param name The property name */ - public boolean getBooleanProperty(String name) { + public boolean getBooleanProperty(String name, boolean defValue) { String obj = getProperty(name); if (obj == null) { - return null; + return defValue; } return Boolean.valueOf(obj).booleanValue(); @@ -407,7 +407,7 @@ public int getIntegerProperty(String name, int defaultValue) { boolean defaultValueFlag; - String obj = getProperty(); + String obj = getProperty(name); if (obj == null) { return defaultValue; @@ -567,7 +567,7 @@ * @param data the text contents of the comment */ public XMLComment newCommentNode(String data) { - return new XMLComment(m_document.createCommentNode(data)); + return new XMLComment(m_document.createComment(data)); }//}}} //{{{ newProcessingInstruction() Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLElement.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -31,10 +31,6 @@ import net.sourceforge.jsxe.util.MiscUtilities; //}}} -//{{{ Swing classes -import javax.swing.text.*; -//}}} - //{{{ DOM classes import org.w3c.dom.*; import org.w3c.dom.events.*; @@ -42,6 +38,7 @@ //{{{ Java classes import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; //}}} @@ -84,7 +81,7 @@ for (int i=0; i<len; i++) { Node attr = attributes.item(i); XMLAttribute xmlAttr = (XMLAttribute)attr.getUserData(USER_DATA_KEY); - attrSet.put(xmlAttr.getName(), xmlAttr.getValue()); + attrSet.put(xmlAttr.getQualifiedName(), xmlAttr.getValue()); } return attrSet; }//}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLError.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -53,23 +53,22 @@ }//}}} //{{{ getDocument() - public javax.swing.text.Document getDocument() { + public XMLDocument getDocument() { return m_document; }//}}} - //{{{ getElement() - public javax.swing.text.Element getElement(int index) { + //{{{ getChild() + public XMLNode getChild(int index) { return null; }//}}} - //{{{ getElementCount() - public int getElementCount() { + //{{{ getChildCount() + public int getChildCount() { return 0; }//}}} - //{{{ getName() - public String getName() { - //TODO + //{{{ getQualifiedName() + public String getQualifiedName() { if (m_warning) { return Messages.getMessage("common.warning"); } else { @@ -77,8 +76,8 @@ } }//}}} - //{{{ getParentElement() - public javax.swing.text.Element getParentElement() { + //{{{ getParentNode() + public XMLNode getParentNode() { return m_parent; }//}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/XMLNode.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -38,12 +38,11 @@ import org.w3c.dom.events.*; //}}} -//{{{ Swing classes -import javax.swing.text.*; +//{{{ Java classes +import java.util.ArrayList; +import java.util.Map; //}}} -import java.util.ArrayList; - //}}} /** @@ -139,8 +138,6 @@ } }//}}} - //{{{ javax.swing.text.Element methods - //{{{ getAttributes() /** * Attributes in an XMLNode are implemented as the attributes in a @@ -149,57 +146,83 @@ * DocumentView. * @return the attributes of the XMLElement node or null. */ - public AttributeSet getAttributes() { + public Map getAttributes() { //no attributes by default. Subclasses may override this behavior return null; }//}}} //{{{ getDocument() - public javax.swing.text.Document getDocument() { - return (javax.swing.text.Document)m_domNode.getOwnerDocument().getUserData(USER_DATA_KEY); + public XMLDocument getDocument() { + Document doc = m_domNode.getOwnerDocument(); + if (doc != null) { + return (XMLDocument)doc.getUserData(USER_DATA_KEY); + } else { + return null; + } }//}}} - //{{{ getElement() + //{{{ getChild() - public javax.swing.text.Element getElement(int index) { - return (javax.swing.text.Element)m_children.get(index); + public XMLNode getChild(int index) { + return (XMLNode)m_children.get(index); }//}}} - //{{{ getElementCount() + //{{{ getChildCount() - public int getElementCount() { + public int getChildCount() { return m_children.size(); }//}}} - //{{{ getElementIndex() - - public int getElementIndex(int offset) { + //{{{ getChildIndex() + /** + * Gets the child index closest to the given offset. The offset is + * specified relative to the beginning of the document. + * Returns -1 if the child is a leaf, otherwise returns the index of the + * child that best represents the given location. Returns 0 if the location + * is less than the start offset. Returns getChildCount() - 1 + * if the location is greater than or equal to the end offset. + * @param offset the specified offset >= 0 + */ + public int getChildIndex(int offset) { //TODO: implement offsets return 0; }//}}} //{{{ getEndOffset() - + /** + * Fetches the offset from the beginning of the document that this node + * ends at. If this node has children, this will be the end offset of the + * last child. As a document position, there is an implied backward bias. + * + * @return the ending offset > getStartOffset() and <= getDocument().getLength() + 1 + */ public int getEndOffset() { //TODO: implement offsets //TODO: should this be abstract? return 0; }//}}} - //{{{ getName() + //{{{ getQualifiedName() /** * Gets the qualified name of the node. This will be the namespace * prefix + ":" + the locale name. * @return the qualified name */ - public String getName() { + public String getQualifiedName() { return m_domNode.getNodeName(); }//}}} - //{{{ getParentElement() - - public javax.swing.text.Element getParentElement() { - return (javax.swing.text.Element)m_domNode.getParentNode().getUserData(USER_DATA_KEY); + //{{{ getParentNode() + /** + * Gets the parent node of this node. + */ + public XMLNode getParentNode() { + Node parent = m_domNode.getParentNode(); + if (parent != null) { + return (XMLNode)parent.getUserData(USER_DATA_KEY); + } else { + return null; + } }//}}} //{{{ getStartOffset() @@ -216,27 +239,30 @@ return m_domNode.hasChildNodes(); }//}}} - //}}} + //{{{ addEventListener() - //{{{ addEventListener() + //TODO: redo change listeners to be XMLNode friendly public void addEventListener(java.lang.String type, EventListener listener, boolean useCapture) { ((EventTarget)m_domNode).addEventListener(type, listener, useCapture); }//}}} //{{{ removeEventListener() + + //TODO: redo change listeners to be XMLNode friendly public void removeEventListener(java.lang.String type, EventListener listener, boolean useCapture) { ((EventTarget)m_domNode).removeEventListener(type, listener, useCapture); }//}}} //{{{ appendNode() public XMLNode appendNode(XMLNode newChild) throws DOMException { - if (((XMLDocument)getDocument()).isReadOnly()) { + XMLDocument doc = getDocument(); + if (doc != null && doc.isReadOnly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); } if (newChild != null) { if (!(newChild instanceof XMLError)) { - XMLNode parent = (XMLNode)newChild.getParentElement(); + XMLNode parent = newChild.getParentNode(); if (parent != null) { parent.removeNode(newChild); } @@ -285,13 +311,14 @@ //{{{ insertNode() public XMLNode insertNode(XMLNode node, int index) throws DOMException { - if (((XMLDocument)getDocument()).isReadOnly()) { + XMLDocument doc = getDocument(); + if (doc != null && doc.isReadOnly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, Messages.getMessage("XML.Read.Only.Node")); } if (node != null) { if (!(node instanceof XMLError)) { - XMLNode parent = (XMLNode)node.getParentElement(); + XMLNode parent = node.getParentNode(); if (parent != null) { parent.removeNode(node); } Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -33,6 +33,7 @@ import net.sourceforge.jsxe.io.*; import net.sourceforge.jsxe.*; import net.sourceforge.jsxe.gui.TabbedView; +import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.dom2.XMLDocument; import net.sourceforge.jsxe.util.*; //}}} @@ -199,10 +200,10 @@ String[] args = { vfs.getFileName(path) }; setAbortable(true); - if (!buffer.isTemporary()) { - setStatus(Messages.getMessage("DocumentBuffer.Loading.Message",args)); - setProgressValue(0); - } + // if (!buffer.isTemporary()) { + // setStatus(Messages.getMessage("DocumentBuffer.Loading.Message",args)); + // setProgressValue(0); + // } path = vfs._canonPath(session,path,view); @@ -285,11 +286,11 @@ private Reader autodetect(InputStream in) throws IOException { in = new BufferedInputStream(in); - String encoding = buffer.getStringProperty(XMLDocument.ENCODING); + String encoding = buffer.getProperty(XMLDocument.ENCODING); if (!in.markSupported()) { Log.log(Log.WARNING,this,"Mark not supported: " + in); } else { - if(buffer.getBooleanProperty(XMLDocument.ENCODING_AUTODETECT)) { + if (buffer.getBooleanProperty(XMLDocument.ENCODING_AUTODETECT, true)) { in.mark(XML_PI_LENGTH); int b1 = in.read(); int b2 = in.read(); @@ -531,7 +532,7 @@ // 0-byte files should open using // the default line seperator" lineSeparator = jsXe.getProperty( - "xml.document."+XMLDocumen.LINE_SEPARATOR, + "xml.document."+XMLDocument.LINE_SEPARATOR, System.getProperty("line.separator")); } else { if (CRLF) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/FileVFS.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -101,9 +101,12 @@ //{{{ save() method public boolean save(TabbedView view, XMLDocument buffer, String path) { if (OperatingSystem.isUnix()) { - int permissions = getPermissions(buffer.getPath()); - Log.log(Log.DEBUG,this,buffer.getPath() + " has permissions 0" + int permissions = getPermissions(path); + Log.log(Log.DEBUG,this, path + " has permissions 0" + Integer.toString(permissions,8)); + // int permissions = getPermissions(buffer.getPath()); + // Log.log(Log.DEBUG,this,buffer.getPath() + " has permissions 0" + // + Integer.toString(permissions,8)); buffer.setIntegerProperty(PERMISSIONS_PROPERTY,permissions); } @@ -407,8 +410,8 @@ //{{{ Permission preservation code - /** Code borrowed from j text editor (http://www.armedbear.org) */ - /** I made some changes to make it support suid, sgid and sticky files */ + /** Code jEdit borrowed from j text editor (http://www.armedbear.org) */ + /** Slava made some changes to make it support suid, sgid and sticky files */ //{{{ getPermissions() method /** @@ -418,7 +421,7 @@ public static int getPermissions(String path) { int permissions = 0; - if (jsXe.getBooleanProperty("chmodDisabled")) { + if (jsXe.getBooleanProperty("chmodDisabled", true)) { return permissions; } @@ -456,7 +459,7 @@ * does nothing. */ public static void setPermissions(String path, int permissions) { - if (jsXe.getBooleanProperty("chmodDisabled")) + if (jsXe.getBooleanProperty("chmodDisabled", true)) return; if (permissions != 0) { Modified: branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-09-02 15:59:17 UTC (rev 1227) +++ branches/jsxe2/src/net/sourceforge/jsxe/util/MiscUtilities.java 2006-09-02 16:17:37 UTC (rev 1228) @@ -29,6 +29,9 @@ //{{{ Imports import net.sourceforge.jsxe.OperatingSystem; +import net.sourceforge.jsxe.io.*; +import net.sourceforge.jsxe.jsXe; + import javax.swing.text.Segment; import java.io.*; import java.util.*; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-09-02 19:21:12
|
Revision: 1231 http://svn.sourceforge.net/jsxe/?rev=1231&view=rev Author: ian_lewis Date: 2006-09-02 12:20:52 -0700 (Sat, 02 Sep 2006) Log Message: ----------- Resolved compile problems dom2 and io packages now compile Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java branches/jsxe2/src/net/sourceforge/jsxe/JARClassLoader.java branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java 2006-09-02 17:49:07 UTC (rev 1230) +++ branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java 2006-09-02 19:20:52 UTC (rev 1231) @@ -474,6 +474,7 @@ static { m_excludeKeys = new ArrayList(); m_excludeKeys.add(DocumentBuffer.LINE_SEPARATOR); + m_excludeKeys.add("xmldocument.dirty"); } //}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/JARClassLoader.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/JARClassLoader.java 2006-09-02 17:49:07 UTC (rev 1230) +++ branches/jsxe2/src/net/sourceforge/jsxe/JARClassLoader.java 2006-09-02 19:20:52 UTC (rev 1231) @@ -99,43 +99,46 @@ */ protected Class findClass(String name) throws ClassNotFoundException { - String classFileName = name.replace('.','/').concat(".class"); - Iterator jarItr = m_jarFiles.values().iterator(); + synchronized(this) { - while (jarItr.hasNext()) { - try { - - JarFile zipFile = (JarFile)jarItr.next(); - ZipEntry entry = zipFile.getEntry(classFileName); - - if (entry != null) { + String classFileName = name.replace('.','/').concat(".class"); + Iterator jarItr = m_jarFiles.values().iterator(); + + while (jarItr.hasNext()) { + try { - InputStream in = zipFile.getInputStream(entry); + JarFile zipFile = (JarFile)jarItr.next(); + ZipEntry entry = zipFile.getEntry(classFileName); - boolean fail = false; - int len = (int)entry.getSize(); - byte[] data = new byte[len]; - int success = 0; - int offset = 0; - - while(success < len && !fail) { - len -= success; - offset += success; + if (entry != null) { - success = in.read(data,offset,len); - if(success == -1) { - fail = true; + InputStream in = zipFile.getInputStream(entry); + + boolean fail = false; + int len = (int)entry.getSize(); + byte[] data = new byte[len]; + int success = 0; + int offset = 0; + + while(success < len && !fail) { + len -= success; + offset += success; + + success = in.read(data,offset,len); + if(success == -1) { + fail = true; + } } + Class c = defineClass(name,data,0,data.length); + return c; } - Class c = defineClass(name,data,0,data.length); - return c; + + } catch(IOException io) { + //failed, try the next jar } - - } catch(IOException io) { - //failed, try the next jar } + throw new ClassNotFoundException(name); } - throw new ClassNotFoundException(name); }//}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 17:49:07 UTC (rev 1230) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom2/ls/XMLDocumentIORequest.java 2006-09-02 19:20:52 UTC (rev 1231) @@ -222,7 +222,7 @@ } read(autodetect(in),length,false); - buffer.setNewFile(false); + // buffer.setNewFile(false); } catch(CharConversionException ch) { Log.log(Log.ERROR,this,ch); @@ -622,7 +622,7 @@ String savePath; boolean twoStageSave = (vfs.getCapabilities() & VFS.RENAME_CAP) != 0 - && jsXe.getBooleanProperty("twoStageSave"); + && jsXe.getBooleanProperty("twoStageSave", false); if(twoStageSave) savePath = vfs.getTwoStageSaveName(path); else @@ -727,8 +727,7 @@ { //buffer.readLock(); - if(!buffer.isDirty()) - { + if(!buffer.getBooleanProperty("xmldocument.dirty", false)) { // buffer has been saved while we // were waiting. return; @@ -820,9 +819,9 @@ //{{{ write() private void write(XMLDocument buffer, OutputStream out) throws IOException { - String newLine = getProperty(XMLDocument.LINE_SEPARATOR); + String newLine = buffer.getProperty(XMLDocument.LINE_SEPARATOR); - String encoding = getProperty(XMLDocument.ENCODING); + String encoding = buffer.getProperty(XMLDocument.ENCODING); if (encoding.equals(MiscUtilities.UTF_8_Y)) { // not supported by Java... out.write(UTF8_MAGIC_1); Modified: branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-09-02 17:49:07 UTC (rev 1230) +++ branches/jsxe2/src/net/sourceforge/jsxe/io/VFSManager.java 2006-09-02 19:20:52 UTC (rev 1231) @@ -29,6 +29,7 @@ //{{{ jsXe classes import net.sourceforge.jsxe.jsXe; +import net.sourceforge.jsxe.JARClassLoader; import net.sourceforge.jsxe.EditBus; import net.sourceforge.jsxe.gui.Messages; import net.sourceforge.jsxe.gui.ErrorListDialog; @@ -78,7 +79,7 @@ /** * The service type. See {@link org.gjt.sp.jedit.ServiceManager}. */ - public static final String SERVICE = "net.sourceforge.jsxe.io.VFS"; + // public static final String SERVICE = "net.sourceforge.jsxe.io.VFS"; //{{{ init() method /** @@ -86,12 +87,13 @@ */ public static void init() { int count = jsXe.getIntegerProperty("ioThreadCount", 4); - ioThreadPool = new WorkThreadPool("jsXe I/O",count); - JARClassLoader classLoader = new JARClassLoader(); + ioThreadPool = new WorkThreadPool("jsXe I/O", count); + // JARClassLoader classLoader = new JARClassLoader(); + JARClassLoader classLoader = jsXe.getPluginLoader(); for (int i = 0; i < ioThreadPool.getThreadCount(); i++) { - ioThreadPool.getThread(i).setContextClassLoader( - classLoader); + ioThreadPool.getThread(i).setContextClassLoader(classLoader); } + } //}}} //{{{ start() method @@ -120,39 +122,26 @@ return urlVFS; } //}}} - //{{{ getVFSByName() method - /** - * @deprecated Use <code>getVFSForProtocol()</code> instead. - */ - public static VFS getVFSByName(String name) - { - // in new api, protocol always equals name - VFS vfs = (VFS)ServiceManager.getService(SERVICE,name); - if(vfs == null) - return (VFS)vfsHash.get(name); - else - return vfs; - } //}}} - //{{{ getVFSForProtocol() method /** * Returns the VFS for the specified protocol. * @param protocol The protocol */ - public static VFS getVFSForProtocol(String protocol) - { - if(protocol.equals("file")) + public static VFS getVFSForProtocol(String protocol) { + if (protocol.equals("file")) return fileVFS; - else - { - VFS vfs = (VFS)ServiceManager.getService(SERVICE,protocol); - if(vfs == null) - vfs = (VFS)protocolHash.get(protocol); + else { + // VFS vfs = (VFS)ServiceManager.getService(SERVICE,protocol); + // if (vfs == null) { + // vfs = (VFS)protocolHash.get(protocol); + // } + VFS vfs = (VFS)protocolHash.get(protocol); - if(vfs != null) + if (vfs != null) { return vfs; - else + } else { return urlVFS; + } } } //}}} @@ -170,12 +159,7 @@ } //}}} //{{{ registerVFS() method - /** - * @deprecated Write a <code>services.xml</code> file instead; - * see {@link org.gjt.sp.jedit.ServiceManager}. - */ - public static void registerVFS(String protocol, VFS vfs) - { + public static void registerVFS(String protocol, VFS vfs) { Log.log(Log.DEBUG,VFSManager.class,"Registered " + vfs.getName() + " filesystem for " + protocol + " protocol"); @@ -183,37 +167,24 @@ protocolHash.put(protocol,vfs); } //}}} - //{{{ getFilesystems() method - /** - * @deprecated Use <code>getVFSs()</code> instead. - */ - public static Enumeration getFilesystems() - { - return vfsHash.elements(); - } //}}} - //{{{ getVFSs() method /** * Returns a list of all registered filesystems. */ - public static String[] getVFSs() - { - // the sooner ppl move to the new api, the less we'll need - // crap like this + public static String[] getVFSs() { List returnValue = new LinkedList(); - String[] newAPI = ServiceManager.getServiceNames(SERVICE); - if(newAPI != null) - { - for(int i = 0; i < newAPI.length; i++) - { - returnValue.add(newAPI[i]); - } - } + // String[] newAPI = ServiceManager.getServiceNames(SERVICE); + // if(newAPI != null) + // { + // for(int i = 0; i < newAPI.length; i++) + // { + // returnValue.add(newAPI[i]); + // } + // } Enumeration oldAPI = vfsHash.keys(); while(oldAPI.hasMoreElements()) returnValue.add(oldAPI.nextElement()); - return (String[])returnValue.toArray(new String[ - returnValue.size()]); + return (String[])returnValue.toArray(new String[returnValue.size()]); } //}}} //}}} 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:21:07
|
Revision: 1238 http://svn.sourceforge.net/jsxe/?rev=1238&view=rev Author: ian_lewis Date: 2006-09-06 12:20:54 -0700 (Wed, 06 Sep 2006) Log Message: ----------- Moved serialization classes to net.sourceforge.jsxe.dom.ls Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java branches/jsxe2/src/net/sourceforge/jsxe/dom/AdapterNode.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java Added Paths: ----------- branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/ branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DOMOutput.java branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DefaultDOMLocator.java Removed Paths: ------------- branches/jsxe2/src/net/sourceforge/jsxe/dom/DOMOutput.java branches/jsxe2/src/net/sourceforge/jsxe/dom/DefaultDOMLocator.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java 2006-09-06 19:13:21 UTC (rev 1237) +++ branches/jsxe2/src/net/sourceforge/jsxe/BufferHistory.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -55,9 +55,9 @@ //}}} //{{{ jsXe classes -import net.sourceforge.jsxe.dom.DOMOutput; -import net.sourceforge.jsxe.dom.DOMSerializer; -import net.sourceforge.jsxe.dom.DOMSerializerConfiguration; +import net.sourceforge.jsxe.dom.ls.DOMOutput; +import net.sourceforge.jsxe.dom.ls.DOMSerializer; +import net.sourceforge.jsxe.dom.ls.DOMSerializerConfiguration; import net.sourceforge.jsxe.util.Log; //}}} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/AdapterNode.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/AdapterNode.java 2006-09-06 19:13:21 UTC (rev 1237) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/AdapterNode.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -33,6 +33,7 @@ import net.sourceforge.jsxe.util.MiscUtilities; import net.sourceforge.jsxe.dom.undo.*; import net.sourceforge.jsxe.dom.completion.*; +import net.sourceforge.jsxe.dom.ls.DOMSerializer; //}}} //{{{ Java Base Classes Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/DOMOutput.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/DOMOutput.java 2006-09-06 19:13:21 UTC (rev 1237) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/DOMOutput.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -1,129 +0,0 @@ -/* -DOMOutput.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2002 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -//{{{ imports - -//{{{ DOM classes -import org.w3c.dom.ls.LSOutput; -//}}} - -//{{{ Java classes -import java.io.OutputStream; -import java.io.Writer; -//}}} - -//}}} - -/** - * An implementation of the LSOutput interface for use with the DOMSerializer - * class. This object is used when generating locations into a document. - * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> - * @version $Id$ - * @see DOMSerializer - */ -public class DOMOutput implements LSOutput { - - //{{{ DOMOutput constructor - - public DOMOutput(OutputStream byteStream, String encoding) { - m_byteStream = byteStream; - m_encoding = encoding; - }//}}} - - //{{{ DOMOutput constructor - - public DOMOutput(String systemId, String encoding) { - m_systemId = systemId; - m_encoding = encoding; - }//}}} - - //{{{ DOMOutput constructor - - public DOMOutput(Writer characterStream) { - m_characterStream = characterStream; - }//}}} - - //{{{ Implemented LSOutput methods - - //{{{ getByteStream() - - public OutputStream getByteStream() { - return m_byteStream; - }//}}} - - //{{{ getCharacterStream() - - public Writer getCharacterStream() { - return m_characterStream; - }//}}} - - //{{{ getEncoding() - - public String getEncoding() { - return m_encoding; - }//}}} - - //{{{ getSystemId() - - public String getSystemId() { - return m_systemId; - }//}}} - - //{{{ getByteStream() - - public void setByteStream(OutputStream byteStream) { - m_byteStream = byteStream; - }//}}} - - //{{{ setCharacterStream() - - public void setCharacterStream(Writer characterStream) { - m_characterStream = characterStream; - }//}}} - - //{{{ setEncoding() - - public void setEncoding(String encoding) { - m_encoding = encoding; - }//}}} - - //{{{ setSystemId() - - public void setSystemId(String systemId) { - m_systemId = systemId; - }//}}} - - //}}} - - //{{{ Private members - - private OutputStream m_byteStream; - private Writer m_characterStream; - private String m_systemId; - private String m_encoding; - - //}}} -} Deleted: branches/jsxe2/src/net/sourceforge/jsxe/dom/DefaultDOMLocator.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/DefaultDOMLocator.java 2006-09-06 19:13:21 UTC (rev 1237) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/DefaultDOMLocator.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -1,111 +0,0 @@ -/* -DefaultDOMLocator.java -:tabSize=4:indentSize=4:noTabs=true: -:folding=explicit:collapseFolds=1: - -Copyright (C) 2002 Ian Lewis (Ian...@me...) - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -Optionally, you may find a copy of the GNU General Public License -from http://www.fsf.org/copyleft/gpl.txt -*/ - -package net.sourceforge.jsxe.dom; - -//{{{ imports -/* -All classes are listed explicitly so -it is easy to see which package it -belongs to. -*/ - -//{{{ DOM classes -import org.w3c.dom.Node; -import org.w3c.dom.DOMLocator; -//}}} - -//}}} - -public class DefaultDOMLocator implements DOMLocator { - - //{{{ DefaultDOMLocator constructor - - public DefaultDOMLocator() { - m_column = -1; - m_line = -1; - m_offset = -1; - }//}}} - - //{{{ DefaultDOMLocator constructor - - public DefaultDOMLocator(Node node, int lineno, int col, int byteOffset, String uri) { - m_line = lineno; - m_column = col; - m_errorNode = node; - m_offset = byteOffset; - m_uri = uri; - }//}}} - - //{{{ Implemented DOMLocator methods - - //{{{ getByteOffset() - - public int getByteOffset() { - return m_offset; - }//}}} - - //{{{ getColumnNumber() - - public int getColumnNumber() { - return m_column; - }//}}} - - //{{{ getRelatedNode() - - public Node getRelatedNode() { - return m_errorNode; - }//}}} - - //{{{ getLineNumber() - - public int getLineNumber() { - return m_line; - }//}}} - - //{{{ getUri() - - public String getUri() { - return m_uri; - }//}}} - - //{{{ getUtf16Offset() - - public int getUtf16Offset() { - //not sure how to approach the byte/UTF-16 offset stuff yet. - return -1; - }//}}} - - //}}} - - //{{{ Private members - - private int m_column; - private int m_line; - private int m_offset; - private Node m_errorNode; - private String m_uri; - - //}}} -} Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 19:13:21 UTC (rev 1237) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -35,6 +35,7 @@ import net.sourceforge.jsxe.util.MiscUtilities; import net.sourceforge.jsxe.dom.completion.*; import net.sourceforge.jsxe.dom.undo.*; +import net.sourceforge.jsxe.dom.ls.*; //}}} //{{{ DOM classes Copied: branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DOMOutput.java (from rev 1232, branches/jsxe2/src/net/sourceforge/jsxe/dom/DOMOutput.java) =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DOMOutput.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DOMOutput.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -0,0 +1,129 @@ +/* +DOMOutput.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom.ls; + +//{{{ imports + +//{{{ DOM classes +import org.w3c.dom.ls.LSOutput; +//}}} + +//{{{ Java classes +import java.io.OutputStream; +import java.io.Writer; +//}}} + +//}}} + +/** + * An implementation of the LSOutput interface for use with the DOMSerializer + * class. This object is used when generating locations into a document. + * @author <a href="mailto:IanLewis at member dot fsf dot org">Ian Lewis</a> + * @version $Id$ + * @see DOMSerializer + */ +public class DOMOutput implements LSOutput { + + //{{{ DOMOutput constructor + + public DOMOutput(OutputStream byteStream, String encoding) { + m_byteStream = byteStream; + m_encoding = encoding; + }//}}} + + //{{{ DOMOutput constructor + + public DOMOutput(String systemId, String encoding) { + m_systemId = systemId; + m_encoding = encoding; + }//}}} + + //{{{ DOMOutput constructor + + public DOMOutput(Writer characterStream) { + m_characterStream = characterStream; + }//}}} + + //{{{ Implemented LSOutput methods + + //{{{ getByteStream() + + public OutputStream getByteStream() { + return m_byteStream; + }//}}} + + //{{{ getCharacterStream() + + public Writer getCharacterStream() { + return m_characterStream; + }//}}} + + //{{{ getEncoding() + + public String getEncoding() { + return m_encoding; + }//}}} + + //{{{ getSystemId() + + public String getSystemId() { + return m_systemId; + }//}}} + + //{{{ getByteStream() + + public void setByteStream(OutputStream byteStream) { + m_byteStream = byteStream; + }//}}} + + //{{{ setCharacterStream() + + public void setCharacterStream(Writer characterStream) { + m_characterStream = characterStream; + }//}}} + + //{{{ setEncoding() + + public void setEncoding(String encoding) { + m_encoding = encoding; + }//}}} + + //{{{ setSystemId() + + public void setSystemId(String systemId) { + m_systemId = systemId; + }//}}} + + //}}} + + //{{{ Private members + + private OutputStream m_byteStream; + private Writer m_characterStream; + private String m_systemId; + private String m_encoding; + + //}}} +} Copied: branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DefaultDOMLocator.java (from rev 1232, branches/jsxe2/src/net/sourceforge/jsxe/dom/DefaultDOMLocator.java) =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DefaultDOMLocator.java (rev 0) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/ls/DefaultDOMLocator.java 2006-09-06 19:20:54 UTC (rev 1238) @@ -0,0 +1,111 @@ +/* +DefaultDOMLocator.java +:tabSize=4:indentSize=4:noTabs=true: +:folding=explicit:collapseFolds=1: + +Copyright (C) 2002 Ian Lewis (Ian...@me...) + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +Optionally, you may find a copy of the GNU General Public License +from http://www.fsf.org/copyleft/gpl.txt +*/ + +package net.sourceforge.jsxe.dom.ls; + +//{{{ imports +/* +All classes are listed explicitly so +it is easy to see which package it +belongs to. +*/ + +//{{{ DOM classes +import org.w3c.dom.Node; +import org.w3c.dom.DOMLocator; +//}}} + +//}}} + +public class DefaultDOMLocator implements DOMLocator { + + //{{{ DefaultDOMLocator constructor + + public DefaultDOMLocator() { + m_column = -1; + m_line = -1; + m_offset = -1; + }//}}} + + //{{{ DefaultDOMLocator constructor + + public DefaultDOMLocator(Node node, int lineno, int col, int byteOffset, String uri) { + m_line = lineno; + m_column = col; + m_errorNode = node; + m_offset = byteOffset; + m_uri = uri; + }//}}} + + //{{{ Implemented DOMLocator methods + + //{{{ getByteOffset() + + public int getByteOffset() { + return m_offset; + }//}}} + + //{{{ getColumnNumber() + + public int getColumnNumber() { + return m_column; + }//}}} + + //{{{ getRelatedNode() + + public Node getRelatedNode() { + return m_errorNode; + }//}}} + + //{{{ getLineNumber() + + public int getLineNumber() { + return m_line; + }//}}} + + //{{{ getUri() + + public String getUri() { + return m_uri; + }//}}} + + //{{{ getUtf16Offset() + + public int getUtf16Offset() { + //not sure how to approach the byte/UTF-16 offset stuff yet. + return -1; + }//}}} + + //}}} + + //{{{ Private members + + private int m_column; + private int m_line; + private int m_offset; + private Node m_errorNode; + private String m_uri; + + //}}} +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2006-09-07 00:11:21
|
Revision: 1247 http://svn.sourceforge.net/jsxe/?rev=1247&view=rev Author: ian_lewis Date: 2006-09-06 17:11:17 -0700 (Wed, 06 Sep 2006) Log Message: ----------- Updated XMLDocument property methods Modified Paths: -------------- branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java Modified: branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-09-07 00:10:46 UTC (rev 1246) +++ branches/jsxe2/src/net/sourceforge/jsxe/DocumentBuffer.java 2006-09-07 00:11:17 UTC (rev 1247) @@ -643,21 +643,21 @@ //}}} //{{{ format output - boolean formatOutput = Boolean.valueOf(getProperty(XMLDocument.FORMAT_XML, "false")).booleanValue(); + boolean formatOutput = getBooleanProperty(XMLDocument.FORMAT_XML); formatCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Format.XML"), formatOutput); addComponent(formatCheckBox, Messages.getMessage("Document.Options.Format.XML.ToolTip")); //}}} //{{{ validate - boolean validating = Boolean.valueOf(getProperty(XMLDocument.IS_VALIDATING, "false")).booleanValue(); + boolean validating = getBooleanProperty(XMLDocument.IS_VALIDATING); m_m_validatingCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Validate"), validating); addComponent(m_m_validatingCheckBox, Messages.getMessage("Document.Options.Validate.ToolTip")); //}}} //{{{ soft tabs - boolean softTabs = Boolean.valueOf(getProperty(XMLDocument.IS_USING_SOFT_TABS, "false")).booleanValue(); + boolean softTabs = getBooleanProperty(XMLDocument.IS_USING_SOFT_TABS); m_m_softTabsCheckBox = new JCheckBox(Messages.getMessage("Document.Options.Soft.Tabs"), softTabs); addComponent(m_m_softTabsCheckBox, Messages.getMessage("Document.Options.Soft.Tabs.ToolTip")); Modified: branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java =================================================================== --- branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-07 00:10:46 UTC (rev 1246) +++ branches/jsxe2/src/net/sourceforge/jsxe/dom/XMLDocument.java 2006-09-07 00:11:17 UTC (rev 1247) @@ -318,21 +318,11 @@ * @return the value of the property for the given key. */ public String getProperty(String key) { - return props.getProperty(key); + synchronized(propertyLock) { + return props.getProperty(key, jsXe.getProperty("xml.document." + key)); + } }//}}} - //{{{ getProperty() - /** - * Gets a property for the key given or returns the default value - * if there is no property for the given key. - * @param key the key to the properties list - * @param defaultValue the default value for the property requested - * @return the value of the property for the given key. - */ - public String getProperty(String key, String defaultValue) { - return props.getProperty(key, defaultValue); - }//}}} - //{{{ setProperty() /** * Sets a property of the XMLDocument This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |