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

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


                    type = clz.getComponentType().getName() + "[]";
                }
            } else {
                type = clz.getName();
            }
            JavaField field = new JavaField(name, type, "");
            field.setTargetNamespace("");
            fields.add(field);
           
        }

        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, "");
            field.setTargetNamespace("");
            fields.add(field);
        }

        return fields;
    }
View Full Code Here

        assertEquals("DBServiceFaultBean", beanClass.getName());
        assertEquals("org.apache.cxf.tools.fortest.cxf523.jaxws", beanClass.getPackageName());

        assertEquals(1, beanClass.getFields().size());

        JavaField field = beanClass.getFields().get(0);
        assertEquals("message", field.getName());
        assertEquals("java.lang.String", field.getType());

        QName qname = beanClass.getElementName();
        assertEquals("DBServiceFault", qname.getLocalPart());
        assertEquals("http://cxf523.fortest.tools.cxf.apache.org/", qname.getNamespaceURI());
    }
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());
       
        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 - 1];
                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

            String fPackageName = ProcessorUtil.parsePackageName(fNamespace, env
                                                                 .mapPackageName(fNamespace));
           
           

            JavaField fField = new JavaField(fName, fType, fNamespace);
            fField.setQName(ProcessorUtil.getElementName(part));
           
            if (!method.getInterface().getPackageName().equals(fPackageName)) {
                fField.setClassName(ProcessorUtil.getFullClzName(part,
                                                                 env, this.collector, false));               
            }
            if (!fType.equals(ProcessorUtil.resolvePartType(part))) {
                fField.setClassName(ProcessorUtil.getType(part, env, true));
            }

            expClass.addField(fField);
        }
        model.addExceptionClass(packageName + "." + name, expClass);
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

            //REVISIT - custom JAXB package names
            String fPackageName = method.getInterface().getPackageName();


            JavaField fField = new JavaField(fName, fType, fNamespace);
            fField.setQName(ProcessorUtil.getElementName(part));

            if (!method.getInterface().getPackageName().equals(fPackageName)) {
                fField.setClassName(ProcessorUtil.getFullClzName(part, context, false));
            }
            if (!fType.equals(ProcessorUtil.resolvePartType(part))) {
                fField.setClassName(ProcessorUtil.getType(part, context, true));
            }

            expClass.addField(fField);
        }
        model.addExceptionClass(packageName + "." + name, expClass);
View Full Code Here

        ResponseWrapper responseWrapper = new ResponseWrapper();

        MessageInfo message = opInfo.getUnwrappedOperation().getOutput();
        Method method = (Method)opInfo.getProperty("operation.method");

        JavaField field  = responseWrapper.buildFields(method, message).get(0);
        assertEquals("_return", field.getName());
        assertEquals("String[]", field.getType());

        // Test int[]

        opInfo = getOperation(testingClass, "sayIntArray");
        assertNotNull(opInfo);

        message = opInfo.getUnwrappedOperation().getOutput();
        method = (Method) opInfo.getProperty("operation.method");

        field = responseWrapper.buildFields(method, message).get(0);
        assertEquals("_return", field.getName());
        assertEquals("int[]", field.getType());

        // Test TestDataBean[]
       
        opInfo = getOperation(testingClass, "sayTestDataBeanArray");
        assertNotNull(opInfo);

        message = opInfo.getUnwrappedOperation().getOutput();
        method = (Method) opInfo.getProperty("operation.method");

        field = responseWrapper.buildFields(method, message).get(0);
        assertEquals("_return", field.getName());
        assertEquals("org.apache.cxf.tools.fortest.withannotation.doc.TestDataBean[]", field.getType());
    }
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.addArgIgnoreEmpty("namespace", jField.getTargetNamespace(), "\"");

        jField.setAnnotation(xmlElementAnnotation);
        jField.getOwner().addImport("javax.xml.bind.annotation.XmlElement");
    }
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.