Package com.sun.codemodel

Examples of com.sun.codemodel.JAnnotationUse


      JFieldVar field = clazz.field(JMod.PRIVATE, javaType, realVariableName);
     
      if (xmlTransient == false)
      {
         // define XmlElement annotation for variable
         JAnnotationUse annotation = field.annotate(XmlElement.class);
         annotation.param("name", name.getLocalPart());
         if (name.getNamespaceURI() != null)
         {
            annotation.param("namespace", name.getNamespaceURI());
         }
      }
      else
      {
         //XmlTransient
View Full Code Here


   }

   private static void addClassAnnotations(JDefinedClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
   {
      // define XmlRootElement class annotation
      JAnnotationUse xmlRootElementAnnotation = clazz.annotate(XmlRootElement.class);
      xmlRootElementAnnotation.param("name", xmlName.getLocalPart());
      String xmlNameNS = xmlName.getNamespaceURI();
      if (xmlNameNS != null && xmlNameNS.length() > 0)
      {
         xmlRootElementAnnotation.param("namespace", xmlNameNS);
      }

      // define XmlType class annotation
      JAnnotationUse xmlTypeAnnotation = clazz.annotate(XmlType.class);
      xmlTypeAnnotation.param("name", xmlType.getLocalPart());
      String xmlTypeNS = xmlType.getNamespaceURI();
      if (xmlTypeNS != null && xmlTypeNS.length() > 0)
      {
         xmlTypeAnnotation.param("namespace", xmlTypeNS);
      }
      if (propertyOrder != null)
      {
         JAnnotationArrayMember paramArray = xmlTypeAnnotation.paramArray("propOrder");
         for (String property : propertyOrder)
         {
            paramArray.param(property);
         }
      }

      // define XmlAccessorType class annotation
      JAnnotationUse xmlAccessorTypeAnnotation = clazz.annotate(XmlAccessorType.class);
      xmlAccessorTypeAnnotation.param("value", XmlAccessType.FIELD);
   }
View Full Code Here

        }

        List<XSFacet> patternList = simpleType.getFacets(FACET_PATTERN);
        if (patternList.size() > 1) {
            if (notAnnotated(fieldVar, patternListAnn)) {
                JAnnotationUse list = fieldVar.annotate(patternListAnn);
                JAnnotationArrayMember listValue = list.paramArray("value");

                for (XSFacet xsFacet : patternList)
                    // If corresponds to <xsd:restriction base="xsd:string">.
                    if ("String".equals(fieldType.name()))
                        a.put(listValue.annotate(patternAnn).param("regexp", eliminateShorthands(xsFacet.getValue().value)), FacetType.pattern);
View Full Code Here

                case assertTrue: customizeAnnotation(fieldVar.annotate(assertTrueAnn), c); continue;
                case future: customizeAnnotation(fieldVar.annotate(futureAnn), c); continue;
                case past: customizeAnnotation(fieldVar.annotate(pastAnn), c); continue;
                }
            } catch (IllegalArgumentException programmingByException) {
                JAnnotationUse annotationUse = fieldVar.annotate(codeModel.ref(c.type));
                if (!c.value.equals("")) annotationUse.param("value", c.value);
                customizeAnnotation(annotationUse, c); continue;
            }
            customizeRegularAnnotations(a, c);
        }
    }
View Full Code Here

