Author: mrglavas
Date: Tue Nov 18 20:54:33 2008
New Revision: 718857

URL: http://svn.apache.org/viewvc?rev=718857&view=rev
Log:
JIRA Issue #1339:
http://issues.apache.org/jira/browse/XERCESJ-1339

Added the getErrorMessages() method to ItemPSVI and completed its 
implementation.

Added:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
   (with props)
Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIAttrNSImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/XMLErrorReporter.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ItemPSVI.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIAttrNSImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIAttrNSImpl.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIAttrNSImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIAttrNSImpl.java
 Tue Nov 18 20:54:33 2008
@@ -22,6 +22,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.xerces.impl.xs.util.StringListImpl;
 import org.apache.xerces.xs.AttributePSVI;
 import org.apache.xerces.xs.ShortList;
 import org.apache.xerces.xs.StringList;
@@ -93,6 +94,9 @@
 
     /** error codes */
     protected StringList fErrorCodes = null;
+    
+    /** error messages */
+    protected StringList fErrorMessages = null;
 
     /** validation context: could be QName or XPath expression*/
     protected String fValidationContext = null;
@@ -160,7 +164,23 @@
      * @return list of error codes
      */
     public StringList getErrorCodes() {
-        return fErrorCodes;
+        if (fErrorCodes != null) {
+            return fErrorCodes;
+        }
+        return StringListImpl.EMPTY_LIST;
+    }
+    
+    /**
+     * A list of error messages generated from the validation attempt or
+     * an empty <code>StringList</code> if no errors occurred during the 
+     * validation attempt. The indices of error messages in this list are 
+     * aligned with those in the <code>[schema error code]</code> list.
+     */
+    public StringList getErrorMessages() {
+        if (fErrorMessages != null) {
+            return fErrorMessages;
+        }
+        return StringListImpl.EMPTY_LIST;
     }
 
     // This is the only information we can provide in a pipeline.
@@ -211,6 +231,7 @@
         this.fValidity = attr.getValidity();
         this.fValidationAttempted = attr.getValidationAttempted();
         this.fErrorCodes = attr.getErrorCodes();
+        this.fErrorMessages = attr.getErrorMessages();
         this.fNormalizedValue = attr.getSchemaNormalizedValue();
         this.fActualValue = attr.getActualNormalizedValue();
         this.fActualValueType = attr.getActualNormalizedValueType();

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/PSVIElementNSImpl.java
 Tue Nov 18 20:54:33 2008
@@ -22,6 +22,7 @@
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 
+import org.apache.xerces.impl.xs.util.StringListImpl;
 import org.apache.xerces.xs.ElementPSVI;
 import org.apache.xerces.xs.ShortList;
 import org.apache.xerces.xs.StringList;
@@ -103,6 +104,9 @@
 
     /** error codes */
     protected StringList fErrorCodes = null;
+    
+    /** error messages */
+    protected StringList fErrorMessages = null;
 
     /** validation context: could be QName or XPath expression*/
     protected String fValidationContext = null;
@@ -172,9 +176,24 @@
      * @return Array of error codes
      */
     public StringList getErrorCodes() {
-        return fErrorCodes;
+        if (fErrorCodes != null) {
+            return fErrorCodes;
+        }
+        return StringListImpl.EMPTY_LIST;
+    }
+    
+    /**
+     * A list of error messages generated from the validation attempt or
+     * an empty <code>StringList</code> if no errors occurred during the 
+     * validation attempt. The indices of error messages in this list are 
+     * aligned with those in the <code>[schema error code]</code> list.
+     */
+    public StringList getErrorMessages() {
+        if (fErrorMessages != null) {
+            return fErrorMessages;
+        }
+        return StringListImpl.EMPTY_LIST;
     }
