### Eclipse Workspace Patch 1.0 #P org.eclipse.wst.xml.core Index: src/org/eclipse/wst/xml/core/internal/document/TextImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/TextImpl.java,v retrieving revision 1.17 diff -u -r1.17 TextImpl.java --- src/org/eclipse/wst/xml/core/internal/document/TextImpl.java 16 Sep 2008 05:09:36 -0000 1.17 +++ src/org/eclipse/wst/xml/core/internal/document/TextImpl.java 5 Dec 2009 22:15:14 -0000 @@ -12,7 +12,7 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -20,6 +20,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText; import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator; @@ -90,7 +91,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } String newSource = getSource(arg); @@ -140,7 +141,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } TextImpl text = (TextImpl) newText; @@ -179,15 +180,15 @@ if (count == 0) return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (count < 0 || offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String source = getSource(); if (source == null || source.length() == 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } StringPair pair = substringSourceExcluded(source, offset, count); if (pair == null) @@ -204,7 +205,7 @@ source = second; } if (source == null) - source = new String(); // delete all + source = XMLCorePlugin.EMPTY_STRING; // delete all setTextSource(source); } @@ -226,7 +227,7 @@ */ private String getData(IStructuredDocumentRegion flatNode) { if (flatNode == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; if (flatNode instanceof StructuredDocumentRegionContainer) { StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode; @@ -430,16 +431,16 @@ if (arg == null || arg.length() == 0) return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String source = getSource(); if (source == null || source.length() == 0) { if (offset > 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } source = getSource(arg); if (source != null) @@ -511,20 +512,20 @@ if (newText == null) return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } TextImpl text = (TextImpl) newText; String newSource = text.getSource(); if (newSource == null || newSource.length() == 0) return; if (offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String source = getSource(); if (source == null || source.length() == 0) { if (offset > 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } setTextSource(newSource); return; @@ -737,7 +738,7 @@ */ public void replaceData(int offset, int count, String arg) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (arg == null || arg.length() == 0) { deleteData(offset, count); @@ -748,12 +749,12 @@ return; } if (offset < 0 || count < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String source = getSource(); if (source == null || source.length() == 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } StringPair pair = substringSourceExcluded(source, offset, count); @@ -852,7 +853,7 @@ */ public void setData(String data) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.fSource = null; @@ -863,7 +864,7 @@ */ public void setSource(String source) throws InvalidCharacterException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } SourceValidator validator = new SourceValidator(this); @@ -883,7 +884,7 @@ */ public void setTextSource(String source) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.fSource = source; @@ -895,7 +896,7 @@ */ public void setValueSource(String source) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } SourceValidator validator = new SourceValidator(this); @@ -911,14 +912,14 @@ */ public Text splitText(int offset) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = getLength(); if (offset > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } Document document = getOwnerDocument(); if (document == null) @@ -1005,17 +1006,17 @@ private String substringData(String data, int offset, int count) throws DOMException { // sure offset and count are non-negative if (count == 0) - return new String(); + return XMLCorePlugin.EMPTY_STRING; if (data == null) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = data.length(); if (offset > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int end = offset + count; if (end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } return data.substring(offset, end); } @@ -1033,7 +1034,7 @@ if (data != null && data.length() > 0) { data = substringData(data, offset, count); if (data == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; String source = getSource(data); if (source != null) return source; @@ -1049,9 +1050,9 @@ private String substringSource(String source, int offset, int count) throws DOMException { // sure offset and count are non-negative if (count == 0) - return new String(); + return XMLCorePlugin.EMPTY_STRING; if (source == null) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = source.length(); @@ -1079,7 +1080,7 @@ } if (offset > length || end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } return source.substring(offset, end); @@ -1094,7 +1095,7 @@ if (source == null) { if (offset == 0 && count == 0) return new StringPair(null, null); - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = source.length(); @@ -1122,7 +1123,7 @@ } if (offset > length || end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String first = (offset > 0 ? source.substring(0, offset) : null); Index: src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java,v retrieving revision 1.7 diff -u -r1.7 CharacterDataImpl.java --- src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java 26 Feb 2009 05:52:16 -0000 1.7 +++ src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java 5 Dec 2009 22:15:13 -0000 @@ -8,13 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.w3c.dom.CharacterData; import org.w3c.dom.DOMException; import org.w3c.dom.Node; @@ -78,33 +79,33 @@ if (count == 0) return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (count < 0 || offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String data = getData(); if (data == null) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = data.length(); if (offset > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (offset == 0) { if (count > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (count == length) - data = new String(); + data = XMLCorePlugin.EMPTY_STRING; else data = data.substring(count); } else { int end = offset + count; if (end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (end == length) data = data.substring(0, offset); @@ -166,17 +167,17 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (offset < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String data = getData(); if (data == null) { if (offset > 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } data = arg; } else if (offset == 0) { @@ -184,7 +185,7 @@ } else { int length = data.length(); if (offset > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (offset == length) data += arg; @@ -219,7 +220,7 @@ */ public void replaceData(int offset, int count, String arg) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (arg == null) { @@ -231,16 +232,16 @@ return; } if (offset < 0 || count < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String data = getData(); if (data == null) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } else if (offset == 0) { int length = data.length(); if (count > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (count == length) data = arg; @@ -250,7 +251,7 @@ int length = data.length(); int end = offset + count; if (end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } if (end == length) data = data.substring(0, offset) + arg; @@ -275,7 +276,7 @@ */ public void setData(String data) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.data = (data != null ? data.toCharArray() : null); @@ -312,24 +313,24 @@ */ public String substringData(int offset, int count) throws DOMException { if (count == 0) - return new String(); + return XMLCorePlugin.EMPTY_STRING; if (offset < 0 || count < 0) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } String data = getData(); if (data == null) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int length = data.length(); if (offset == 0 && count == length) return data; if (offset > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } int end = offset + count; if (end > length) { - throw new DOMException(DOMException.INDEX_SIZE_ERR, new String()); + throw new DOMException(DOMException.INDEX_SIZE_ERR, XMLCorePlugin.EMPTY_STRING); } return data.substring(offset, end); } Index: src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java,v retrieving revision 1.9 diff -u -r1.9 CommentImpl.java --- src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java 26 Feb 2009 05:52:16 -0000 1.9 +++ src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,7 +12,7 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -23,6 +23,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; import org.w3c.dom.Comment; import org.w3c.dom.DOMException; @@ -82,7 +83,7 @@ String sdata = getData(getStructuredDocumentRegion()); if (sdata != null) return sdata; - return new String(); + return XMLCorePlugin.EMPTY_STRING; } return new String(data); } @@ -185,7 +186,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } DocumentImpl document = (DocumentImpl) getOwnerDocument(); Index: src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java,v retrieving revision 1.5 diff -u -r1.5 EntityReferenceImpl.java --- src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java 10 Apr 2007 20:05:34 -0000 1.5 +++ src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,12 +12,13 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.w3c.dom.EntityReference; import org.w3c.dom.Node; import org.w3c.dom.UserDataHandler; @@ -70,7 +71,7 @@ */ public String getNodeName() { if (this.name == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.name; } Index: src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java,v retrieving revision 1.9 diff -u -r1.9 NodeContainer.java --- src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java 12 Aug 2009 15:07:40 -0000 1.9 +++ src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java 5 Dec 2009 22:15:14 -0000 @@ -8,13 +8,14 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; import org.w3c.dom.DOMException; import org.w3c.dom.Document; @@ -245,16 +246,16 @@ if (newChild == null) return null; // nothing to do if (refChild != null && refChild.getParentNode() != this) { - throw new DOMException(DOMException.NOT_FOUND_ERR, new String()); + throw new DOMException(DOMException.NOT_FOUND_ERR, XMLCorePlugin.EMPTY_STRING); } if (!isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (newChild == refChild) return newChild; // nothing to do //new child can not be a parent of this, would cause cycle if(isParent(newChild)) { - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) { @@ -372,11 +373,11 @@ if (oldChild == null) return null; if (oldChild.getParentNode() != this) { - throw new DOMException(DOMException.NOT_FOUND_ERR, new String()); + throw new DOMException(DOMException.NOT_FOUND_ERR, XMLCorePlugin.EMPTY_STRING); } if (!isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } // synchronized in case another thread is getting item, or length @@ -412,7 +413,7 @@ */ public void removeChildNodes() { if (!isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } Node nextChild = null; @@ -435,7 +436,7 @@ if (!hasChildNodes()) return null; if (!isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } Document document = null; @@ -476,7 +477,7 @@ */ public Node replaceChild(Node newChild, Node oldChild) throws DOMException { if (!isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (oldChild == null) Index: src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java,v retrieving revision 1.8 diff -u -r1.8 EntityImpl.java --- src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java 10 Apr 2007 20:05:34 -0000 1.8 +++ src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,12 +12,13 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.w3c.dom.DOMException; import org.w3c.dom.Entity; import org.w3c.dom.Node; @@ -93,7 +94,7 @@ */ public String getNodeName() { if (this.name == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.name; } @@ -182,7 +183,7 @@ */ public void setNotationName(String notationName) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.notationName = notationName; @@ -196,7 +197,7 @@ */ public void setPublicId(String publicId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.publicId = publicId; @@ -210,7 +211,7 @@ */ public void setSystemId(String systemId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.systemId = systemId; Index: src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java,v retrieving revision 1.9 diff -u -r1.9 DocumentTypeImpl.java --- src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java 10 Apr 2007 20:05:34 -0000 1.9 +++ src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,13 +12,14 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType; import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; import org.w3c.dom.DOMException; @@ -93,7 +94,7 @@ */ public String getName() { if (this.name == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.name; } @@ -156,7 +157,7 @@ */ public void setInternalSubset(String internalSubset) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.internalSubset = internalSubset; @@ -180,7 +181,7 @@ */ public void setPublicId(String publicId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.publicId = publicId; @@ -196,7 +197,7 @@ */ public void setSystemId(String systemId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.systemId = systemId; Index: src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java,v retrieving revision 1.8 diff -u -r1.8 ProcessingInstructionImpl.java --- src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java 10 Apr 2007 20:05:34 -0000 1.8 +++ src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java 5 Dec 2009 22:15:14 -0000 @@ -12,7 +12,7 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -23,6 +23,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; import org.w3c.dom.DOMException; import org.w3c.dom.Node; @@ -84,10 +85,10 @@ IStructuredDocumentRegion flatNode = getFirstStructuredDocumentRegion(); if (flatNode == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; ITextRegionList regions = flatNode.getRegions(); if (regions == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; ITextRegion targetRegion = null; ITextRegion dataRegion = null; @@ -109,7 +110,7 @@ } } if (dataRegion == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; int offset = dataRegion.getStart(); int end = flatNode.getLength(); if (closeRegion != null) @@ -152,7 +153,7 @@ */ public String getTarget() { if (this.target == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.target; } @@ -181,7 +182,7 @@ */ public void setData(String data) throws DOMException { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.data = data; Index: src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java,v retrieving revision 1.28 diff -u -r1.28 AttrImpl.java --- src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java 20 Oct 2009 20:13:42 -0000 1.28 +++ src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,6 +12,8 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 + * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -24,6 +26,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; @@ -44,6 +47,7 @@ * AttrImpl class */ public class AttrImpl extends NodeImpl implements IDOMAttr { + private ITextRegion equalRegion = null; private char[] fName = null; @@ -151,7 +155,7 @@ */ public String getName() { if (this.fName == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return new String(this.fName); } @@ -346,7 +350,7 @@ */ private String getValue(String source) { if (source == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; if (source.length() == 0) return source; StringBuffer buffer = null; @@ -440,7 +444,7 @@ return null; if (this.fValueRegion != null) return StructuredDocumentRegionUtil.getAttrValue(ownerRegion, this.fValueRegion); - return new String(); + return XMLCorePlugin.EMPTY_STRING; } private String getValueSource(ElementImpl ownerElement) { @@ -453,7 +457,7 @@ // the flatnode that this.valueRegion belongs to. if (this.fValueRegion != null) return StructuredDocumentRegionUtil.getAttrValue(ownerElement.getStructuredDocumentRegion(), this.fValueRegion); - return new String(); + return XMLCorePlugin.EMPTY_STRING; } /** @@ -704,7 +708,7 @@ */ public void setPrefix(String prefix) throws DOMException { if (this.ownerElement != null && !this.ownerElement.isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } int prefixLength = (prefix != null ? prefix.length() : 0); String localName = getLocalName(); @@ -713,7 +717,7 @@ return; } if (localName == null) - localName = new String(); + localName = XMLCorePlugin.EMPTY_STRING; int localLength = localName.length(); StringBuffer buffer = new StringBuffer(prefixLength + 1 + localLength); buffer.append(prefix); @@ -756,7 +760,7 @@ public void setValueSource(String source) { if (this.ownerElement != null && !this.ownerElement.isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.fValueSource = (source != null) ? source.toCharArray() : null; Index: src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java,v retrieving revision 1.8 diff -u -r1.8 CDATASectionImpl.java --- src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java 26 Feb 2009 05:52:16 -0000 1.8 +++ src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java 5 Dec 2009 22:15:13 -0000 @@ -13,6 +13,7 @@ * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -23,6 +24,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext; import org.w3c.dom.CDATASection; import org.w3c.dom.DOMException; @@ -77,7 +79,7 @@ String sdata = getData(getStructuredDocumentRegion()); if (sdata != null) return sdata; - return new String(); + return XMLCorePlugin.EMPTY_STRING; } return new String(data); } Index: src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java,v retrieving revision 1.26 diff -u -r1.26 ElementImpl.java --- src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java 23 Nov 2009 20:16:19 -0000 1.26 +++ src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java 5 Dec 2009 22:15:13 -0000 @@ -14,7 +14,7 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -27,6 +27,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter; import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; @@ -174,7 +175,7 @@ return null; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (this.attrNodes == null) @@ -241,7 +242,7 @@ // In the absence of the attribute, get the default value if (attr == null) { String defaultValue = getDefaultValue(name); - return (defaultValue != null) ? defaultValue : new String(); + return (defaultValue != null) ? defaultValue : XMLCorePlugin.EMPTY_STRING; } return attr.getValue(); } @@ -258,7 +259,7 @@ if (attribute instanceof CMAttributeDeclaration) return ((CMAttributeDeclaration) attribute).getAttrType().getImpliedValue(); } - return new String(); + return XMLCorePlugin.EMPTY_STRING; } /** @@ -327,7 +328,7 @@ // In the absence of the attribute, get the default value if (attr == null) { String defaultValue = getDefaultValue(name); - return (defaultValue != null) ? defaultValue : new String(); + return (defaultValue != null) ? defaultValue : XMLCorePlugin.EMPTY_STRING; } return attr.getValue(); } @@ -614,7 +615,7 @@ */ public String getTagName() { if (this.fTagName == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return new String(fTagName); } @@ -706,13 +707,13 @@ if (newChild == null) return null; if (!isContainer()) { // never be container - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } if (newChild.getNodeType() != TEXT_NODE) { if (isJSPContainer() || isCDATAContainer()) { // accepts only // Text // child - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } } return super.insertBefore(newChild, refChild); @@ -1017,11 +1018,11 @@ return null; // invalid parameter if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (this.attrNodes == null) { // no attribute - throw new DOMException(DOMException.NOT_FOUND_ERR, new String()); + throw new DOMException(DOMException.NOT_FOUND_ERR, XMLCorePlugin.EMPTY_STRING); } int length = this.attrNodes.getLength(); @@ -1039,7 +1040,7 @@ } // not found - throw new DOMException(DOMException.NOT_FOUND_ERR, new String()); + throw new DOMException(DOMException.NOT_FOUND_ERR, XMLCorePlugin.EMPTY_STRING); } /** @@ -1056,7 +1057,7 @@ return null; // no attribute if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } int length = this.attrNodes.getLength(); @@ -1087,7 +1088,7 @@ return null; // no attribute if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } int length = this.attrNodes.getLength(); @@ -1133,7 +1134,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } int length = this.attrNodes.getLength(); @@ -1210,7 +1211,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } Attr attr = getAttributeNode(name); @@ -1242,7 +1243,7 @@ return null; // nothing to do if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } AttrImpl attr = (AttrImpl) newAttr; @@ -1250,7 +1251,7 @@ if (owner != null) { if (owner == this) return null; // nothing to do - throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, new String()); + throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, XMLCorePlugin.EMPTY_STRING); } Attr oldAttr = removeAttributeNode(newAttr.getName()); @@ -1265,7 +1266,7 @@ return null; // nothing to do if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } AttrImpl attr = (AttrImpl) newAttr; @@ -1273,7 +1274,7 @@ if (owner != null) { if (owner == this) return null; // nothing to do - throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, new String()); + throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, XMLCorePlugin.EMPTY_STRING); } String name = newAttr.getLocalName(); @@ -1291,7 +1292,7 @@ return; if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=139552 @@ -1322,7 +1323,7 @@ public void setCommentTag(boolean isCommentTag) { IDOMNode parent = (IDOMNode) getParentNode(); if (parent != null && !parent.isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (isCommentTag) @@ -1340,7 +1341,7 @@ public void setEmptyTag(boolean isEmptyTag) { IDOMNode parent = (IDOMNode) getParentNode(); if (parent != null && !parent.isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (isEmptyTag) @@ -1372,7 +1373,7 @@ public void setJSPTag(boolean isJSPTag) { IDOMNode parent = (IDOMNode) getParentNode(); if (parent != null && !parent.isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } if (isJSPTag) @@ -1410,7 +1411,7 @@ public void setPrefix(String prefix) throws DOMException { IDOMNode parent = (IDOMNode) getParentNode(); if (parent != null && !parent.isChildEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } int prefixLength = (prefix != null ? prefix.length() : 0); Index: src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java,v retrieving revision 1.5 diff -u -r1.5 NotationImpl.java --- src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java 10 Apr 2007 20:05:34 -0000 1.5 +++ src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java 5 Dec 2009 22:15:14 -0000 @@ -12,12 +12,13 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.w3c.dom.DOMException; import org.w3c.dom.Node; import org.w3c.dom.Notation; @@ -75,7 +76,7 @@ */ public String getNodeName() { if (this.name == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.name; } @@ -124,7 +125,7 @@ */ public void setPublicId(String publicId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.publicId = publicId; } @@ -137,7 +138,7 @@ */ public void setSystemId(String systemId) { if (!isDataEditable()) { - throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String()); + throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, XMLCorePlugin.EMPTY_STRING); } this.systemId = systemId; } Index: src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java,v retrieving revision 1.11 diff -u -r1.11 XMLModelUpdater.java --- src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java 19 Aug 2009 21:38:21 -0000 1.11 +++ src/org/eclipse/wst/xml/core/internal/document/XMLModelUpdater.java 5 Dec 2009 22:15:15 -0000 @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -23,6 +23,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator; @@ -82,7 +83,7 @@ String name = attr.getName(); if (name == null) - name = new String(); + name = XMLCorePlugin.EMPTY_STRING; ITextRegion nameRegion = attr.getNameRegion(); if (nameRegion == null) return; // error @@ -140,7 +141,7 @@ value = this.generator.generateAttrValue(attr, quote); if (value == null) { - value = new String(); + value = XMLCorePlugin.EMPTY_STRING; // remove equal too ITextRegion equalRegion = attr.getEqualRegion(); if (equalRegion != null) @@ -160,7 +161,7 @@ if (value == null) { if (equalRegion == null) return; // nothng to do - value = new String(); + value = XMLCorePlugin.EMPTY_STRING; // remove equal start += equalRegion.getStart(); end += equalRegion.getTextEnd(); @@ -525,7 +526,7 @@ String source = this.generator.generateSource(text); if (source == null) - source = new String(); + source = XMLCorePlugin.EMPTY_STRING; int length = source.length(); TextImpl impl = (TextImpl) text; @@ -607,7 +608,7 @@ String source = this.generator.generateSource(node); if (source == null) - source = new String(); + source = XMLCorePlugin.EMPTY_STRING; int length = source.length(); NodeImpl impl = (NodeImpl) node; @@ -1488,7 +1489,7 @@ else { String content = this.generator.generateSource(node); if (content == null) - content = new String(); + content = XMLCorePlugin.EMPTY_STRING; int length = content.length(); IStructuredDocumentRegion flatNode = null; if (length > 0) { @@ -1590,7 +1591,7 @@ private void replaceSource(String source, int start, int end) { int inserted = 0; if (source == null) - source = new String(); + source = XMLCorePlugin.EMPTY_STRING; else inserted = source.length(); int removed = end - start; Index: src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java,v retrieving revision 1.11 diff -u -r1.11 StructuredDocumentRegionProxy.java --- src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java 10 Apr 2007 20:05:34 -0000 1.11 +++ src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionProxy.java 5 Dec 2009 22:15:14 -0000 @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -20,6 +20,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; class StructuredDocumentRegionProxy implements IStructuredDocumentRegion { @@ -216,10 +217,10 @@ */ public String getText() { if (this.flatNode == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; String text = this.flatNode.getText(); if (text == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; int end = this.offset + this.length; return text.substring(this.offset, end); } Index: src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java,v retrieving revision 1.11 diff -u -r1.11 StructuredDocumentRegionContainer.java --- src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java 10 Apr 2007 20:05:34 -0000 1.11 +++ src/org/eclipse/wst/xml/core/internal/document/StructuredDocumentRegionContainer.java 5 Dec 2009 22:15:14 -0000 @@ -8,7 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -22,6 +22,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; class StructuredDocumentRegionContainer implements IStructuredDocumentRegion { @@ -238,7 +239,7 @@ public String getText() { int size = this.flatNodes.size(); if (size == 0) - return new String(); + return XMLCorePlugin.EMPTY_STRING; StringBuffer buffer = new StringBuffer(); for (int i = 0; i < size; i++) { IStructuredDocumentRegion flatNode = (IStructuredDocumentRegion) this.flatNodes.elementAt(i); Index: src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java,v retrieving revision 1.29 diff -u -r1.29 DocumentImpl.java --- src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java 14 Oct 2009 23:29:20 -0000 1.29 +++ src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java 5 Dec 2009 22:15:13 -0000 @@ -12,7 +12,7 @@ * * Balazs Banfai: Bug 154737 getUserData/setUserData support for Node * https://bugs.eclipse.org/bugs/show_bug.cgi?id=154737 - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -28,6 +28,7 @@ import org.apache.xerces.dom.TreeWalkerImpl; import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementRegistry; import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; @@ -335,7 +336,7 @@ public Element createCommentElement(String tagName, boolean isJSPTag) throws DOMException { Element result = null; if (!isJSPType() && isJSPTag) { - throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, new String()); + throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, XMLCorePlugin.EMPTY_STRING); } ElementImpl element = (ElementImpl) createElement(tagName); element.setJSPTag(isJSPTag); @@ -344,7 +345,7 @@ result = element; } else { - throw new DOMException(DOMException.INVALID_CHARACTER_ERR, new String()); + throw new DOMException(DOMException.INVALID_CHARACTER_ERR, XMLCorePlugin.EMPTY_STRING); } return result; } @@ -394,7 +395,7 @@ */ public Element createElementNS(String uri, String tagName) throws DOMException { if (!isValidName(tagName)) { - throw new DOMException(DOMException.INVALID_CHARACTER_ERR, new String()); + throw new DOMException(DOMException.INVALID_CHARACTER_ERR, XMLCorePlugin.EMPTY_STRING); } ElementImpl element = (ElementImpl) createElement(tagName); @@ -425,7 +426,7 @@ */ public EntityReference createEntityReference(String name) throws DOMException { if (!isXMLType()) { - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, new String()); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, XMLCorePlugin.EMPTY_STRING); } EntityReferenceImpl ref = new EntityReferenceImpl(); Index: src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java,v retrieving revision 1.22 diff -u -r1.22 NodeImpl.java --- src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java 24 Nov 2009 02:57:06 -0000 1.22 +++ src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java 5 Dec 2009 22:15:14 -0000 @@ -15,6 +15,7 @@ * * David Carver (STAR) - bug 295127 - implement isSameNode and compareDocumentPosition methods. * Unit Tests covered in wst.xsl XPath 2.0 tests. + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.document; @@ -30,6 +31,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; import org.w3c.dom.DOMException; @@ -96,7 +98,7 @@ * org.w3c.dom.Node */ public Node appendChild(Node newChild) throws DOMException { - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } /** @@ -422,7 +424,7 @@ */ public String getSource() { if (this.flatNode == null) - return new String(); + return XMLCorePlugin.EMPTY_STRING; return this.flatNode.getText(); } @@ -519,7 +521,7 @@ * org.w3c.dom.Node */ public Node insertBefore(Node newChild, Node refChild) throws DOMException { - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } public boolean isChildEditable() { @@ -575,7 +577,7 @@ break; default : - result = new String(); + result = XMLCorePlugin.EMPTY_STRING; break; } return result; @@ -646,7 +648,7 @@ * org.w3c.dom.Node */ public Node removeChild(Node oldChild) throws DOMException { - throw new DOMException(DOMException.NOT_FOUND_ERR, new String()); + throw new DOMException(DOMException.NOT_FOUND_ERR, XMLCorePlugin.EMPTY_STRING); } /** @@ -678,7 +680,7 @@ * org.w3c.dom.Node */ public Node replaceChild(Node newChild, Node oldChild) throws DOMException { - throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String()); + throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, XMLCorePlugin.EMPTY_STRING); } /** @@ -848,7 +850,7 @@ */ public short compareDocumentPosition(Node other) throws DOMException { if (!(other instanceof IDOMNode)) - throw new DOMException(DOMException.NOT_SUPPORTED_ERR, new String()); + throw new DOMException(DOMException.NOT_SUPPORTED_ERR, XMLCorePlugin.EMPTY_STRING); int nodeStart = this.getStartOffset(); int otherStart = ((IDOMNode) other).getStartOffset(); Index: src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java,v retrieving revision 1.11 diff -u -r1.11 XMLCorePlugin.java --- src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java 10 Apr 2007 20:05:35 -0000 1.11 +++ src/org/eclipse/wst/xml/core/internal/XMLCorePlugin.java 5 Dec 2009 22:15:13 -0000 @@ -29,6 +29,7 @@ public static final String USER_CATALOG_ID = "user_catalog"; //$NON-NLS-1$ public static final String DEFAULT_CATALOG_ID = "default_catalog"; //$NON-NLS-1$ public static final String SYSTEM_CATALOG_ID = "system_catalog"; //$NON-NLS-1$ + public static final String EMPTY_STRING = ""; private CatalogSet catalogSet = null; private String defaultCatalogFileStateLocation; Index: src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java,v retrieving revision 1.5 diff -u -r1.5 CommentNodeFormatter.java --- src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java 27 Mar 2007 21:37:10 -0000 1.5 +++ src/org/eclipse/wst/xml/core/internal/provisional/format/CommentNodeFormatter.java 5 Dec 2009 22:15:15 -0000 @@ -8,12 +8,13 @@ * Contributors: * IBM Corporation - initial API and implementation * Jens Lukowski/Innoopract - initial renaming/restructuring - * + * David Carver (STAR) - bug 296999 - Inefficient use of new String() *******************************************************************************/ package org.eclipse.wst.xml.core.internal.provisional.format; import org.eclipse.wst.sse.core.internal.format.IStructuredFormatContraints; import org.eclipse.wst.sse.core.utils.StringUtils; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; import org.w3c.dom.Node; @@ -23,7 +24,7 @@ static private final String LF = "\n"; //$NON-NLS-1$ protected String adjustIndentations(String aString, String lineIndent, String singleIndent) { - String result = new String(); + String result = XMLCorePlugin.EMPTY_STRING; int indexOfLineDelimiter = StringUtils.indexOfLineDelimiter(aString); result = aString.substring(0, indexOfLineDelimiter); Index: src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java =================================================================== RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java,v retrieving revision 1.10 diff -u -r1.10 ElementNodeFormatter.java --- src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java 20 Feb 2008 19:00:28 -0000 1.10 +++ src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java 5 Dec 2009 22:15:15 -0000 @@ -21,6 +21,7 @@ import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; import org.eclipse.wst.sse.core.utils.StringUtils; import org.eclipse.wst.xml.core.internal.Logger; +import org.eclipse.wst.xml.core.internal.XMLCorePlugin; import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; @@ -404,7 +405,7 @@ } protected String getUndefinedRegions(IDOMNode node, int startOffset, int length) { - String result = new String(); + String result = XMLCorePlugin.EMPTY_STRING; IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion(); ITextRegionList regions = flatNode.getRegions();