You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by sa...@apache.org on 2012/07/12 10:08:15 UTC
svn commit: r1360573 - in /axis/axis2/java/core/trunk/modules/adb-codegen:
./ src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/
src/org/apache/axis2/schema/writer/ test-resources/xsd/
test/org/apache/axis2/schema/fix/
Author: sagara
Date: Thu Jul 12 08:08:14 2012
New Revision: 1360573
URL: http://svn.apache.org/viewvc?rev=1360573&view=rev
Log:
Added modification to fix AXIS2-4356 and test cases.
Added:
axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd (with props)
axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/
axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java (with props)
Modified:
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?rev=1360573&r1=1360572&r2=1360573&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Thu Jul 12 08:08:14 2012
@@ -80,6 +80,7 @@ public class BeanWriterMetaInfoHolder {
protected String itemTypeClassName;
protected boolean isUnion;
protected boolean isList;
+ protected boolean fixed = false;
protected boolean isParticleClass;
// keep whether this class has a partical class type variable
@@ -941,6 +942,14 @@ public class BeanWriterMetaInfoHolder {
public QName getRestrictionBaseType() {
return restrictionBaseType;
+ }
+
+ public boolean isFixed() {
+ return fixed;
+ }
+
+ public void setFixed(boolean fixed) {
+ this.fixed = fixed;
}
@Override
@@ -966,7 +975,7 @@ public class BeanWriterMetaInfoHolder {
+ restrictionBaseType + ", restrictionClassName=" + restrictionClassName
+ ", simple=" + simple + ", specialTypeFlagMap=" + specialTypeFlagMap
+ ", totalDigitsFacet=" + totalDigitsFacet + ", xmlNameJavaNameMap="
- + xmlNameJavaNameMap + "]";
+ + xmlNameJavaNameMap + ", xmlNameJavaNameMap=" + fixed + "]";
}
}
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java?rev=1360573&r1=1360572&r2=1360573&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/SchemaCompiler.java Thu Jul 12 08:08:14 2012
@@ -547,6 +547,12 @@ public class SchemaCompiler {
metainf.registerDefaultValue(xsElt.getQName(),xsElt.getDefaultValue());
}
+ // register the fixed value if present
+ if (xsElt.getFixedValue() != null){
+ metainf.registerDefaultValue(xsElt.getQName(),xsElt.getFixedValue());
+ metainf.setFixed(true);
+ }
+
if (isBinary(xsElt)) {
metainf.addtStatus(xsElt.getQName(),
SchemaConstants.BINARY_TYPE);
@@ -1819,6 +1825,10 @@ public class SchemaCompiler {
// set the default value
if (att.getDefaultValue() != null){
metainf.registerDefaultValue(att.getQName(),att.getDefaultValue());
+ }
+ if(att.getFixedValue() != null){
+ metainf.registerDefaultValue(att.getQName(), att.getFixedValue());
+ metainf.setFixed(true);
}
// after
} else {
@@ -2226,7 +2236,11 @@ public class SchemaCompiler {
if (elt.getDefaultValue() != null){
metainfHolder.registerDefaultValue(referencedQName,elt.getDefaultValue());
}
-
+ // register the default value as well
+ if (elt.getFixedValue() != null){
+ metainfHolder.registerDefaultValue(referencedQName,elt.getFixedValue());
+ metainfHolder.setFixed(true);
+ }
}
}
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl?rev=1360573&r1=1360572&r2=1360573&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate-bean.xsl Thu Jul 12 08:08:14 2012
@@ -116,6 +116,7 @@
<xsl:variable name="maxInFacet"><xsl:value-of select="@maxInFacet"/></xsl:variable>
<xsl:variable name="minInFacet"><xsl:value-of select="@minInFacet"/></xsl:variable>
<xsl:variable name="patternFacet"><xsl:value-of select="@patternFacet"/></xsl:variable>
+ <xsl:variable name="fixed" select="@fixed"/>
<xsl:variable name="shortTypeNameUncapped" select="@shorttypename"/>
<xsl:variable name="shortTypeName"
select="concat(translate( substring($shortTypeNameUncapped, 1, 1 ),'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ), substring($shortTypeNameUncapped, 2, string-length($shortTypeNameUncapped)))" />
@@ -539,7 +540,9 @@
</xsl:when>
<xsl:otherwise>
+ <xsl:if test="not($fixed)">
this.<xsl:value-of select="$varName"/>=param;
+ </xsl:if>
</xsl:otherwise>
</xsl:choose>
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?rev=1360573&r1=1360572&r2=1360573&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Thu Jul 12 08:08:14 2012
@@ -879,6 +879,10 @@ public class JavaBeanWriter implements B
if (metainf.getInnerChoiceStatusForQName(name)){
XSLTUtils.addAttribute(model, "innerchoice", "yes", property);
}
+
+ if (metainf.isFixed()){
+ XSLTUtils.addAttribute(model, "fixed", "yes", property);
+ }
Modified: axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml?rev=1360573&r1=1360572&r2=1360573&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/sub-build.xml Thu Jul 12 08:08:14 2012
@@ -85,6 +85,7 @@
<arg file="${testsuite.source.dir}/unqualified/companyservice.xsd"/>
<arg file="${testsuite.source.dir}/names.xsd"/> <!-- compile only; no tests -->
<arg file="${testsuite.source.dir}/std-schemas.xsd"/> <!-- compile only; no tests -->
+ <arg file="${schema.source.dir}/fixed_value.xsd"/>
<arg file="${schema.generated.src.dir}"/>
</java>
<java classname="org.apache.axis2.schema.XSD2Java" fork="true" failonerror="true">
Added: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd?rev=1360573&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd (added)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd Thu Jul 12 08:08:14 2012
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ 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. -->
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="fixedStringElement" type="fixedString" />
+ <xs:complexType name="fixedString">
+ <xs:sequence>
+ <xs:element minOccurs="0" name="msg" fixed="ABC"
+ type="xs:string" />
+ </xs:sequence>
+ </xs:complexType>
+</xs:schema>
\ No newline at end of file
Propchange: axis/axis2/java/core/trunk/modules/adb-codegen/test-resources/xsd/fixed_value.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Added: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java?rev=1360573&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java (added)
+++ axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java Thu Jul 12 08:08:14 2012
@@ -0,0 +1,105 @@
+/*
+ * 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.axis2.schema.fix;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+
+import axis2.apache.org.FixedString;
+import axis2.apache.org.FixedStringElement;
+
+import junit.framework.TestCase;
+
+public class FixedValueTest extends TestCase {
+
+ public static String ERROR_MSG = "Input values do not follow defined XSD restrictions";
+
+ public void testFixedStringElement1() throws Exception {
+ FixedStringElement fixElement = new FixedStringElement();
+ FixedString fixedString = new FixedString();
+ fixedString.setMsg("XYZ");
+ fixElement.setFixedStringElement(fixedString);
+ OMElement omElement = fixElement.getOMElement(FixedStringElement.MY_QNAME,
+ OMAbstractFactory.getSOAP11Factory());
+ }
+
+ public void testFixedStringElement2() throws Exception {
+ FixedStringElement fixElement = new FixedStringElement();
+ FixedString fixedString = new FixedString();
+ fixedString.setMsg("");
+ fixElement.setFixedStringElement(fixedString);
+ OMElement omElement = fixElement.getOMElement(FixedStringElement.MY_QNAME,
+ OMAbstractFactory.getSOAP11Factory());
+ }
+
+ public void testFixedStringElement3() throws Exception {
+ FixedStringElement fixElement = new FixedStringElement();
+ FixedString fixedString = new FixedString();
+ fixedString.setMsg("");
+ fixElement.setFixedStringElement(fixedString);
+ OMElement omElement = fixElement.getOMElement(FixedStringElement.MY_QNAME,
+ OMAbstractFactory.getSOAP11Factory());
+ }
+
+ public void testFixedStringElementParse1() throws Exception {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new QName("", "fixedStringElement"));
+ OMElement msg = factory.createOMElement(new QName("", "msg"));
+ msg.setText("xyz");
+ element.addChild(msg);
+ FixedStringElement fixedStringElement = FixedStringElement.Factory.parse(element
+ .getXMLStreamReader());
+ assertNotNull(fixedStringElement.getFixedStringElement().getMsg());
+ assertEquals("ABC", fixedStringElement.getFixedStringElement().getMsg());
+ assertFalse("xyz".equalsIgnoreCase(fixedStringElement.getFixedStringElement().getMsg()));
+
+ }
+
+ public void testFixedStringElementParse2() throws Exception {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new QName("", "fixedStringElement"));
+ OMElement msg = factory.createOMElement(new QName("", "msg"));
+ msg.setText("");
+ element.addChild(msg);
+ FixedStringElement fixedStringElement = FixedStringElement.Factory.parse(element
+ .getXMLStreamReader());
+ assertNotNull(fixedStringElement.getFixedStringElement().getMsg());
+ assertEquals("ABC", fixedStringElement.getFixedStringElement().getMsg());
+ assertFalse("".equalsIgnoreCase(fixedStringElement.getFixedStringElement().getMsg()));
+
+ }
+
+ public void testFixedStringElementParse3() throws Exception {
+ OMFactory factory = OMAbstractFactory.getOMFactory();
+ OMElement element = factory.createOMElement(new QName("", "fixedStringElement"));
+ OMElement msg = factory.createOMElement(new QName("", "msg"));
+ element.addChild(msg);
+ FixedStringElement fixedStringElement = FixedStringElement.Factory.parse(element
+ .getXMLStreamReader());
+ assertNotNull(fixedStringElement.getFixedStringElement().getMsg());
+ assertEquals("ABC", fixedStringElement.getFixedStringElement().getMsg());
+ assertFalse(fixedStringElement.getFixedStringElement().getMsg() == null);
+
+ }
+
+}
\ No newline at end of file
Propchange: axis/axis2/java/core/trunk/modules/adb-codegen/test/org/apache/axis2/schema/fix/FixedValueTest.java
------------------------------------------------------------------------------
svn:eol-style = native