neilg       2002/07/24 12:08:42

  Modified:    java/src/org/apache/xerces/dom DOMImplementationImpl.java
                        DocumentImpl.java ElementImpl.java
                        ElementNSImpl.java NamedNodeMapImpl.java
  Log:
  DOM error message localization.
  
  Revision  Changes    Path
  1.24      +8 -8      
xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java
  
  Index: DOMImplementationImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- DOMImplementationImpl.java        3 Apr 2002 23:48:26 -0000       1.23
  +++ DOMImplementationImpl.java        24 Jul 2002 19:08:41 -0000      1.24
  @@ -163,16 +163,16 @@
                                                    String systemID)
       {
        if (!CoreDocumentImpl.isXMLName(qualifiedName)) {
  -             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 
  -                                        "DOM002 Illegal character");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"INVALID_CHARACTER_ERR", null);
  +             throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
           }
           int index = qualifiedName.indexOf(':');
           int lastIndex = qualifiedName.lastIndexOf(':');
           // it is an error for NCName to have more than one ':'
           if (index == 0 || index == qualifiedName.length() - 1 || lastIndex!=index) {
  -         throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                    "DOM003 Namespace error");
  -     }
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +             throw new DOMException(DOMException.NAMESPACE_ERR, msg);
  +         }
        return new DocumentTypeImpl(null, qualifiedName, publicID, systemID);
       }
       /**
  @@ -201,8 +201,8 @@
                                                throws DOMException
       {
        if (doctype != null && doctype.getOwnerDocument() != null) {
  -            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
  -                                   "DOM005 Wrong document");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
           }
           DocumentImpl doc = new DocumentImpl(doctype);
           Element e = doc.createElementNS( namespaceURI, qualifiedName);
  
  
  
  1.74      +11 -9     xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java
  
  Index: DocumentImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DocumentImpl.java,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- DocumentImpl.java 20 Jun 2002 01:29:05 -0000      1.73
  +++ DocumentImpl.java 24 Jul 2002 19:08:41 -0000      1.74
  @@ -307,8 +307,8 @@
                                          boolean entityReferenceExpansion)
       {
        if (root == null) {
  -            throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
  -                                   "DOM007 Not supported");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", 
null);
  +            throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
           }
           return new TreeWalkerImpl(root, whatToShow, filter,
                                     entityReferenceExpansion);
  @@ -452,9 +452,10 @@
            if (type.equalsIgnoreCase("MutationEvents") ||
                   "MutationEvent".equals(type))
                return new MutationEventImpl();
  -         else
  -             throw new DOMException(DOMException.NOT_SUPPORTED_ERR,
  -                                        "DOM007 Not supported");
  +         else {
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_SUPPORTED_ERR", 
null);
  +             throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
  +        }
        }
   
       /**
  @@ -696,9 +697,10 @@
   
           // VALIDATE -- must have been initialized at least once, must have
           // a non-null non-blank name.
  -        if(!evt.initialized || evt.type == null || evt.type.equals(""))
  -            throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR,
  -                                     "DOM010 Unspecified event type");
  +        if(!evt.initialized || evt.type == null || evt.type.equals("")) {
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"UNSPECIFIED_EVENT_TYPE_ERR", null);
  +            throw new EventException(EventException.UNSPECIFIED_EVENT_TYPE_ERR, 
msg);
  +        }
           
           // If nobody is listening for this event, discard immediately
           LCount lc = LCount.lookup(evt.getType());
  
  
  
  1.50      +26 -23    xml-xerces/java/src/org/apache/xerces/dom/ElementImpl.java
  
  Index: ElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementImpl.java,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- ElementImpl.java  20 Jun 2002 01:29:05 -0000      1.49
  +++ ElementImpl.java  24 Jul 2002 19:08:41 -0000      1.50
  @@ -392,8 +392,8 @@
       public void removeAttribute(String name) {
   
        if (ownerDocument.errorChecking && isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                   "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
                
           if (needsSyncData()) {
  @@ -429,8 +429,8 @@
           throws DOMException {
   
        if (ownerDocument.errorChecking && isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                   "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
                
           if (needsSyncData()) {
  @@ -438,8 +438,8 @@
           }
   
           if (attributes == null) {
  -            throw new DOMException(DOMException.NOT_FOUND_ERR, 
  -                                       "DOM008 Not found");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", 
null);
  +            throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
           }
           return (Attr) attributes.removeItem(oldAttr, true);
   
  @@ -468,8 +468,8 @@
       public void setAttribute(String name, String value) {
   
        if (ownerDocument.errorChecking && isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                   "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
   
           if (needsSyncData()) {
  @@ -516,14 +516,15 @@
   
        if (ownerDocument.errorChecking) {
               if (isReadOnly()) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
                   throw new DOMException(
                                        DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                     "DOM001 Modification not allowed");
  +                                     msg);
               }
        
               if (newAttr.getOwnerDocument() != ownerDocument) {
  -             throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
  -                                       "DOM005 Wrong document");
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +                 throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
               }
           }
   
  @@ -612,8 +613,8 @@
       public void setAttributeNS(String namespaceURI, String qualifiedName, String 
value) {
   
        if (ownerDocument.errorChecking && isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                   "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
   
           if (needsSyncData()) {
  @@ -665,8 +666,8 @@
       public void removeAttributeNS(String namespaceURI, String localName) {
   
        if (ownerDocument.errorChecking && isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                   "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
                
           if (needsSyncData()) {
  @@ -740,13 +741,14 @@
           }
           if (ownerDocument.errorChecking) {
               if (isReadOnly()) {
  -             throw new DOMException(
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +                 throw new DOMException(
                                        DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                     "DOM001 Modification not allowed");
  +                                     msg);
               }
               if (newAttr.getOwnerDocument() != ownerDocument) {
  -                throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
  -                                       "DOM005 Wrong document");
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +                throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
               }
           }
   
  @@ -881,14 +883,15 @@
           }
        if (ownerDocument.errorChecking) {
               if (isReadOnly()) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
                   throw new DOMException(
                                        DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                     "DOM001 Modification not allowed");
  +                                     msg);
               }
        
               if (at.getOwnerElement() != this) {
  -                throw new DOMException(DOMException.NOT_FOUND_ERR, 
  -                                       "DOM008 Not found");
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", 
null);
  +                throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
               }
           }
           ((AttrImpl) at).isIdAttribute(true);
  
  
  
  1.24      +17 -16    xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java
  
  Index: ElementNSImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ElementNSImpl.java        20 Jun 2002 01:29:05 -0000      1.23
  +++ ElementNSImpl.java        24 Jul 2002 19:08:41 -0000      1.24
  @@ -125,19 +125,19 @@
           
               if (ownerDocument.errorChecking) {
                   if (this.namespaceURI == null
  -                    || (localName.length() == 0)
  -                    || (localName.indexOf(':') >= 0)) {
  -                    throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                           "DOM003 Namespace error");
  +                        || (localName.length() == 0)
  +                        || (localName.indexOf(':') >= 0)) {
  +                    String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +                    throw new DOMException(DOMException.NAMESPACE_ERR, msg);
                   }
                   else if (prefix.equals("xml")) {
                       if (!namespaceURI.equals(xmlURI)) {
  -                        throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                               "DOM003 Namespace error");
  +                        String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +                        throw new DOMException(DOMException.NAMESPACE_ERR, msg);
                       }
                   } else if (index == 0) {
  -                    throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                           "DOM003 Namespace error");
  +                    String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +                    throw new DOMException(DOMException.NAMESPACE_ERR, msg);
                   }
               }
           }
  @@ -276,22 +276,23 @@
           }
           if (ownerDocument().errorChecking) {
               if (isReadOnly()) {
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
                   throw new DOMException(
                                        DOMException.NO_MODIFICATION_ALLOWED_ERR, 
  -                                     "DOM001 Modification not allowed");
  +                                     msg);
               }
               if (!CoreDocumentImpl.isXMLName(prefix)) {
  -                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, 
  -                                       "DOM002 Illegal character");
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"INVALID_CHARACTER_ERR", null);
  +                throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
               }
               if (namespaceURI == null || prefix.indexOf(':') >=0) {
  -                  throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                         "DOM003 Namespace error");
  +                String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +                throw new DOMException(DOMException.NAMESPACE_ERR, msg);
               } else if (prefix != null) {
                   if (prefix.equals("xml")) {
                       if (!namespaceURI.equals(xmlURI)) {
  -                        throw new DOMException(DOMException.NAMESPACE_ERR, 
  -                                               "DOM003 Namespace error");
  +                        String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR", 
null);
  +                        throw new DOMException(DOMException.NAMESPACE_ERR, msg);
                       }
                   }
               }
  
  
  
  1.31      +17 -15    xml-xerces/java/src/org/apache/xerces/dom/NamedNodeMapImpl.java
  
  Index: NamedNodeMapImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/NamedNodeMapImpl.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- NamedNodeMapImpl.java     20 Jun 2002 01:29:05 -0000      1.30
  +++ NamedNodeMapImpl.java     24 Jul 2002 19:08:41 -0000      1.31
  @@ -209,12 +209,12 @@
           throws DOMException {
   
        if (isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
  -                                       "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
        if (arg.getOwnerDocument() != ownerNode.ownerDocument()) {
  -            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
  -                                       "DOM005 Wrong document");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
           }
   
        int i = findNamePoint(arg.getNodeName(),0);
  @@ -248,13 +248,13 @@
           throws DOMException {
   
        if (isReadOnly()) {
  -            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
  -                                       "DOM001 Modification not allowed");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
  +            throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, msg);
           }
       
        if(arg.getOwnerDocument() != ownerNode.ownerDocument()) {
  -            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR,
  -                                       "DOM005 Wrong document");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"WRONG_DOCUMENT_ERR", null);
  +            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
           }
   
        int i = findNamePoint(arg.getNamespaceURI(), arg.getLocalName());
  @@ -291,14 +291,15 @@
           throws DOMException {
   
        if (isReadOnly()) {
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
               throw
                   new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
  -                                     "DOM001 Modification not allowed");
  +                msg);
           }
        int i = findNamePoint(name,0);
        if (i < 0) {
  -            throw new DOMException(DOMException.NOT_FOUND_ERR,
  -                                       "DOM008 Not found");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", 
null);
  +            throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
           }
   
           NodeImpl n = (NodeImpl)nodes.elementAt(i);
  @@ -326,14 +327,15 @@
           throws DOMException {
   
        if (isReadOnly()) {
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, 
"NO_MODIFICATION_ALLOWED_ERR", null);
               throw
                   new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
  -                                     "DOM001 Modification not allowed");
  +                msg);
           }
        int i = findNamePoint(namespaceURI, name);
        if (i < 0) {
  -            throw new DOMException(DOMException.NOT_FOUND_ERR,
  -                                       "DOM008 Not found");
  +            String msg = 
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NOT_FOUND_ERR", 
null);
  +            throw new DOMException(DOMException.NOT_FOUND_ERR, msg);
           }
   
           NodeImpl n = (NodeImpl)nodes.elementAt(i);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to