-
 
     // This is the only information we can provide in a pipeline.
     public String getValidationContext() {
@@ -255,6 +274,7 @@
         this.fValidity = elem.getValidity();
         this.fValidationAttempted = elem.getValidationAttempted();
         this.fErrorCodes = elem.getErrorCodes();
+        this.fErrorMessages = elem.getErrorMessages();
         this.fNormalizedValue = elem.getSchemaNormalizedValue();
         this.fActualValue = elem.getActualNormalizedValue();
         this.fActualValueType = elem.getActualNormalizedValueType();

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/XMLErrorReporter.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/XMLErrorReporter.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/XMLErrorReporter.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/XMLErrorReporter.java
 Tue Nov 18 20:54:33 2008
@@ -271,15 +271,16 @@
      * @param arguments The replacement arguments for the error message,
      *                  if needed.
      * @param severity  The severity of the error.
+     * @return          The formatted error message.
      *
      * @see #SEVERITY_WARNING
      * @see #SEVERITY_ERROR
      * @see #SEVERITY_FATAL_ERROR
      */
-    public void reportError(String domain, String key, Object[] arguments, 
+    public String reportError(String domain, String key, Object[] arguments, 
                             short severity) throws XNIException {
-        reportError(fLocator, domain, key, arguments, severity);
-    } // reportError(String,String,Object[],short)
+        return reportError(fLocator, domain, key, arguments, severity);
+    } // reportError(String,String,Object[],short):String
     
     /**
      * Reports an error. The error message passed to the error handler
@@ -292,15 +293,16 @@
      *                  if needed.
      * @param severity  The severity of the error.
      * @param exception The exception to wrap.
+     * @return          The formatted error message.
      *
      * @see #SEVERITY_WARNING
      * @see #SEVERITY_ERROR
      * @see #SEVERITY_FATAL_ERROR
      */
-    public void reportError(String domain, String key, Object[] arguments, 
+    public String reportError(String domain, String key, Object[] arguments, 
             short severity, Exception exception) throws XNIException {
-        reportError(fLocator, domain, key, arguments, severity, exception);
-    } // reportError(String,String,Object[],short,Exception)
+        return reportError(fLocator, domain, key, arguments, severity, 
exception);
+    } // reportError(String,String,Object[],short,Exception):String
     
     /**
      * Reports an error at a specific location.
@@ -311,16 +313,17 @@
      * @param arguments The replacement arguments for the error message,
      *                  if needed.
      * @param severity  The severity of the error.
+     * @return          The formatted error message.
      *
      * @see #SEVERITY_WARNING
      * @see #SEVERITY_ERROR
      * @see #SEVERITY_FATAL_ERROR
      */
-    public void reportError(XMLLocator location,
+    public String reportError(XMLLocator location,
             String domain, String key, Object[] arguments, 
             short severity) throws XNIException {
-        reportError(location, domain, key, arguments, severity, null);
-    } // reportError(XMLLocator,String,String,Object[],short)
+        return reportError(location, domain, key, arguments, severity, null);
+    } // reportError(XMLLocator,String,String,Object[],short):String
 
     /**
      * Reports an error at a specific location.
@@ -332,12 +335,13 @@
      *                  if needed.
      * @param severity  The severity of the error.
      * @param exception The exception to wrap.
+     * @return          The formatted error message.
      *
      * @see #SEVERITY_WARNING
      * @see #SEVERITY_ERROR
      * @see #SEVERITY_FATAL_ERROR
      */
-    public void reportError(XMLLocator location,
+    public String reportError(XMLLocator location,
                             String domain, String key, Object[] arguments, 
                             short severity, Exception exception) throws 
XNIException {
 
@@ -398,8 +402,9 @@
                 break;
             }
         }
+        return message;
 
-    } // reportError(XMLLocator,String,String,Object[],short,Exception)
+    } // reportError(XMLLocator,String,String,Object[],short,Exception):String
 
     //
     // XMLComponent methods

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AttributePSVImpl.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/AttributePSVImpl.java
 Tue Nov 18 20:54:33 2008
@@ -68,8 +68,8 @@
     /** validity: valid, invalid, unknown */
     protected short fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
 
-    /** error codes */
-    protected String[] fErrorCodes = null;
+    /** error codes and error messages */
+    protected String[] fErrors = null;
 
     /** validation context: could be QName or XPath expression*/
     protected String fValidationContext = null;
@@ -137,10 +137,23 @@
      * @return list of error codes
      */
     public StringList getErrorCodes() {
-        if (fErrorCodes == null) {
+        if (fErrors == null || fErrors.length == 0) {
             return StringListImpl.EMPTY_LIST;
         }
-        return new StringListImpl(fErrorCodes, fErrorCodes.length);
+        return new PSVIErrorList(fErrors, true);
+    }
+    
+    /**
+     * A list of error messages generated from the validation attempt or
+     * an empty <code>StringList</code> if no errors occurred during the 
+     * validation attempt. The indices of error messages in this list are 
+     * aligned with those in the <code>[schema error code]</code> list.
+     */
+    public StringList getErrorMessages() {
+        if (fErrors == null || fErrors.length == 0) {
+            return StringListImpl.EMPTY_LIST;
+        }
+        return new PSVIErrorList(fErrors, false);
     }
 
     // This is the only information we can provide in a pipeline.
@@ -215,7 +228,7 @@
         fMemberType = null;
         fValidationAttempted = AttributePSVI.VALIDATION_NONE;
         fValidity = AttributePSVI.VALIDITY_NOTKNOWN;
-        fErrorCodes = null;
+        fErrors = null;
         fValidationContext = null;
     }
 }

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/ElementPSVImpl.java
 Tue Nov 18 20:54:33 2008
