src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java

changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 637
9c07ef4934dd
     1.1 --- a/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java	Thu Apr 04 19:05:24 2013 -0700
     1.2 +++ b/src/share/jaxws_classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java	Tue Apr 09 14:51:13 2013 +0100
     1.3 @@ -49,16 +49,19 @@
     1.4  import com.sun.codemodel.internal.JExpression;
     1.5  import com.sun.codemodel.internal.JType;
     1.6  import com.sun.tools.internal.xjc.model.nav.NClass;
     1.7 +import com.sun.xml.internal.bind.v2.model.annotation.Locatable;
     1.8 +import com.sun.xml.internal.bind.v2.model.core.BuiltinLeafInfo;
     1.9 +import com.sun.xml.internal.bind.v2.model.core.Element;
    1.10 +import com.sun.xml.internal.bind.v2.model.core.LeafInfo;
    1.11 +import com.sun.xml.internal.bind.v2.runtime.Location;
    1.12  import com.sun.tools.internal.xjc.model.nav.NType;
    1.13  import com.sun.tools.internal.xjc.model.nav.NavigatorImpl;
    1.14  import com.sun.tools.internal.xjc.outline.Aspect;
    1.15  import com.sun.tools.internal.xjc.outline.Outline;
    1.16  import com.sun.tools.internal.xjc.runtime.ZeroOneBooleanAdapter;
    1.17  import com.sun.tools.internal.xjc.util.NamespaceContextAdapter;
    1.18 -import com.sun.xml.internal.bind.DatatypeConverterImpl;
    1.19  import com.sun.xml.internal.bind.v2.WellKnownNamespace;
    1.20  import com.sun.xml.internal.bind.v2.model.core.ID;
    1.21 -import com.sun.xml.internal.bind.v2.model.impl.BuiltinLeafInfoImpl;
    1.22  import com.sun.xml.internal.xsom.XSComponent;
    1.23  import com.sun.xml.internal.xsom.XmlString;
    1.24  
    1.25 @@ -92,13 +95,23 @@
    1.26   *
    1.27   * @author Kohsuke Kawaguchi
    1.28   */
    1.29 -public abstract class CBuiltinLeafInfo extends BuiltinLeafInfoImpl<NType,NClass> implements CNonElement {
    1.30 +public abstract class CBuiltinLeafInfo implements CNonElement, BuiltinLeafInfo<NType,NClass>, LeafInfo<NType,NClass>, Location {
    1.31 +
    1.32 +    private final NType type;
    1.33 +    /**
    1.34 +     * Can be null for anonymous types.
    1.35 +     */
    1.36 +    private final QName typeName;
    1.37 +
    1.38 +    private final QName[] typeNames;
    1.39  
    1.40      private final ID id;
    1.41  
    1.42      // no derived class other than the spec-defined ones. definitely not for enum.
    1.43 -    private CBuiltinLeafInfo(NType typeToken, QName typeName, ID id) {
    1.44 -        super(typeToken,typeName);
    1.45 +    private CBuiltinLeafInfo(NType typeToken, ID id, QName... typeNames) {
    1.46 +        this.type = typeToken;
    1.47 +        this.typeName = typeNames.length>0?typeNames[0]:null;
    1.48 +        this.typeNames = typeNames;
    1.49          this.id = id;
    1.50      }
    1.51  
    1.52 @@ -172,6 +185,73 @@
    1.53      }
    1.54  
    1.55      /**
    1.56 +     * @deprecated always return false at this level.
    1.57 +     */
    1.58 +    public final boolean isElement() {
    1.59 +        return false;
    1.60 +    }
    1.61 +
    1.62 +    /**
    1.63 +     * @deprecated always return null at this level.
    1.64 +     */
    1.65 +    public final QName getElementName() {
    1.66 +        return null;
    1.67 +    }
    1.68 +
    1.69 +    /**
    1.70 +     * @deprecated always return null at this level.
    1.71 +     */
    1.72 +    public final Element<NType,NClass> asElement() {
    1.73 +        return null;
    1.74 +    }
    1.75 +
    1.76 +    /**
    1.77 +     * A reference to the representation of the type.
    1.78 +     */
    1.79 +    public NType getType() {
    1.80 +        return type;
    1.81 +    }
    1.82 +
    1.83 +    /**
    1.84 +     * Returns all the type names recognized by this bean info.
    1.85 +     *
    1.86 +     * @return
    1.87 +     *      do not modify the returned array.
    1.88 +     */
    1.89 +    public final QName[] getTypeNames() {
    1.90 +        return typeNames;
    1.91 +    }
    1.92 +
    1.93 +    /**
    1.94 +     * Leaf-type cannot be referenced from IDREF.
    1.95 +     *
    1.96 +     * @deprecated
    1.97 +     *      why are you calling a method whose return value is always known?
    1.98 +     */
    1.99 +    public final boolean canBeReferencedByIDREF() {
   1.100 +        return false;
   1.101 +    }
   1.102 +
   1.103 +    public QName getTypeName() {
   1.104 +        return typeName;
   1.105 +    }
   1.106 +
   1.107 +    public Locatable getUpstream() {
   1.108 +        return null;
   1.109 +    }
   1.110 +
   1.111 +    public Location getLocation() {
   1.112 +        // this isn't very accurate, but it's not too bad
   1.113 +        // doing it correctly need leaves to hold navigator.
   1.114 +        // otherwise revisit the design so that we take navigator as a parameter
   1.115 +        return this;
   1.116 +    }
   1.117 +
   1.118 +    public boolean isSimpleType() {
   1.119 +        return true;
   1.120 +    }
   1.121 +
   1.122 +    /**
   1.123       * {@link CBuiltinLeafInfo} for Java classes that have
   1.124       * the spec defined built-in binding semantics.
   1.125       */
   1.126 @@ -180,7 +260,7 @@
   1.127              this(c,typeName,com.sun.xml.internal.bind.v2.model.core.ID.NONE);
   1.128          }
   1.129          protected Builtin(Class c, String typeName, ID id) {
   1.130 -            super(NavigatorImpl.theInstance.ref(c), new QName(WellKnownNamespace.XML_SCHEMA,typeName),id);
   1.131 +            super(NavigatorImpl.theInstance.ref(c), id, new QName(WellKnownNamespace.XML_SCHEMA,typeName));
   1.132              LEAVES.put(getType(),this);
   1.133          }
   1.134  
   1.135 @@ -215,46 +295,46 @@
   1.136      };
   1.137      public static final CBuiltinLeafInfo BOOLEAN = new Builtin(Boolean.class,"boolean") {
   1.138              public JExpression createConstant(Outline outline, XmlString lexical) {
   1.139 -                return JExpr.lit(DatatypeConverterImpl._parseBoolean(lexical.value));
   1.140 +                return JExpr.lit(DatatypeConverter.parseBoolean(lexical.value));
   1.141              }
   1.142      };
   1.143      public static final CBuiltinLeafInfo INT = new Builtin(Integer.class,"int") {
   1.144          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.145 -            return JExpr.lit(DatatypeConverterImpl._parseInt(lexical.value));
   1.146 +            return JExpr.lit(DatatypeConverter.parseInt(lexical.value));
   1.147          }
   1.148      };
   1.149      public static final CBuiltinLeafInfo LONG = new Builtin(Long.class,"long") {
   1.150          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.151 -            return JExpr.lit(DatatypeConverterImpl._parseLong(lexical.value));
   1.152 +            return JExpr.lit(DatatypeConverter.parseLong(lexical.value));
   1.153          }
   1.154      };
   1.155      public static final CBuiltinLeafInfo BYTE = new Builtin(Byte.class,"byte") {
   1.156          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.157              return JExpr.cast(
   1.158                      outline.getCodeModel().BYTE,
   1.159 -                    JExpr.lit(DatatypeConverterImpl._parseByte(lexical.value)));
   1.160 +                    JExpr.lit(DatatypeConverter.parseByte(lexical.value)));
   1.161          }
   1.162      };
   1.163      public static final CBuiltinLeafInfo SHORT = new Builtin(Short.class,"short") {
   1.164          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.165              return JExpr.cast(
   1.166                      outline.getCodeModel().SHORT,
   1.167 -                    JExpr.lit(DatatypeConverterImpl._parseShort(lexical.value)));
   1.168 +                    JExpr.lit(DatatypeConverter.parseShort(lexical.value)));
   1.169          }
   1.170      };
   1.171      public static final CBuiltinLeafInfo FLOAT = new Builtin(Float.class,"float") {
   1.172          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.173 -            return JExpr.lit(DatatypeConverterImpl._parseFloat(lexical.value));
   1.174 +            return JExpr.lit(DatatypeConverter.parseFloat(lexical.value));
   1.175          }
   1.176      };
   1.177      public static final CBuiltinLeafInfo DOUBLE = new Builtin(Double.class,"double") {
   1.178          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.179 -            return JExpr.lit(DatatypeConverterImpl._parseDouble(lexical.value));
   1.180 +            return JExpr.lit(DatatypeConverter.parseDouble(lexical.value));
   1.181          }
   1.182      };
   1.183      public static final CBuiltinLeafInfo QNAME = new Builtin(QName.class,"QName") {
   1.184          public JExpression createConstant(Outline outline, XmlString lexical) {
   1.185 -            QName qn = DatatypeConverterImpl._parseQName(lexical.value,new NamespaceContextAdapter(lexical));
   1.186 +            QName qn = DatatypeConverter.parseQName(lexical.value,new NamespaceContextAdapter(lexical));
   1.187              return JExpr._new(outline.getCodeModel().ref(QName.class))
   1.188                  .arg(qn.getNamespaceURI())
   1.189                  .arg(qn.getLocalPart())

mercurial