Package org.apache.cxf.tools.common.model

Examples of org.apache.cxf.tools.common.model.JavaField


    }
   
    private void buildBeanFields(final Class exceptionClass, final JavaClass jClass) {
        for (Method method : exceptionClass.getMethods()) {
            if (isIncludedGetter(method)) {
                JavaField field = new JavaField(getFieldName(method),
                                                method.getReturnType().getName(),
                                                "");
                field.setOwner(jClass);
                jClass.addField(field);
                jClass.appendGetter(field);
                jClass.appendSetter(field);
            }
        }
View Full Code Here


   
    protected List<JavaField> buildFields(final Method method, final MessageInfo message) {
        List<JavaField> fields = new ArrayList<JavaField>();
       
        final Class<?> returnType = method.getReturnType();
        JavaField field = new JavaField();
        if (CollectionUtils.isEmpty(message.getMessageParts())) {
            return fields;
        }
        MessagePartInfo part = message.getMessageParts().get(0);
        field.setName(part.getName().getLocalPart());
       
        if (!returnType.isAssignableFrom(void.class)) {
            String type;           
            if (returnType.isArray()) {
                if (isBuiltInTypes(returnType.getComponentType())) {
                    type = returnType.getComponentType().getSimpleName() + "[]";
                } else {
                    type = returnType.getComponentType().getName() + "[]";
                }
            } else {
                type = returnType.getName();
            }
            field.setType(type);
            field.setTargetNamespace("");
           
        }
        fields.add(field);
       
        final Class[] paramClasses = method.getParameterTypes();
        for (MessagePartInfo mpi : message.getMessageParts()) {
            int idx = mpi.getIndex();
            if (idx >= 0) {
                String name = mpi.getName().getLocalPart();
                String type;
                Class clz = paramClasses[idx];
                if (clz.isArray()) {
                    if (isBuiltInTypes(clz.getComponentType())) {
                        type = clz.getComponentType().getSimpleName() + "[]";
                    } else {
                        type = clz.getComponentType().getName() + "[]";
                    }
                } else {
                    type = clz.getName();
                }
                fields.add(new JavaField(name, type, ""));
              
            }
        }
       
        return fields;
View Full Code Here

    protected List<JavaField> buildFields(final Method method, final MessageInfo message) {
        List<JavaField> fields = new ArrayList<JavaField>();

        final Class<?> returnType = method.getReturnType();
        JavaField field = new JavaField();
        if (CollectionUtils.isEmpty(message.getMessageParts())) {
            return fields;
        }
        MessagePartInfo part = message.getMessageParts().get(0);

        field.setName(part.getName().getLocalPart());

        boolean hasReturnType = false;

        if (!returnType.isAssignableFrom(void.class)) {
            hasReturnType = true;
            String type = getTypeString(method.getGenericReturnType());
            List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
            field.setType(type);
            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
            field.setTargetNamespace("");

        }
        fields.add(field);

        final Type[] paramClasses = method.getGenericParameterTypes();
        for (MessagePartInfo mpi : message.getMessageParts()) {
            int idx = hasReturnType ? mpi.getIndex() - 1 : mpi.getIndex();
            if (idx >= 0) {
                String name = mpi.getName().getLocalPart();
                Type t = paramClasses[idx];
                String type = getTypeString(t);
                JavaField jf = new JavaField(name, type, "");
                List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx - 1);
                jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
                if (t instanceof ParameterizedType) {
                    ParameterizedType pt = (ParameterizedType)t;
                    Class c = (Class)pt.getRawType();
                    if (Holder.class.isAssignableFrom(c)) {
                        Annotation[][] paramAnnotations = method.getParameterAnnotations();
                        WebParam wParam = getWebParamAnnotation(paramAnnotations[idx]);
                        if (wParam != null && !StringUtils.isEmpty(wParam.targetNamespace())) {
                            jf.setTargetNamespace(wParam.targetNamespace());
                        }
                    }                  
                }
                fields.add(jf);
            }
View Full Code Here

            int idx = mpi.getIndex();
            String name = mpi.getName().getLocalPart();
            Type t = paramClasses[idx];
            String type = getTypeString(t);

            JavaField field = new JavaField(name, type, "");

            if (paramAnnotations != null
                && paramAnnotations.length == paramClasses.length) {
                WebParam wParam = getWebParamAnnotation(paramAnnotations[idx]);
                if (wParam != null && !StringUtils.isEmpty(wParam.targetNamespace())) {
                    field.setTargetNamespace(wParam.targetNamespace());
                } else {
                    field.setTargetNamespace("");
                }
            }

            List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx);
            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
            fields.add(field);
        }

        return fields;
    }
View Full Code Here

import org.apache.cxf.tools.common.model.JavaField;

public class WrapperBeanFieldAnnotator implements Annotator {

    public void annotate(final JavaAnnotatable field) {
        JavaField jField = null;
        if (field instanceof JavaField) {
            jField = (JavaField) field;
        } else {
            throw new RuntimeException("WrapperBeanFiledAnnotator expect JavaField as input");
        }
        String rawName = jField.getRawName();
        JavaAnnotation xmlElementAnnotation = new JavaAnnotation("XmlElement");
       
        xmlElementAnnotation.addArgument("name", rawName);
        xmlElementAnnotation.addArgIgnoreEmtpy("namespace", jField.getTargetNamespace(), "\"");

        jField.setAnnotation(xmlElementAnnotation);
        jField.getOwner().addImport("javax.xml.bind.annotation.XmlElement");
    }
View Full Code Here

