Author: mukulg
Date: Sat Nov 13 13:28:15 2010
New Revision: 1034753

URL: http://svn.apache.org/viewvc?rev=1034753&view=rev
Log:
improving few code indentations to improve readibility.

Modified:
    
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java

Modified: 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
URL: 
http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java?rev=1034753&r1=1034752&r2=1034753&view=diff
==============================================================================
--- 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
 (original)
+++ 
xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/impl/xs/XSDAssertionValidator.java
 Sat Nov 13 13:28:15 2010
@@ -51,9 +51,8 @@ import org.apache.xerces.xs.XSTypeDefini
  */
 public class XSDAssertionValidator {
     
-    // XMLSchemaValidator instance that acts as context for the present 
-    // assertion validator subcomponent. Passed into the constructor of 
-    // this object.
+    // XMLSchemaValidator instance that acts as context for the present 
assertion validator subcomponent.
+    // Passed into the constructor of this object.
     XMLSchemaValidator xmlSchemaValidator = null;
     
     // assertion processor object reference
@@ -61,7 +60,7 @@ public class XSDAssertionValidator {
     
     
     /*
-     * Class constructor
+     * Class constructor.
      */
     public XSDAssertionValidator(XMLSchemaValidator xmlSchemaValidator) {
        this.xmlSchemaValidator = xmlSchemaValidator; 
@@ -69,8 +68,7 @@ public class XSDAssertionValidator {
 
     
     /*
-     * Assertions processing interface during the XNI event, 'handleCharacters'
-     * in XMLSchemaValidator. 
+     * Assertions processing interface during the XNI event, 
'handleCharacters' in XMLSchemaValidator. 
      */
     public void characterDataHandler(XMLString text) {
         
@@ -82,8 +80,7 @@ public class XSDAssertionValidator {
     
     
     /*
-     * Assertions processing interface during the XNI event, 
'handleStartElement'
-     * in XMLSchemaValidator.
+     * Assertions processing interface during the XNI event, 
'handleStartElement' in XMLSchemaValidator.
      */
     public void handleStartElement(QName element, XMLAttributes attributes) {
        
@@ -95,18 +92,16 @@ public class XSDAssertionValidator {
             // construct parameter values for the assertion processor
             NamespaceSupport xpathNamespaceContext = null;
             if (assertionList instanceof XSObjectList) {
-                xpathNamespaceContext = ((XSAssertImpl)((XSObjectList)
-                         assertionList).item(0)).getXPath2NamespaceContext();  
  
+                xpathNamespaceContext = ((XSAssertImpl)((XSObjectList) 
assertionList).item(0)).
+                                                                          
getXPath2NamespaceContext();    
             }
             else {
                 Vector assertVector = (Vector) assertionList;
-                xpathNamespaceContext = ((XSAssertImpl)assertVector.
-                                   get(0)).getXPath2NamespaceContext();
+                xpathNamespaceContext = 
((XSAssertImpl)assertVector.get(0)).getXPath2NamespaceContext();
             }
             
             Map assertProcessorParams = new HashMap();
-            assertProcessorParams.put("XPATH2_NS_CONTEXT", 
-                                      xpathNamespaceContext);
+            assertProcessorParams.put("XPATH2_NS_CONTEXT", 
xpathNamespaceContext);
             // initialize the assertions processor
             initializeAssertProcessor(assertProcessorParams);
         }
@@ -123,15 +118,11 @@ public class XSDAssertionValidator {
     
     
     /*
-     * Assertions processing interface during the XNI event, 'handleEndElement'
-     * in XMLSchemaValidator.
+     * Assertions processing interface during the XNI event, 
'handleEndElement' in XMLSchemaValidator.
      */
-    public void handleEndElement(QName element, 
-                                 XSElementDecl elemDecl, 
-                                 XSTypeDefinition typeDef, 
-                                 XSNotationDecl notation,
-                                 XSGrammarBucket grammarBucket,
-                                 boolean atomicValueValid) {
+    public void handleEndElement(QName element, XSElementDecl elemDecl, 
+                                 XSTypeDefinition typeDef, XSNotationDecl 
notation,
+                                 XSGrammarBucket grammarBucket, boolean 
atomicValueValid) {
         
         if (fAssertionProcessor != null) {
             try {
@@ -146,8 +137,7 @@ public class XSDAssertionValidator {
                 // store assertPSVI into the augmentations.
                 AugmentationsImpl assertAugs = new AugmentationsImpl();
                 assertAugs.putItem(Constants.ELEMENT_PSVI, assertPSVI);
-                assertAugs.putItem("ATOMIC_VALUE_VALIDITY", Boolean.valueOf
-                                               (atomicValueValid));
+                assertAugs.putItem("ATOMIC_VALUE_VALIDITY", 
Boolean.valueOf(atomicValueValid));
                 fAssertionProcessor.endElement(element, assertAugs);
             } catch (Exception ex) {
                 throw new XNIException(ex.getMessage(), ex);
@@ -158,22 +148,18 @@ public class XSDAssertionValidator {
     
     
     /*
-     * Accumulate a list of assertions (fetch from the underlying XSModel
-     * instance) to be processed for the current context. Return the 
-     * assertions list.
+     * Accumulate a list of assertions (fetch from the underlying XSModel 
instance) to be processed
+     * for the current context. Return the assertions list.
      */
-    private List getAssertsForEvaluation(QName element,
-                                         XMLAttributes attributes) {
+    private List getAssertsForEvaluation(QName element, XMLAttributes 
attributes) {
         
-       XSTypeDefinition typeDef = xmlSchemaValidator.fCurrentPSVI.
-                                                         getTypeDefinition();
+       XSTypeDefinition typeDef = 
xmlSchemaValidator.fCurrentPSVI.getTypeDefinition();
 
        List assertionList = null;
             
        if (typeDef.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE) {
            // if element's schema type is a "complex type"               
-           XSObjectListImpl complexTypeAsserts = getAssertsFromComplexType(
-                                                       typeDef, attributes);
+           XSObjectListImpl complexTypeAsserts = 
getAssertsFromComplexType(typeDef, attributes);
            if (complexTypeAsserts.size() > 0) {
                assertionList = complexTypeAsserts;             
            }
@@ -191,51 +177,38 @@ public class XSDAssertionValidator {
     /*
      * Accumulate assertions from a complex type.
      */
-    private XSObjectListImpl getAssertsFromComplexType(XSTypeDefinition 
-                                       typeDef, XMLAttributes attributes) {
+    private XSObjectListImpl getAssertsFromComplexType(XSTypeDefinition 
typeDef, XMLAttributes attributes) {
         
         XSObjectListImpl complexTypeAsserts = new XSObjectListImpl();
 
-        XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition) 
-                                                               typeDef;
+        XSComplexTypeDefinition complexTypeDef = (XSComplexTypeDefinition) 
typeDef;
 
         XSObjectList primaryAssertions = complexTypeDef.getAssertions();
         if (primaryAssertions.getLength() > 0) {
             for (int i = 0; i < primaryAssertions.getLength(); i++) {
-                complexTypeAsserts.addXSObject((XSAssert) primaryAssertions.
-                                                            get(i));
+                complexTypeAsserts.addXSObject((XSAssert) 
primaryAssertions.get(i));
             }
         }
 
-        // add assertion facets, from "complexType -> simpleContent -> 
-        // restriction".
-        XSSimpleTypeDefinition simpleContentType = complexTypeDef.
-                                                       getSimpleType();
+        // add assertion facets, from "complexType -> simpleContent -> 
restriction"
+        XSSimpleTypeDefinition simpleContentType = 
complexTypeDef.getSimpleType();
         if (simpleContentType != null) {
-            XSObjectList complexTypeFacets = simpleContentType.
-                                                  getMultiValueFacets();
+            XSObjectList complexTypeFacets = 
simpleContentType.getMultiValueFacets();
             for (int i = 0; i < complexTypeFacets.getLength(); i++) {
-                XSMultiValueFacet facet = (XSMultiValueFacet) 
-                                                   complexTypeFacets.item(i);
-                if (facet.getFacetKind() == XSSimpleTypeDefinition.
-                                                               FACET_ASSERT) {
+                XSMultiValueFacet facet = (XSMultiValueFacet) 
complexTypeFacets.item(i);
+                if (facet.getFacetKind() == 
XSSimpleTypeDefinition.FACET_ASSERT) {
                     Vector simpleContentAsserts = facet.getAsserts();
-                    for (int simpleAssertIdx = 0; simpleAssertIdx < 
-                                   simpleContentAsserts.size(); 
-                                                         simpleAssertIdx++) {
-                        XSAssert simpleContentAssert = (XSAssert)
-                        simpleContentAsserts.get(simpleAssertIdx);
+                    for (int simpleAssertIdx = 0; simpleAssertIdx < 
simpleContentAsserts.size(); simpleAssertIdx++) {
+                        XSAssert simpleContentAssert = (XSAssert) 
simpleContentAsserts.get(simpleAssertIdx);
                         complexTypeAsserts.addXSObject(simpleContentAssert);
                     }
                 }
             }
         }
 
-        // find assertions from attributes of a complex type, and add them
-        // to the parent assertions list.
+        // find assertions from attributes of a complex type, and add them to 
the parent assertions list.
         XSObjectListImpl attrAsserts = getAssertsFromAttributes(attributes);
-        for (int attrAssertIdx = 0; attrAssertIdx < attrAsserts.getLength(); 
-                                                            attrAssertIdx++) {
+        for (int attrAssertIdx = 0; attrAssertIdx < attrAsserts.getLength(); 
attrAssertIdx++) {
             complexTypeAsserts.addXSObject(attrAsserts.item(attrAssertIdx)); 
         }
 
@@ -253,13 +226,10 @@ public class XSDAssertionValidator {
         
         for (int attrIndx = 0; attrIndx < attributes.getLength(); attrIndx++) {
             Augmentations attrAugs = attributes.getAugmentations(attrIndx);
-            AttributePSVImpl attrPSVI = (AttributePSVImpl) attrAugs.getItem
-                                                    (Constants.ATTRIBUTE_PSVI);
-            XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) 
attrPSVI.
-                                                       getTypeDefinition();
+            AttributePSVImpl attrPSVI = (AttributePSVImpl) 
attrAugs.getItem(Constants.ATTRIBUTE_PSVI);
+            XSSimpleTypeDefinition attrType = (XSSimpleTypeDefinition) 
attrPSVI.getTypeDefinition();
             if (attrType != null) {
-                // this accumulates assertions only for simpleType -> 
-                // restriction.
+                // this accumulates assertions only for simpleType -> 
restriction
                 XSObjectList facets = attrType.getMultiValueFacets();
 
                 // simpleType variety is 'unknown/absent' at the moment        
            
@@ -268,21 +238,15 @@ public class XSDAssertionValidator {
                 if (facets.getLength() == 0 && attrType.getItemType() != null) 
{
                     // facets for simpleType -> list
                     attrTypeVariety = XSSimpleTypeDefinition.VARIETY_LIST;
-                    facets = (XSObjectListImpl) attrType.getItemType().
-                                                           
getMultiValueFacets();    
+                    facets = (XSObjectListImpl) 
attrType.getItemType().getMultiValueFacets();    
                 }
-                else if (attrType.getVariety() == XSSimpleTypeDefinition.
-                                                                 
VARIETY_UNION) {
+                else if (attrType.getVariety() == 
XSSimpleTypeDefinition.VARIETY_UNION) {
                     attrTypeVariety = XSSimpleTypeDefinition.VARIETY_UNION;
-                    // Special handling for assertions on simpleType -> union
-                    // cases. Adding an assertion here, for determining the
-                    // NamespaceContext.
-                    // This particular assertion object is not actually 
evaluated.
-                    // For union types, assertions are later again determined
-                    // in XMLAssertPsychopathImpl, which are evaluated to 
determine
-                    // validity of an XML instance.               
-                    XSAssertImpl assertImpl = 
getFirstAssertFromUnionMemberTypes(
-                                                        
attrType.getMemberTypes());
+                    // Special handling for assertions on "simpleType -> 
union" cases. Adding an assertion here,
+                    // for determining the XSModel NamespaceContext. This 
particular assertion object is not 
+                    // actually evaluated. For simpleType's with variety 
union, assertions are later again determined 
+                    // in XMLAssertPsychopathImpl, which are evaluated to 
determine validity of an XML instance.               
+                    XSAssertImpl assertImpl = 
getFirstAssertFromUnionMemberTypes(attrType.getMemberTypes());
                     if (assertImpl != null) {
                         assertImpl.setTypeDefinition(attrType);
                         assertImpl.setVariety(attrTypeVariety);
@@ -292,23 +256,16 @@ public class XSDAssertionValidator {
                     }
                 }
 
-                // iterate all the facets, for attributes having the 'simple
-                // type' variety "atomic | list", and accumulate assertions
-                // from them.
-                for (int facetIdx = 0; facetIdx < facets.getLength(); 
-                                                               facetIdx++) {
-                    XSMultiValueFacet facet = (XSMultiValueFacet) facets.item
-                                                                    (facetIdx);
-                    if (facet.getFacetKind() == XSSimpleTypeDefinition.
-                                                               FACET_ASSERT) {
+                // iterate all the facets, for attributes having the 
simpleType variety "atomic | list", and
+                // accumulate assertions from them.
+                for (int facetIdx = 0; facetIdx < facets.getLength(); 
facetIdx++) {
+                    XSMultiValueFacet facet = (XSMultiValueFacet) 
facets.item(facetIdx);
+                    if (facet.getFacetKind() == 
XSSimpleTypeDefinition.FACET_ASSERT) {
                         Vector attrAsserts = facet.getAsserts();
                         for (int j = 0; j < attrAsserts.size(); j++) {
-                            XSAssertImpl attrAssert = (XSAssertImpl) 
-                                                         
attrAsserts.elementAt(j);
-                            attrAssert.setAttrName(attributes.getLocalName
-                                                                 (attrIndx));
-                            attrAssert.setAttrValue(attributes.getValue
-                                                                 (attrIndx));
+                            XSAssertImpl attrAssert = (XSAssertImpl) 
attrAsserts.elementAt(j);
+                            
attrAssert.setAttrName(attributes.getLocalName(attrIndx));
+                            
attrAssert.setAttrValue(attributes.getValue(attrIndx));
                             attrAssert.setVariety(attrTypeVariety);            
                    
                             attrAssertList.addXSObject(attrAssert);    
                         }
@@ -331,35 +288,28 @@ public class XSDAssertionValidator {
         
         List simpleTypeAsserts = null;
 
-        XSSimpleTypeDefinition simpleTypeDef = (XSSimpleTypeDefinition) 
-                                                             typeDef;          
           
+        XSSimpleTypeDefinition simpleTypeDef = (XSSimpleTypeDefinition) 
typeDef;                     
 
-        XSObjectListImpl facets = (XSObjectListImpl) simpleTypeDef.
-                                                    getMultiValueFacets();
+        XSObjectListImpl facets = (XSObjectListImpl) 
simpleTypeDef.getMultiValueFacets();
 
         if (facets.getLength() == 0 && simpleTypeDef.getItemType() != null) {
             // facets for simpleType -> list
-            facets = (XSObjectListImpl) simpleTypeDef.getItemType().
-                                                        getMultiValueFacets(); 
   
+            facets = (XSObjectListImpl) 
simpleTypeDef.getItemType().getMultiValueFacets();    
         }
-        else if (simpleTypeDef.getVariety() == XSSimpleTypeDefinition.
-                                                            VARIETY_UNION) {
-            // Special handling for assertions on simpleType -> union
-            // cases. Adding an assertion here, for determining the
-            // NamespaceContext.
-            XSAssertImpl assertImpl = getFirstAssertFromUnionMemberTypes(
-                                              simpleTypeDef.getMemberTypes());
+        else if (simpleTypeDef.getVariety() == 
XSSimpleTypeDefinition.VARIETY_UNION) {
+            // Special handling for assertions on simpleType -> union cases. 
Adding an assertion here,
+            // for determining the NamespaceContext.
+            XSAssertImpl assertImpl = 
getFirstAssertFromUnionMemberTypes(simpleTypeDef.getMemberTypes());
             if (assertImpl != null) {
                 simpleTypeAsserts = new Vector();
                 simpleTypeAsserts.add(assertImpl);
             }
         }
 
-        // iterate all the facets, having the 'simple type' variety "atomic | 
-        // list", and accumulate assertions from them.
+        // iterate all the facets, having the 'simple type' variety "atomic | 
list", and accumulate assertions
+        // from them.
         for (int facetIdx = 0; facetIdx < facets.getLength(); facetIdx++) {
-            XSMultiValueFacet facet = (XSMultiValueFacet) facets.item(
-                                                               facetIdx);
+            XSMultiValueFacet facet = (XSMultiValueFacet) 
facets.item(facetIdx);
             if (facet.getFacetKind() == XSSimpleTypeDefinition.FACET_ASSERT) {
                 if (simpleTypeAsserts == null) {
                     simpleTypeAsserts = new Vector();   
@@ -374,32 +324,24 @@ public class XSDAssertionValidator {
     
     
     /*
-     * Get the 1st assertion from the member types of union. Needed to get 
-     * an schema 'namespace context', which is available for example, in the
-     * 1st assertion in the assertions list.
+     * Get the 1st assertion from the member types of simpleType union. Needed 
to get an schema
+     * "namespace context", which is available for example, in the 1st 
assertion in the assertions
+     * list.
      */
-    private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList 
-                                                             memberTypes) {
+    private XSAssertImpl getFirstAssertFromUnionMemberTypes(XSObjectList 
memberTypes) {
         
         XSAssertImpl assertImpl = null;
         
-        for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength();
-                                                       memberTypeIdx++) {
-            XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition) 
-                                          memberTypes.item(memberTypeIdx);
-            if (!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.
-                                                      getNamespace())) {
+        for (int memberTypeIdx = 0; memberTypeIdx < memberTypes.getLength(); 
memberTypeIdx++) {
+            XSSimpleTypeDefinition memType = (XSSimpleTypeDefinition) 
memberTypes.item(memberTypeIdx);
+            if 
(!SchemaSymbols.URI_SCHEMAFORSCHEMA.equals(memType.getNamespace())) {
                 XSObjectList memberTypeFacets = memType.getMultiValueFacets();
-                for (int memberTypeFacetIdx = 0; memberTypeFacetIdx < 
-                                                   
memberTypeFacets.getLength(); 
-                                                   memberTypeFacetIdx++) {
-                    XSMultiValueFacet facet = (XSMultiValueFacet) 
-                                    memberTypeFacets.item(memberTypeFacetIdx);
-                    if (facet.getFacetKind() == XSSimpleTypeDefinition.
-                                                              FACET_ASSERT) {
+                for (int memberTypeFacetIdx = 0; memberTypeFacetIdx < 
memberTypeFacets.getLength(); 
+                                                                               
    memberTypeFacetIdx++) {
+                    XSMultiValueFacet facet = (XSMultiValueFacet) 
memberTypeFacets.item(memberTypeFacetIdx);
+                    if (facet.getFacetKind() == 
XSSimpleTypeDefinition.FACET_ASSERT) {
                         Vector assertFacets = facet.getAsserts();
-                        assertImpl = (XSAssertImpl) assertFacets.get(0);
-                        
+                        assertImpl = (XSAssertImpl) assertFacets.get(0);       
                 
                         // return the 1st assertion that's found
                         return assertImpl;
                     }
@@ -417,19 +359,16 @@ public class XSDAssertionValidator {
      */
     private void initializeAssertProcessor(Map assertParams) {
         
-        String assertProcessorProp = System
-                .getProperty("org.apache.xerces.assertProcessor");
+        String assertProcessorProp = 
System.getProperty("org.apache.xerces.assertProcessor");
         
         if (assertProcessorProp == null || assertProcessorProp.equals("")) {
-            // if assertion processor is not specified via a system
-            // property, initialize it to the "PsychoPath XPath 2.0" processor.
+            // if assertion processor is not specified via a system property, 
initialize it to
+            // the "PsychoPath XPath 2.0" processor.
             fAssertionProcessor = new XMLAssertPsychopathImpl(assertParams);
         } else {
             try {
-                Class assertClass = ClassLoader.getSystemClassLoader()
-                        .loadClass(assertProcessorProp);
-                fAssertionProcessor = (XMLAssertHandler) 
-                                             assertClass.newInstance();
+                Class assertClass = 
ClassLoader.getSystemClassLoader().loadClass(assertProcessorProp);
+                fAssertionProcessor = (XMLAssertHandler) 
assertClass.newInstance();
             } catch (ClassNotFoundException ex) {
                 throw new XNIException(ex.getMessage(), ex);
             } catch (InstantiationException ex) {
@@ -439,10 +378,8 @@ public class XSDAssertionValidator {
             }
         }
         
-        fAssertionProcessor.setProperty
-                    ("http://apache.org/xml/properties/assert/validator";, 
-                                                      xmlSchemaValidator);
+        
fAssertionProcessor.setProperty("http://apache.org/xml/properties/assert/validator";,
 xmlSchemaValidator);
         
     } // initializeAssertProcessor
     
-} // class XMLAssertionValidator
+} // class XSDAssertionValidator



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

Reply via email to