Author: nickarls
Date: 2009-03-18 08:49:03 -0400 (Wed, 18 Mar 2009)
New Revision: 2091
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
Log:
some xsd stuff
Modified:
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java
===================================================================
---
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-18
12:29:51 UTC (rev 2090)
+++
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/helpers/DataSetter.java 2009-03-18
12:49:03 UTC (rev 2091)
@@ -17,6 +17,9 @@
package org.jboss.webbeans.xsd.helpers;
+import java.util.HashMap;
+import java.util.Map;
+
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.element.Modifier;
@@ -35,7 +38,13 @@
*/
public class DataSetter
{
-
+ public static Map<TypedModel, TypedModel> typeSubstitutions = new
HashMap<TypedModel, TypedModel>()
+ {
+ private static final long serialVersionUID = 8092480390430415094L;
+ {
+ put(TypedModel.of("java.lang.String", false),
TypedModel.of("string", true));
+ }};
+
/**
* Checks if an element is public
*
@@ -83,6 +92,7 @@
{
boolean primitive = parameterElement.asType().getKind().isPrimitive();
TypedModel parameter = new TypedModel(parameterElement.asType().toString(),
primitive);
+ parameter = typeSubstitutions.containsKey(parameter) ?
typeSubstitutions.get(parameter) : parameter;
method.addParameter(parameter);
}
// OK, cheating a little with a common model for methods and constructors
Modified: extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java
===================================================================
---
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java 2009-03-18
12:29:51 UTC (rev 2090)
+++
extensions/trunk/xsd/src/main/java/org/jboss/webbeans/xsd/model/TypedModel.java 2009-03-18
12:49:03 UTC (rev 2091)
@@ -83,13 +83,14 @@
@Override
public boolean equals(Object other)
{
- return type.equals(other);
+ TypedModel otherType = (TypedModel) other;
+ return type.equals(otherType.getType()) && primitive ==
otherType.isPrimitive();
}
@Override
public int hashCode()
{
- return type.hashCode();
+ return type.hashCode() + (isPrimitive() ? 0 : 1);
}
public Element toXSD(NamespaceHandler namespaceHandler)
@@ -100,4 +101,9 @@
return item;
}
+ public static TypedModel of(String type, boolean primitive)
+ {
+ return new TypedModel(type, primitive);
+ }
+
}