@@ -83,8 +83,8 @@
     /** validity: valid, invalid, unknown */
     protected short fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
 
-    /** error codes */
-    protected String[] fErrorCodes = null;
+    /** error codes and error messages */
+    protected String[] fErrors = null;
 
     /** validation context: could be QName or XPath expression*/
     protected String fValidationContext = null;
@@ -157,12 +157,24 @@
      * @return Array of error codes
      */
     public StringList getErrorCodes() {
-        if (fErrorCodes == null) {
+        if (fErrors == null || fErrors.length == 0) {
             return StringListImpl.EMPTY_LIST;
         }
-        return new StringListImpl(fErrorCodes, fErrorCodes.length);
+        return new PSVIErrorList(fErrors, true);
+    }
+    
+    /**
+     * A list of error messages generated from the validation attempt or
+     * an empty <code>StringList</code> if no errors occurred during the 
+     * validation attempt. The indices of error messages in this list are 
+     * aligned with those in the <code>[schema error code]</code> list.
+     */
+    public StringList getErrorMessages() {
+        if (fErrors == null || fErrors.length == 0) {
+            return StringListImpl.EMPTY_LIST;
+        }
+        return new PSVIErrorList(fErrors, false);
     }
-
 
     // This is the only information we can provide in a pipeline.
     public String getValidationContext() {
@@ -265,7 +277,7 @@
         fMemberType = null;
         fValidationAttempted = ElementPSVI.VALIDATION_NONE;
         fValidity = ElementPSVI.VALIDITY_NOTKNOWN;
-        fErrorCodes = null;
+        fErrors = null;
         fValidationContext = null;
         fNormalizedValue = null;
         fActualValue = null;

Added: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java?rev=718857&view=auto
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
 (added)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
 Tue Nov 18 20:54:33 2008
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.xerces.impl.xs;
+
+import org.apache.xerces.xs.StringList;
+
+/**
+ * StringList implementation for schema error codes and error messages.
+ *
+ * @xerces.internal
+ *
+ * @author Michael Glavassevich, IBM
+ * 
+ * @version $Id$
+ */
+final class PSVIErrorList implements StringList {
+
+    private final String[] fArray;
+    private final int fLength;
+    private final int fOffset;
+    
+    public PSVIErrorList(String[] array, boolean even) {
+        fArray = array;
+        fLength = (fArray.length >> 1);
+        fOffset = even ? 0 : 1;
+    }
+
+    public boolean contains(String item) {
+        if (item == null) {
+            for (int i = 0; i < fLength; ++i) {
+                if (fArray[(i << 1) + fOffset] == null) {
+                    return true;
+                }
+            }
+        }
+        else {
+            for (int i = 0; i < fLength; ++i) {
+                if (item.equals(fArray[(i << 1) + fOffset])) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    public int getLength() {
+        return fLength;
+    }
+
+    public String item(int index) {
+        if (index < 0 || index >= fLength) {
+            return null;
+        }
+        return fArray[(index << 1) + fOffset];
+    }
+}

Propchange: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/PSVIErrorList.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
 Tue Nov 18 20:54:33 2008
@@ -463,9 +463,10 @@
 
         public void reportError(String domain, String key, Object[] arguments, 
short severity)
             throws XNIException {
-            fErrorReporter.reportError(domain, key, arguments, severity);
+            String message = fErrorReporter.reportError(domain, key, 
arguments, severity);
             if (fAugPSVI) {
                 fErrors.addElement(key);
+                fErrors.addElement(message);
             }
         } // reportError(String,String,Object[],short)
 
@@ -476,9 +477,10 @@
             Object[] arguments,
             short severity)
             throws XNIException {
-            fErrorReporter.reportError(location, domain, key, arguments, 
severity);
+            String message = fErrorReporter.reportError(location, domain, key, 
arguments, severity);
             if (fAugPSVI) {
                 fErrors.addElement(key);
+                fErrors.addElement(message);
             }
         } // reportError(XMLLocator,String,String,Object[],short)
     }
@@ -2530,7 +2532,7 @@
                 String[] errors = fXSIErrorReporter.mergeContext();
 
                 // PSVI: error codes
-                fCurrentPSVI.fErrorCodes = errors;
+                fCurrentPSVI.fErrors = errors;
                 // PSVI: validity
                 fCurrentPSVI.fValidity =
                     (errors == null) ? ElementPSVI.VALIDITY_VALID : 
ElementPSVI.VALIDITY_INVALID;
@@ -3079,7 +3081,7 @@
 
             String[] errors = fXSIErrorReporter.mergeContext();
             // PSVI: error codes
-            attrPSVI.fErrorCodes = errors;
+            attrPSVI.fErrors = errors;
             // PSVI: validity
             attrPSVI.fValidity =
                 (errors == null) ? AttributePSVI.VALIDITY_VALID : 
AttributePSVI.VALIDITY_INVALID;

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ItemPSVI.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ItemPSVI.java?rev=718857&r1=718856&r2=718857&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ItemPSVI.java 
(original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/xs/ItemPSVI.java 
Tue Nov 18 20:54:33 2008
@@ -28,19 +28,19 @@
      */
     public static final short VALIDITY_NOTKNOWN         = 0;
     /**
-     *  Validity value indicating that validation has been strictly assessed 
+     * Validity value indicating that validation has been strictly assessed 
      * and the item in question is invalid according to the rules of schema 
      * validation. 
      */
     public static final short VALIDITY_INVALID          = 1;
     /**
-     *  Validation status indicating that schema validation has been performed 
+     * Validation status indicating that schema validation has been performed 
      * and the item in question is valid according to the rules of schema 
      * validation. 
      */
     public static final short VALIDITY_VALID            = 2;
     /**
-     *  Validation status indicating that schema validation has been performed 
+     * Validation status indicating that schema validation has been performed 
      * and the item in question has specifically been skipped. 
      */
     public static final short VALIDATION_NONE           = 0;
@@ -50,12 +50,12 @@
      */
     public static final short VALIDATION_PARTIAL        = 1;
     /**
-     *  Validation status indicating that full schema validation has been 
+     * Validation status indicating that full schema validation has been 
      * performed on the item. 
      */
     public static final short VALIDATION_FULL           = 2;
     /**
-     *  The nearest ancestor element information item with a 
+     * The nearest ancestor element information item with a 
      * <code>[schema information]</code> property (or this element item 
      * itself if it has such a property). For more information refer to 
      * element validation context and attribute validation context . 
@@ -63,7 +63,7 @@
     public String getValidationContext();
 
     /**
-     *  <code>[validity]</code>: determines the validity of the schema item 
+     * <code>[validity]</code>: determines the validity of the schema item 
      * with respect to the validation being attempted. The value will be one 
      * of the constants: <code>VALIDITY_NOTKNOWN</code>, 
      * <code>VALIDITY_INVALID</code> or <code>VALIDITY_VALID</code>. 
@@ -71,7 +71,7 @@
     public short getValidity();
 
     /**
-     *  <code>[validation attempted]</code>: determines the extent to which 
+     * <code>[validation attempted]</code>: determines the extent to which 
      * the schema item has been validated. The value will be one of the 
      * constants: <code>VALIDATION_NONE</code>, 
      * <code>VALIDATION_PARTIAL</code> or <code>VALIDATION_FULL</code>. 
@@ -79,11 +79,19 @@
     public short getValidationAttempted();
 
     /**
-     *  <code>[schema error code]</code>: a list of error codes generated from 
+     * <code>[schema error code]</code>: a list of error codes generated from 
      * the validation attempt or an empty <code>StringList</code> if no 
      * errors occurred during the validation attempt. 
      */
     public StringList getErrorCodes();
+    
+    /**
+     * A list of error messages generated from the validation attempt or
+     * an empty <code>StringList</code> if no errors occurred during the 
+     * validation attempt. The indices of error messages in this list are 
+     * aligned with those in the <code>[schema error code]</code> list.
+     */
+    public StringList getErrorMessages();
 
     /**
      * <code>[schema normalized value]</code>: the normalized value of this 
@@ -154,7 +162,7 @@
                                    throws XSException;
 
     /**
-     *  <code>[type definition]</code>: an item isomorphic to the type 
+     * <code>[type definition]</code>: an item isomorphic to the type 
      * definition used to validate the schema item. 
      */
     public XSTypeDefinition getTypeDefinition();



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

Reply via email to