Author: ruchithf
Date: Mon May 15 11:44:14 2006
New Revision: 406708

URL: http://svn.apache.org/viewcvs?rev=406708&view=rev
Log:
Preventing NPEs

Modified:
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/CharacterImpl.java
    
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/TextImpl.java

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/CharacterImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/CharacterImpl.java?rev=406708&r1=406707&r2=406708&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/CharacterImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/CharacterImpl.java
 Mon May 15 11:44:14 2006
@@ -40,7 +40,8 @@
 
        public CharacterImpl(DocumentImpl ownerNode, String value, OMFactory 
factory){
                super(ownerNode, factory);
-               this.textValue = new StringBuffer(value);
+        this.textValue = (value != null) ? new StringBuffer(value)
+                : new StringBuffer("");
        }
        
        ///
@@ -111,7 +112,7 @@
         * Inserts a string at the specified offset.
         */
        public void insertData(int offset, String data) throws DOMException {
-               int length = this.textValue.length();
+               int length = this.getLength();
                
                if (this.isReadonly()) {
                        throw new 
DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
@@ -136,7 +137,7 @@
         */
        public void setData(String data) throws DOMException {
                if (!this.isReadonly()) {
-                       this.textValue.replace(0,textValue.length(), data);
+                       this.textValue.replace(0,this.getLength(), data);
                } else {
                        throw new 
DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
                                        DOMMessageFormatter.formatMessage(
@@ -152,7 +153,7 @@
      * returned.
         */
        public String substringData(int offset, int count) throws DOMException {
-               if(offset < 0 || offset > this.textValue.length() || count < 0) 
{
+               if(offset < 0 || offset > this.getLength() || count < 0) {
                        throw new DOMException(DOMException.INDEX_SIZE_ERR,
                                        DOMMessageFormatter.formatMessage(
                                                        
DOMMessageFormatter.DOM_DOMAIN,
@@ -167,7 +168,7 @@
         * Returns the length of the string value.
         */
        public int getLength() {
-               return this.textValue.length();
+               return (this.textValue != null) ? this.textValue.length() : 0;
        }
                
 }

Modified: 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/TextImpl.java
URL: 
http://svn.apache.org/viewcvs/webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/TextImpl.java?rev=406708&r1=406707&r2=406708&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/TextImpl.java
 (original)
+++ 
webservices/commons/trunk/modules/axiom/src/org/apache/axiom/om/impl/dom/TextImpl.java
 Mon May 15 11:44:14 2006
@@ -83,7 +83,8 @@
      */
     public TextImpl(String text, OMFactory factory) {
         super(factory);
-        this.textValue = new StringBuffer(text);
+        this.textValue = (text != null) ? new StringBuffer(text)
+                : new StringBuffer("");
         this.done = true;
         this.ns = XOP_NS;
     }


Reply via email to