    private void buildBeanFields(final Class exceptionClass, final JavaClass jClass) {
        Map<String, JavaField> fields = new TreeMap<String, JavaField>();
       
        for (Method method : exceptionClass.getMethods()) {
            if (isIncludedGetter(method)) {
                JavaField field = new JavaField(getFieldName(method),
                                                method.getReturnType().getName(),
                                                "");
                field.setOwner(jClass);
                fields.put(field.getName(), field);
            }
        }
        for (Map.Entry<String, JavaField> ent : fields.entrySet()) {
            jClass.addField(ent.getValue());
            jClass.appendGetter(ent.getValue());
View Full Code Here

    private void buildBeanFields(final Class exceptionClass, final JavaClass jClass) {
        Map<String, JavaField> fields = new TreeMap<String, JavaField>();
       
        for (Method method : exceptionClass.getMethods()) {
            if (isIncludedGetter(method)) {
                JavaField field = new JavaField(getFieldName(method),
                                                method.getReturnType().getName(),
                                                "");
                field.setOwner(jClass);
                fields.put(field.getName(), field);
            }
        }
        for (Map.Entry<String, JavaField> ent : fields.entrySet()) {
            jClass.addField(ent.getValue());
            jClass.appendGetter(ent.getValue());
View Full Code Here

    protected List<JavaField> buildFields(final Method method, final MessageInfo message) {
        List<JavaField> fields = new ArrayList<JavaField>();

        final Class<?> returnType = method.getReturnType();
        JavaField field = new JavaField();
        if (CollectionUtils.isEmpty(message.getMessageParts())) {
            return fields;
        }
        MessagePartInfo part = message.getMessageParts().get(0);

        field.setName(part.getName().getLocalPart());

        boolean hasReturnType = false;

        if (!returnType.isAssignableFrom(void.class)) {
            hasReturnType = true;
            String type = getTypeString(method.getGenericReturnType());
            List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method);
            field.setType(type);
            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
            field.setTargetNamespace("");

        }
        fields.add(field);

        final Type[] paramClasses = method.getGenericParameterTypes();
        for (MessagePartInfo mpi : message.getMessageParts()) {
            int idx = hasReturnType ? mpi.getIndex() - 1 : mpi.getIndex();
            if (idx >= 0) {
                String name = mpi.getName().getLocalPart();

                Type t = paramClasses[idx];
                String type = getTypeString(t);

                JavaField jf = new JavaField(name, type, "");
                List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx - 1);
                jf.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
                fields.add(new JavaField(name, type, ""));

            }
        }

        return fields;
View Full Code Here

            int idx = mpi.getIndex();
            String name = mpi.getName().getLocalPart();
            Type t = paramClasses[idx];
            String type = getTypeString(t);

            JavaField field = new JavaField(name, type, "");

            if (paramAnnotations != null
                && paramAnnotations.length == paramClasses.length) {
                WebParam wParam = getWebParamAnnotation(paramAnnotations[idx]);
                if (wParam != null && !StringUtils.isEmpty(wParam.targetNamespace())) {
                    field.setTargetNamespace(wParam.targetNamespace());
                } else {
                    field.setTargetNamespace("");
                }
            }

            List<Annotation> jaxbAnns = WrapperUtil.getJaxbAnnotations(method, idx);
            field.setJaxbAnnotations(jaxbAnns.toArray(new Annotation[jaxbAnns.size()]));
            fields.add(field);
        }

        return fields;
    }
View Full Code Here

import org.apache.cxf.tools.common.model.JavaField;

public class WrapperBeanFieldAnnotator implements Annotator {

    public void annotate(final JavaAnnotatable field) {
        JavaField jField = null;
        if (field instanceof JavaField) {
            jField = (JavaField) field;
        } else {
            throw new RuntimeException("WrapperBeanFiledAnnotator expect JavaField as input");
        }
        String rawName = jField.getRawName();
        JAnnotation xmlElementAnnotation = new JAnnotation(XmlElement.class);
        xmlElementAnnotation.addElement(new JAnnotationElement("name", rawName));
        if (!StringUtils.isEmpty(jField.getTargetNamespace())) {
            xmlElementAnnotation.addElement(new JAnnotationElement("namespace",
                                                                          jField.getTargetNamespace()));
        }

        jField.addAnnotation(xmlElementAnnotation);
       
        for (Annotation ann : jField.getJaxbAnnotaions()) {
            if (ann instanceof XmlMimeType) {
                JAnnotation mimeAnno = new JAnnotation(XmlMimeType.class);
                mimeAnno.addElement(new JAnnotationElement("value", ((XmlMimeType)ann).value()));
                jField.addAnnotation(mimeAnno);
            } else if (ann instanceof XmlJavaTypeAdapter) {          
                JAnnotation jaxbAnn = new JAnnotation(XmlJavaTypeAdapter.class);
                jaxbAnn.addElement(new JAnnotationElement("value", ((XmlJavaTypeAdapter)ann).value()));
                jaxbAnn.addElement(new JAnnotationElement("type", ((XmlJavaTypeAdapter)ann).type()));
                jField.addAnnotation(jaxbAnn);
            } else if (ann instanceof XmlAttachmentRef) {
                JAnnotation jaxbAnn = new JAnnotation(XmlAttachmentRef.class);
                jField.addAnnotation(jaxbAnn);
            } else if (ann instanceof XmlList) {
                JAnnotation jaxbAnn = new JAnnotation(XmlList.class);
                jField.addAnnotation(jaxbAnn);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.tools.common.model.JavaField

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.