[jboss-svn-commits] JBossWS SVN: r1025 - in branches/jbossws-1.0/src/main/java/org/jboss/ws/tools: . helpers
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Sep 20 10:30:52 EDT 2006
Author: david.boeren
Date: 2006-09-20 10:30:47 -0400 (Wed, 20 Sep 2006)
New Revision: 1025
Modified:
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/JavaWriter.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/ToolsUtils.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
Log:
Applied fix for JBWS-1170, converting WSDL/XSD illegal characters to underscores in java variable names
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/JavaWriter.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/JavaWriter.java 2006-09-20 14:10:32 UTC (rev 1024)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/JavaWriter.java 2006-09-20 14:30:47 UTC (rev 1025)
@@ -347,6 +347,9 @@
{
VAR v = (VAR)iter.next();
String name = v.getVarname();
+ // JBWS-1170 Convert characters which are illegal in Java identifiers
+ name=ToolsUtils.convertInvalidCharacters(name);
+
String type = v.getVartype();
boolean isArr = v.isArrayType();
buf.append(newline);
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java 2006-09-20 14:10:32 UTC (rev 1024)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/NamespacePackageMapping.java 2006-09-20 14:30:47 UTC (rev 1025)
@@ -166,7 +166,7 @@
current = current.toLowerCase();
current = convertReserved(current);
current = convertStart(current);
- current = convertInvalidCharacters(current);
+ current = ToolsUtils.convertInvalidCharacters(current);
packageName.append(current);
if (i < tokens.length - 1)
@@ -210,24 +210,6 @@
}
/**
- * Check all of the characters in the component and for any that are not valid
- * in Java identifiers replace with an underscore.
- */
- private String convertInvalidCharacters(final String component)
- {
- String result = component;
- for (int i = 0; i < result.length(); i++)
- {
- if (Character.isJavaIdentifierPart(result.charAt(i)) == false)
- {
- result = result.replace(result.charAt(i), '_');
- }
- }
-
- return result;
- }
-
- /**
* Given a domain name split it into the corresponding parts, and convert
* into the order suitable for creating a package name.
*
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/ToolsUtils.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/ToolsUtils.java 2006-09-20 14:10:32 UTC (rev 1024)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/ToolsUtils.java 2006-09-20 14:30:47 UTC (rev 1025)
@@ -474,7 +474,24 @@
{
if(typeMapping.isRegistered(clazz,xmlType) == false )
typeMapping.register(clazz,xmlType, new SimpleSerializerFactory(), new SimpleDeserializerFactory());
+ }
+ /**
+ * Check all of the characters in the component and for any that are not valid
+ * in Java identifiers replace with an underscore.
+ */
+ public static String convertInvalidCharacters(final String component)
+ {
+ String result = component;
+ for (int i = 0; i < result.length(); i++)
+ {
+ if (Character.isJavaIdentifierPart(result.charAt(i)) == false)
+ {
+ result = result.replace(result.charAt(i), '_');
+ }
+ }
+
+ return result;
}
//Private methods
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2006-09-20 14:10:32 UTC (rev 1024)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/XSDTypeToJava.java 2006-09-20 14:30:47 UTC (rev 1025)
@@ -530,7 +530,7 @@
throws IOException
{
List <VAR> vars = new ArrayList<VAR>();
- // Handle xsd:any elements
+ // Handle xsd:any elements
if (xsterm instanceof XSWildcard)
{
XSWildcard xsw = (XSWildcard)xsterm;
@@ -542,7 +542,7 @@
// }
}
- // Handle xsd:group
+ // Handle xsd:group
if (xsterm instanceof XSModelGroup)
{
vars.addAll(createVARsforXSModelGroup((XSModelGroup)xsterm, schema, origType));
@@ -553,7 +553,7 @@
- // TODO:Check if the element contains any anon complex type
+ // TODO: Check if the element contains any anon complex type
// TODO: If yes, create class that is ComplexTypeName+ElementName
// TODO: ItemsItem If the elem contains anon simpletype
// TODO: No need to create seperate Java class
@@ -562,12 +562,11 @@
XSTypeDefinition xstypedef = elem.getTypeDefinition();
String xstypename = xstypedef.getName();
-
- // Check if it is a composite type
+ // Check if it is a composite type
if(xstypename != null && xstypedef.getName().equals(origType.getName())
&& xstypedef.getNamespace().equals(origType.getNamespace()))
{
- // it is a composite type
+ // it is a composite type
QName qn = new QName(origType.getNamespace(),origType.getName());
VAR vr = createVAR(qn, elem, (XSComplexTypeDefinition)xstypedef, tname, pkgname, arrayType);
vars.add(vr);
@@ -579,16 +578,16 @@
{
XSComplexTypeDefinition xsc = (XSComplexTypeDefinition)xstypedef;
String subname = utils.firstLetterUpperCase(tname);
- // Save the fname in a temp var
+ // Save the fname in a temp var
String tempfname = this.fname;
- // it will be an anonymous type
+ // it will be an anonymous type
String anonName = fname + subname;
this.fname = anonName;
this.createJavaFile((XSComplexTypeDefinition)xstypedef, schema, false);
- // Restore the fname
+ // Restore the fname
this.fname = tempfname;
- // Bypass rest of processing
+ // Bypass rest of processing
QName anonqn = new QName(anonName);
VAR vr = createVAR(anonqn, elem, xsc, tname, pkgname, arrayType);
vars.add(vr);
Modified: branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java
===================================================================
--- branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2006-09-20 14:10:32 UTC (rev 1024)
+++ branches/jbossws-1.0/src/main/java/org/jboss/ws/tools/helpers/MappingFileGeneratorHelper.java 2006-09-20 14:30:47 UTC (rev 1025)
@@ -597,7 +597,8 @@
XSElementDeclaration xe = (XSElementDeclaration) xsterm;
VariableMapping vm = new VariableMapping(jxtm);
String name = xe.getName();
- vm.setJavaVariableName(Introspector.decapitalize(name));
+ // JBWS-1170 Convert characters which are illegal in Java identifiers
+ vm.setJavaVariableName(ToolsUtils.convertInvalidCharacters(Introspector.decapitalize(name)));
vm.setXmlElementName(name);
jxtm.addVariableMapping(vm);
}
@@ -615,7 +616,8 @@
VariableMapping vm = new VariableMapping(jxtm);
String name = att.getName();
vm.setXmlAttributeName(name);
- vm.setJavaVariableName(Introspector.decapitalize(name));
+ // JBWS-1170 Convert characters which are illegal in Java identifiers
+ vm.setJavaVariableName(ToolsUtils.convertInvalidCharacters(Introspector.decapitalize(name)));
jxtm.addVariableMapping(vm);
}
}
More information about the jboss-svn-commits
mailing list