Author: mukulg
Date: Sun Nov 14 03:26:14 2010
New Revision: 1034928

URL: http://svn.apache.org/viewvc?rev=1034928&view=rev
Log:
doing few more code indentation improvements for better readibility.

Modified:
    
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/impl/xs/XSDTypeAlternativeValidator.java
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java

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=1034928&r1=1034927&r2=1034928&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
 Sun Nov 14 03:26:14 2010
@@ -2160,11 +2160,8 @@ public class XMLSchemaValidator
 
         //process type alternatives
         if (fTypeAlternativesChecking && fCurrentElemDecl != null) {
-            XSTypeDefinition currentType = fTypeAlternativeValidator.
-                                                     getCurrentType(
-                                                         fCurrentElemDecl, 
-                                                         element, 
-                                                         attributes);          
 
+            XSTypeDefinition currentType = 
fTypeAlternativeValidator.getCurrentType(fCurrentElemDecl, 
+                                                                               
     element, attributes);           
            if (currentType != null) {
                fCurrentType = currentType;    
            }
@@ -2380,8 +2377,7 @@ public class XMLSchemaValidator
         
         // delegate to 'type alternative' validator subcomponent
         if (fSchemaVersion == Constants.SCHEMA_VERSION_1_1) {
-           fTypeAlternativeValidator.handleStartElement(fCurrentElemDecl, 
-                                                        attributes);
+           fTypeAlternativeValidator.handleStartElement(fCurrentElemDecl, 
attributes);
         }
 
         // call all active identity constraints

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java?rev=1034928&r1=1034927&r2=1034928&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDTypeAlternativeValidator.java
 Sun Nov 14 03:26:14 2010
@@ -31,7 +31,7 @@ import org.apache.xerces.xs.XSAttributeD
 import org.apache.xerces.xs.XSTypeDefinition;
 
 /**
- * An XML Schema validator subcomponent handling 'type alternative' processing.
+ * An XML Schema validator subcomponent handling "type alternative" processing.
  * 
  * @xerces.internal
  * 
@@ -52,7 +52,7 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Class constructor
+     * Class constructor.
      */
     public XSDTypeAlternativeValidator() {
       // NO OP ...
@@ -60,29 +60,22 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Determine the schema type applicable for an element declaration,
-     * using type alternative information.
+     * Determine the schema type applicable for an element declaration, using 
type alternative information.
      */
-    public XSTypeDefinition getCurrentType(XSElementDecl currentElemDecl, 
-                                           QName element, 
-                                           XMLAttributes attributes) {
+    public XSTypeDefinition getCurrentType(XSElementDecl currentElemDecl, 
QName element, XMLAttributes attributes) {
         
         XSTypeDefinition currentType = null;        
         boolean typeSelected = false;
         
-        XSTypeAlternativeImpl[] alternatives = currentElemDecl.
-                                                   getTypeAlternatives();
+        XSTypeAlternativeImpl[] alternatives = 
currentElemDecl.getTypeAlternatives();
         
         if (alternatives != null) {              
-            // construct a list of attributes needed for CTA processing.
-            // This method call adds inherited attributes as well, to the list
-            // of attributes.
+            // Construct a list of attributes needed for CTA processing. This 
includes inherited attributes as well.
             XMLAttributes ctaAttributes = getAttributesForCTA(attributes);
             
             for (int i = 0; i < alternatives.length; i++) {
                 Test test = alternatives[i].getTest();
-                if (test != null && test.evaluateTest(element, 
-                                                      ctaAttributes)) {
+                if (test != null && test.evaluateTest(element, ctaAttributes)) 
{
                     currentType = alternatives[i].getTypeDefinition();
                     typeSelected = true;
                     break;
@@ -90,8 +83,7 @@ public class XSDTypeAlternativeValidator
             }
             //if a type is not selected try to assign the default type
             if (!typeSelected) {
-                XSTypeAlternativeImpl defType = currentElemDecl.
-                                                   getDefaultTypeDefinition();
+                XSTypeAlternativeImpl defType = 
currentElemDecl.getDefaultTypeDefinition();
                 if (defType != null) {
                     currentType = defType.getTypeDefinition();
                 }
@@ -104,20 +96,16 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Type alternative processing interface during the XNI event
-     * 'handleStartElement' in XMLSchemaValidator. 
+     * Type alternative processing interface during the XNI event 
'handleStartElement' in XMLSchemaValidator. 
      */
-    public void handleStartElement(XSElementDecl currentElemDecl, 
-                                   XMLAttributes attributes) {
+    public void handleStartElement(XSElementDecl currentElemDecl, 
XMLAttributes attributes) {
         
         fInhrAttrCountStack.push(fInheritableAttrList.size());
         
-        // Find attributes among the attributes of the current element, which
-        // are declared inheritable. The inheritable attributes will later be
-        // used for processing 'type alternative' instruction.
+        // Find attributes among the attributes of the current element, which 
are declared inheritable.
+        // The inheritable attributes will later be used for processing "type 
alternative" instruction.
         if (attributes.getLength() > 0) {
-           // get inheritable attributes, only if an element has a complex
-           // type (i.e, has > 0 attributes).
+           // get inheritable attributes, only if an element has a complex 
type (i.e, has > 0 attributes).
            saveInheritableAttributes(currentElemDecl, attributes);
         }
         
@@ -125,13 +113,12 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Type alternative processing interface during the XNI event
-     * 'handleEndElement' in XMLSchemaValidator. 
+     * Type alternative processing interface during the XNI event 
'handleEndElement' in XMLSchemaValidator. 
      */
     public void handleEndElement() {
         
-        // modify the Vector list 'fInheritableAttrList' and pop the stack,
-        // 'fInhrAttrCountStack', to reflect inheritable attributes processing.
+        // modify the Vector list 'fInheritableAttrList' and pop the stack, 
'fInhrAttrCountStack', to reflect
+        // inheritable attributes processing.
         if (fInhrAttrCountStack.size() > 0) {
             fInheritableAttrList.setSize(fInhrAttrCountStack.pop());
         }
@@ -140,8 +127,7 @@ public class XSDTypeAlternativeValidator
     
 
     /*
-     * Construct a list of attributes, needed for CTA processing. This includes
-     * inherited attributes as well.  
+     * Construct a list of attributes, needed for CTA processing. This 
includes inherited attributes as well.  
      */
     private XMLAttributes getAttributesForCTA(XMLAttributes attributes) {
 
@@ -150,27 +136,19 @@ public class XSDTypeAlternativeValidator
       for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
          QName qName = new QName();
          attributes.getName(attrIndx, qName);
-         ctaAttributes.addAttribute(qName, attributes.getType(attrIndx),
-                                    attributes.getValue(attrIndx));   
+         ctaAttributes.addAttribute(qName, attributes.getType(attrIndx), 
attributes.getValue(attrIndx));   
       }
       
-      // traverse up the XML tree, to find inherited attributes.
-      // attributes only from the nearest ancestor, are added to the list.
-      for (int elemIndx = fInheritableAttrList.size() - 1; elemIndx > -1; 
-                                                             elemIndx--) {     
   
-         InheritableAttribute inhAttr = (InheritableAttribute) 
-                                  fInheritableAttrList.elementAt(elemIndx);
-         // if an inheritable attribute doesn't already exist in the attributes
-         // list, add it to the list.
+      // Traverse up the XML tree, to find inheritable attributes. Attributes 
only from the nearest ancestor,
+      // are added to the list (since there is recursive inclusion of 
inheritable attributes in an XML tree).
+      for (int elemIndx = fInheritableAttrList.size() - 1; elemIndx > -1; 
elemIndx--) {        
+         InheritableAttribute inhAttr = (InheritableAttribute) 
fInheritableAttrList.elementAt(elemIndx);
+         // if an inheritable attribute doesn't already exist in the 
attributes list, add it to the list
          if (!attributeExists(ctaAttributes, inhAttr)) {
-            String rawName = "".equals(inhAttr.getPrefix()) ? 
-                                       inhAttr.getLocalName() : 
-                                       inhAttr.getPrefix() + ":" + 
+            String rawName = "".equals(inhAttr.getPrefix()) ? 
inhAttr.getLocalName() : inhAttr.getPrefix() + ":" + 
                                        inhAttr.getLocalName(); 
-            fTempQName.setValues(inhAttr.getPrefix(), inhAttr.getLocalName(), 
-                                                  rawName, inhAttr.getUri());
-            ctaAttributes.addAttribute(fTempQName, inhAttr.getType(), 
-                                                   inhAttr.getValue());
+            fTempQName.setValues(inhAttr.getPrefix(), inhAttr.getLocalName(), 
rawName, inhAttr.getUri());
+            ctaAttributes.addAttribute(fTempQName, inhAttr.getType(), 
inhAttr.getValue());
          }
       }
       
@@ -180,41 +158,31 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * For the current element being handled by the Schema validator, find
-     * all inheritable attributes for this element. Save these inheritable
-     * attributes, in a global Vector list.
+     * For the current element being handled by the Schema validator, find all 
inheritable attributes for this element.
+     * Save these inheritable attributes, to a global Vector list.
      */
-    private void saveInheritableAttributes(XSElementDecl currentElemDecl,
-                                           XMLAttributes attributes) {
+    private void saveInheritableAttributes(XSElementDecl currentElemDecl, 
XMLAttributes attributes) {
        
-       if (currentElemDecl != null && currentElemDecl.fType instanceof  
-                                                         XSComplexTypeDecl) {
-          XSComplexTypeDecl currentComplexType = (XSComplexTypeDecl) 
-                                                        currentElemDecl.fType;
-          XSObjectListImpl attributeUses = (XSObjectListImpl) 
-                                      currentComplexType.getAttributeUses();   
        
+       if (currentElemDecl != null && currentElemDecl.fType instanceof 
XSComplexTypeDecl) {
+          XSComplexTypeDecl currentComplexType = (XSComplexTypeDecl) 
currentElemDecl.fType;
+          XSObjectListImpl attributeUses = (XSObjectListImpl) 
currentComplexType.getAttributeUses();           
           
           // iterate all the attributes, being passed to this method        
           for (int attrIndx = 0; attrIndx < attributes.getLength(); 
attrIndx++) {
              String attrName = attributes.getLocalName(attrIndx);
              String attrUri = attributes.getURI(attrIndx);            
-             // iterate all the attribute declarations of a complex type,
-             // for the current element.
-             for (int attrUsesIndx = 0; attrUsesIndx < 
attributeUses.getLength(); 
-                                                            attrUsesIndx++) {
-                XSAttributeUseImpl attrUseImpl = (XSAttributeUseImpl) 
-                                            attributeUses.get(attrUsesIndx);
+             // iterate all the attribute declarations of a complex type, for 
the current element
+             for (int attrUsesIndx = 0; attrUsesIndx < 
attributeUses.getLength(); attrUsesIndx++) {
+                XSAttributeUseImpl attrUseImpl = (XSAttributeUseImpl) 
attributeUses.get(attrUsesIndx);
                 XSAttributeDeclaration attrDecl = 
attrUseImpl.getAttrDeclaration();              
                 // the current element, has an inheritable attribute
-                if (attrName.equals(attrDecl.getName()) &&
-                        XSTypeHelper.uriEqual(attrUri, 
attrDecl.getNamespace()) &&    
-                      attrUseImpl.getInheritable()) {                   
-                    InheritableAttribute inhrAttr = new InheritableAttribute(
-                                            attributes.getLocalName(attrIndx),
-                                            attributes.getPrefix(attrIndx),
-                                            attributes.getURI(attrIndx),
-                                            attributes.getValue(attrIndx),
-                                            attributes.getType(attrIndx)) ;
+                if (attrName.equals(attrDecl.getName()) && 
XSTypeHelper.uriEqual(attrUri, attrDecl.getNamespace()) &&    
+                                                                               
        attrUseImpl.getInheritable()) {                   
+                    InheritableAttribute inhrAttr = new 
InheritableAttribute(attributes.getLocalName(attrIndx),
+                                                                             
attributes.getPrefix(attrIndx),
+                                                                             
attributes.getURI(attrIndx),
+                                                                             
attributes.getValue(attrIndx),
+                                                                             
attributes.getType(attrIndx)) ;
                     fInheritableAttrList.add(inhrAttr);                   
                }
             }
@@ -225,18 +193,16 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * Check if an inheritable attribute, exists in the attributes list
+     * Check if an inheritable attribute, exists in the attributes list.
      */
-    private boolean attributeExists(XMLAttributes attributes, 
-                                    InheritableAttribute inhAttr) {
+    private boolean attributeExists(XMLAttributes attributes, 
InheritableAttribute inhAttr) {
       
       boolean attrExists = false;
       
       for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
           String localName = attributes.getLocalName(attrIndx);
           String uri = attributes.getURI(attrIndx);          
-          if (localName.equals(inhAttr.getLocalName()) &&
-                XSTypeHelper.uriEqual(uri, inhAttr.getUri())) {              
+          if (localName.equals(inhAttr.getLocalName()) && 
XSTypeHelper.uriEqual(uri, inhAttr.getUri())) {              
              attrExists = true;
              break;
           }
@@ -248,9 +214,8 @@ public class XSDTypeAlternativeValidator
     
     
     /*
-     * A class representing an inheritable attribute. An instance of this class
-     * is used as an intermediate storage, for inheritable attribute 
-     * information.
+     * A class representing an inheritable attribute. An instance of this 
class is used as an intermediate storage,
+     * for inheritable attribute information.
      */
     final class InheritableAttribute {       
        
@@ -260,11 +225,8 @@ public class XSDTypeAlternativeValidator
        private final String value;
        private final String type;
       
-       public InheritableAttribute(String localName,
-                                   String prefix,
-                                   String uri,
-                                   String value,
-                                   String type) {
+       public InheritableAttribute(String localName, String prefix, String 
uri, 
+                                   String value, String type) {
          this.localName = localName;
          this.prefix = prefix;
          this.uri = uri;
@@ -292,6 +254,6 @@ public class XSDTypeAlternativeValidator
           return type; 
        }
        
-    } // class, InheritableAttribute
+    } // class InheritableAttribute
     
 } // class XSDTypeAlternativeValidator

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java?rev=1034928&r1=1034927&r2=1034928&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/util/XSTypeHelper.java
 Sun Nov 14 03:26:14 2010
@@ -56,12 +56,10 @@ public class XSTypeHelper {
         
         if (!typesIdentical) {                        
             if (uriEqual(typeDefn1.getNamespace(), typeDefn2.getNamespace())) {
-                // if targetNamespace of types are same, then check for  
equality
-                // of type names and of the base type.
+                // if targetNamespace of types are same, then check for  
equality of type names and of the base type.
                 if ((type1Name == null && type2Name == null) ||
                     (type1Name != null && type1Name.equals(type2Name))
-                          && (schemaTypesIdentical(typeDefn1.getBaseType(),
-                                                   typeDefn2.getBaseType()))) {
+                          && (schemaTypesIdentical(typeDefn1.getBaseType(), 
typeDefn2.getBaseType()))) {
                      typesIdentical = true;   
                 }
             }
@@ -93,27 +91,22 @@ public class XSTypeHelper {
     
     
     /*
-     * Determine if an atomic value is valid with respect to any of the union's
-     * member types. If this method returns 'true', then the value is valid 
with
-     * respect to entire union schema component. 
+     * Determine if an atomic value is valid with respect to any of the 
union's member types. 
+     * If this method returns 'true', then the value is valid with respect to 
entire union 
+     * schema component. 
      */
     public static boolean isAtomicValueValidForAnUnion(XSObjectList 
memberTypes,
-                                                       String content,
-                                                       ValidatedInfo 
validatedInfo) {
+                                                       String content, 
ValidatedInfo validatedInfo) {
         
         boolean isValid = false;
         
         // check the union member types in order to check for validity of an 
'atomic value'.
         // the validity of 'atomic value' wrt to the 1st available type in 
this sequence,
         // is sufficient to achieve the objective of this method.
-        for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); 
-                                                    memTypeIdx++) {
-            XSSimpleType simpleTypeDv = (XSSimpleType) memberTypes.item
-                                                     (memTypeIdx);
-            if (SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(simpleTypeDv.
-                                                      getNamespace())) {       
         
-                if (XSTypeHelper.isValueValidForASimpleType(content, 
-                                                            simpleTypeDv)) {
+        for (int memTypeIdx = 0; memTypeIdx < memberTypes.getLength(); 
memTypeIdx++) {
+            XSSimpleType simpleTypeDv = (XSSimpleType) 
memberTypes.item(memTypeIdx);
+            if 
(SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(simpleTypeDv.getNamespace())) {       
         
+                if (XSTypeHelper.isValueValidForASimpleType(content, 
simpleTypeDv)) {
                     isValid = true;
                     break;  
                 }
@@ -130,8 +123,7 @@ public class XSTypeHelper {
      * according to the type) of a given schema simpleType definition. Using 
Xerces API
      * 'XSSimpleType.validate' for this need.
      */
-    public static boolean isValueValidForASimpleType(String value,
-                                                     XSSimpleType simplType) {
+    public static boolean isValueValidForASimpleType(String value, 
XSSimpleType simplType) {
         
         boolean isValueValid = true;
         
@@ -140,8 +132,7 @@ public class XSTypeHelper {
             ValidatedInfo validatedInfo = new ValidatedInfo();
             ValidationContext validationState = new ValidationState();
             
-            // attempt to validate the "string value" with a simpleType
-            // instance.
+            // attempt to validate the "string value" with a simpleType 
instance.
             simplType.validate(value, validationState, validatedInfo);
         } 
         catch(InvalidDatatypeValueException ex){



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to