/*     */   private void addProperty(JDefinedClass clazz, String typeName, QName name, String variable)
/*     */     throws ClassNotFoundException
/*     */   {
/* 135 */     Class type = JavaUtils.loadJavaType(typeName, this.loader);
/* 136 */     JFieldVar field = clazz.field(4, type, variable);
/* 137 */     JAnnotationUse annotation = field.annotate(XmlElement.class);
/* 138 */     if (name.getNamespaceURI() != null)
/* 139 */       annotation.param("namespace", name.getNamespaceURI());
/* 140 */     annotation.param("name", name.getLocalPart());
/*     */
/* 143 */     JMethod method = clazz.method(1, type, getterPrefix(type) + JavaUtils.capitalize(variable));
/* 144 */     method.body()._return(JExpr._this().ref(variable));
/*     */
/* 146 */     method = clazz.method(1, Void.TYPE, "set" + JavaUtils.capitalize(variable));
View Full Code Here

/* 147 */     method.body().assign(JExpr._this().ref(variable), method.param(type, variable));
/*     */   }
/*     */
/*     */   private static void addClassAnnotations(JDefinedClass clazz, QName xmlName, QName xmlType, String[] propertyOrder)
/*     */   {
/* 152 */     JAnnotationUse annotation = clazz.annotate(XmlRootElement.class);
/* 153 */     if ((xmlName.getNamespaceURI() != null) && (xmlName.getNamespaceURI().length() > 0))
/* 154 */       annotation.param("namespace", xmlName.getNamespaceURI());
/* 155 */     annotation.param("name", xmlName.getLocalPart());
/*     */
/* 157 */     annotation = clazz.annotate(XmlType.class);
/* 158 */     if (((xmlType.getNamespaceURI() != null ? 1 : 0) & (xmlType.getNamespaceURI().length() > 0 ? 1 : 0)) != 0)
/* 159 */       annotation.param("namespace", xmlType.getNamespaceURI());
/* 160 */     annotation.param("name", xmlType.getLocalPart());
/* 161 */     if (propertyOrder != null)
/*     */     {
/* 163 */       JAnnotationArrayMember paramArray = annotation.paramArray("propOrder");
/* 164 */       for (String property : propertyOrder) {
/* 165 */         paramArray.param(property);
/*     */       }
/*     */     }
/* 168 */     annotation = clazz.annotate(XmlAccessorType.class);
/* 169 */     annotation.param("value", XmlAccessType.FIELD);
/*     */   }
View Full Code Here

                if (xjcValue instanceof JAnnotationArrayMember) {
                    List<Object> values = (List<Object>) PrivilegedAccessHelper.getValueFromField(JANNOTATIONARRAYMEMBER_VALUES, xjcValue);
                    Object[] valuesArray = new Object[values.size()];
                    for (int i = 0; i < values.size(); i++) {
                        if (values.get(i) instanceof JAnnotationUse) {
                            JAnnotationUse xjcAnno = (JAnnotationUse) values.get(i);
                            XJCJavaAnnotationImpl anno = new XJCJavaAnnotationImpl(xjcAnno, dynamicClassLoader);
                            valuesArray[i] = anno.getJavaAnnotation();
                        } else {
                            Field valueField = PrivilegedAccessHelper.getDeclaredField(values.get(i).getClass(), "value", true);
                            Object value = PrivilegedAccessHelper.getValueFromField(valueField, values.get(i));
View Full Code Here

        }
       
        cls._extends(java.lang.Exception.class);

        //@WebFault
        JAnnotationUse faultAnn = cls.annotate(WebFault.class);
        faultAnn.param("name", fault.getBlock().getName().getLocalPart());
        faultAnn.param("targetNamespace", fault.getBlock().getName().getNamespaceURI());

        JType faultBean = fault.getBlock().getType().getJavaType().getType().getType();

        //faultInfo filed
        JFieldVar fi = cls.field(JMod.PRIVATE, faultBean, "faultInfo");
View Full Code Here

* @author Arun Gupta
*/
public class W3CAddressingJavaGeneratorExtension extends TJavaGeneratorExtension {
    @Override
    public void writeMethodAnnotations(TWSDLOperation two, JMethod jMethod) {
        JAnnotationUse actionAnn = null;

        if (!(two instanceof Operation))
            return;

        Operation o = ((Operation)two);

        // explicit input action
        if (o.getInput().getAction() != null && !o.getInput().getAction().equals("")) {
            // explicitly specified
            actionAnn = jMethod.annotate(Action.class);
            actionAnn.param("input", o.getInput().getAction());
        }

        // explicit output action
        if (o.getOutput() != null && o.getOutput().getAction() != null && !o.getOutput().getAction().equals("")) {
            // explicitly specified
            if (actionAnn == null)
                actionAnn = jMethod.annotate(Action.class);

            actionAnn.param("output", o.getOutput().getAction());
        }

        // explicit fault action
        if (o.getFaults() != null && o.getFaults().size() > 0) {
            Map<String, JClass> map = o.getFaults();
            JAnnotationArrayMember jam = null;

            for (Fault f : o.faults()) {
                if (f.getAction() == null)
                    continue;

                if (f.getAction().equals(""))
                    continue;

                if (actionAnn == null) {
                    actionAnn = jMethod.annotate(Action.class);
                }
                if (jam == null) {
                    jam = actionAnn.paramArray("fault");
                }
                final JAnnotationUse faAnn = jam.annotate(FaultAction.class);
                faAnn.param("className", map.get(f.getName()));
                faAnn.param("value", f.getAction());
            }
        }
    }
View Full Code Here

    protected void writeHandlerConfig(String className, JDefinedClass cls, WsimportOptions options) {
        Element e = options.getHandlerChainConfiguration();
        if(e == null)
            return;
        JAnnotationUse handlerChainAnn = cls.annotate(cm.ref(HandlerChain.class));
        NodeList nl = e.getElementsByTagNameNS(
            "http://java.sun.com/xml/ns/javaee", "handler-chain");
        if(nl.getLength() > 0){
            String fName = getHandlerConfigFileName(className);
            handlerChainAnn.param("file", fName);
            generateHandlerChainFile(e, className);
        }
    }
View Full Code Here

TOP

Related Classes of com.sun.codemodel.JAnnotationUse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.