Examples of JavaMethod


Examples of com.badlogic.gdx.jnigen.parsing.JavaMethodParser.JavaMethod

      if (segment instanceof JniSection) {
        emitJniSection(buffer, (JniSection)segment);
      }

      if (segment instanceof JavaMethod) {
        JavaMethod javaMethod = (JavaMethod)segment;
        if (javaMethod.getNativeCode() == null) {
          throw new RuntimeException("Method '" + javaMethod.getName() + "' has no body");
        }
        CMethod cMethod = findCMethod(javaMethod, cMethods);
        if (cMethod == null)
          throw new RuntimeException("Couldn't find C method for Java method '" + javaMethod.getClassName() + "#"
            + javaMethod.getName() + "'");
        emitJavaMethod(buffer, javaMethod, cMethod);
      }
    }
    cppFile.writeString(buffer.toString(), false, "UTF-8");
  }
View Full Code Here

Examples of com.caucho.bytecode.JavaMethod

    ArrayList<JavaMethod> methods = baseClass.getMethodList();

    // Move the __super methods
    ArrayList<JavaMethod> extMethods = extClass.getMethodList();
    for (int i = 0; i < extMethods.size(); i++) {
      JavaMethod extMethod = extMethods.get(i);

      fixupExtMethod(baseClass, extClass, extMethod);

      String baseName = extMethod.getName();

      if (baseName.endsWith("__super"))
        continue;

      String superName = baseName + "__super";

      int j;
      for (j = 0; j < methods.size(); j++) {
        JavaMethod method = methods.get(j);

        String type = method.getDescriptor();

        if (! method.getName().equals(baseName)
      || ! method.getDescriptor().equals(extMethod.getDescriptor()))
          continue;

        if (baseName.equals("<init>")) {
          baseClass.getConstantPool().addUTF8("__init__super");
          mergeInitMethods(baseClass, method, extClass, extMethod);
          break;
        }

        if (baseName.equals("<clinit>")) {
          concatenateMethods(baseClass, method, extClass, extMethod);
          break;
        }

        baseClass.getConstantPool().addUTF8(superName);
        method.setName(superName);
        baseClass.getConstantPool().addUTF8(type);
        method.setDescriptor(type);

        // set the super methods private
        int flags = method.getAccessFlags();
        flags = (flags & ~ACC_PUBLIC & ~ACC_PROTECTED) | ACC_PRIVATE;
        method.setAccessFlags(flags);
        break;
      }
    }
  }
View Full Code Here

Examples of com.oracle.xmlns.webservices.jaxws_databinding.JavaMethod

            Annotation[] reflection() {
                return ExternalMetadataReader.super.getAnnotations(m);
            }

            Annotation[] external() {
                JavaMethod jm = getJavaMethod(m, reader);
                return (jm == null) ? new Annotation[0] : getAnnotations(jm.getMethodAnnotation());
            }
        };
        return merger.merge();
    }
View Full Code Here

Examples of com.redhat.ceylon.compiler.loader.model.JavaMethod

    }

    private Method addMethod(ClassOrInterface klass, MethodMirror methodMirror, ClassMirror classMirror,
                             boolean isCeylon, boolean isOverloaded) {
       
        JavaMethod method = new JavaMethod(methodMirror);
        String methodName = methodMirror.getName();
       
        method.setContainer(klass);
        method.setScope(klass);
        method.setRealName(methodName);
        method.setUnit(klass.getUnit());
        method.setOverloaded(isOverloaded || isOverloadingMethod(methodMirror));
        ProducedType type = null;
        try{
            setMethodOrValueFlags(klass, methodMirror, method, isCeylon);
        }catch(ModelResolutionException x){
            // collect an error in its type
            type = logModelResolutionException(x, klass, "method '"+methodMirror.getName()+"' (checking if it is an overriding method");
        }
        if(methodName.equals("hash")
                || methodName.equals("string"))
            method.setName(methodName+"_method");
        else
            method.setName(Util.strip(methodName, isCeylon, method.isShared()));
        method.setDefaultedAnnotation(methodMirror.isDefault());

        // type params first
        setTypeParameters(method, methodMirror, isCeylon);

        // and its return type
        // do not log an additional error if we had one from checking if it was overriding
        if(type == null)
            type = obtainType(methodMirror.getReturnType(), methodMirror, method, Decl.getModuleContainer(method), VarianceLocation.COVARIANT,
                              "method '"+methodMirror.getName()+"'", klass);
        method.setType(type);
       
        // now its parameters
        if(isEqualsMethod(methodMirror))
            setEqualsParameters(method, methodMirror);
        else
            setParameters(method, methodMirror, isCeylon, klass);
       
        method.setUncheckedNullType((!isCeylon && !methodMirror.getReturnType().isPrimitive()) || isUncheckedNull(methodMirror));
        type.setRaw(isRaw(Decl.getModuleContainer(klass), methodMirror.getReturnType()));
        markDeclaredVoid(method, methodMirror);
        markUnboxed(method, methodMirror, methodMirror.getReturnType());
        markTypeErased(method, methodMirror, methodMirror.getReturnType());
        markUntrustedType(method, methodMirror, methodMirror.getReturnType());
View Full Code Here

Examples of com.sun.tools.internal.ws.processor.model.java.JavaMethod

        //@XmlSeeAlso
        if(options.target.isLaterThan(Options.Target.V2_1))
            writeXmlSeeAlso(cls);

        for (Operation operation: port.getOperations()) {
            JavaMethod method = operation.getJavaMethod();

            //@WebMethod
            JMethod m;
            JDocComment methodDoc;
            String methodJavaDoc = operation.getJavaDoc();
            if(method.getReturnType().getName().equals("void")){
                m = cls.method(JMod.PUBLIC, void.class, method.getName());
                methodDoc = m.javadoc();
            }else {
                JAXBTypeAndAnnotation retType = method.getReturnType().getType();
                m = cls.method(JMod.PUBLIC, retType.getType(), method.getName());
                retType.annotate(m);
                methodDoc = m.javadoc();
                JCommentPart ret = methodDoc.addReturn();
                ret.add("returns "+retType.getName());
            }
            if(methodJavaDoc != null)
                methodDoc.add(methodJavaDoc);

            writeWebMethod(operation, m);
            JClass holder = cm.ref(Holder.class);
            for (JavaParameter parameter: method.getParametersList()) {
                JVar var;
                JAXBTypeAndAnnotation paramType = parameter.getType().getType();
                if (parameter.isHolder()) {
                    var = m.param(holder.narrow(paramType.getType().boxify()), parameter.getName());
                }else{
View Full Code Here

Examples of com.sun.tools.ws.processor.model.java.JavaMethod

       
        // @SOAPBinding
        seiInfo.setSoapBindingAnnotation(getSOAPBindingAnnotation(port));
       
            for (Operation operation: port.getOperations()) {
                JavaMethod method = operation.getJavaMethod();
               
          MethodInfo methodInfo = new MethodInfo();
          // method name
          methodInfo.setName(method.getName());
         
          // method doc comment
          String methodJavaDoc = operation.getJavaDoc();
          if (methodJavaDoc == null) {
            methodJavaDoc = "public method";
          }
         
          // method return type
                String returnTypeName;
          if(method.getReturnType().getName().equals("void")){
            returnTypeName = "void";
                } else {
                  returnTypeName = method.getReturnType().getType()
            .getName();
                }
          if (this.isWrapped(operation)) { // wrapped response
                Response response = operation.getResponse();
                    Block resBlock = response.getBodyBlocks().next();
                    returnTypeName = resBlock.getType().getJavaType().getName();
          }
          TypeInfo returnType = new TypeInfo();
          returnType.setFullName(returnTypeName);
          returnType.setName(ClassNameUtil
              .stripQualifier(returnTypeName));
          methodInfo.setReturnType(returnType);
         
          methodInfo.setWebMethodAnnotation(getWebMethodAnnotation(operation, method.getName()));
          methodInfo.setWebResultAnnotation(getWebResultAnnotation(operation));
          methodInfo.setSoapBindingAnnotation(getSOAPBindingAnnotation(operation));
         
          if (this.isWrapped(operation)) { // wrapped request parameter
                  Block reqBlock = operation.getRequest().getBodyBlocks().next();
                  String parameterTypeName = reqBlock.getType().getJavaType().getName();
                 
            ParameterInfo paramInfo = new ParameterInfo();
                  paramInfo.setName("request");
            // param type
            TypeInfo paramType = new TypeInfo();
            paramType.setFullName(parameterTypeName);
            paramType.setName(ClassNameUtil
                .stripQualifier(parameterTypeName));
            paramInfo.setType(paramType);
           
            // add this param in method definition
            methodInfo.getParameters().add(paramInfo);
          } else {
            for (JavaParameter parameter : method.getParametersList()) {
              ParameterInfo paramInfo = new ParameterInfo();
             
              // param name
              paramInfo.setName(parameter.getName());
              // param type
View Full Code Here

Examples of com.sun.xml.ws.api.model.JavaMethod

      // TODO when operation <input><json:body contains different namespace than port level name space bellow call fails to identify operation.
      WSDLBoundOperation operation   = seiModel.getPort().getBinding().getOperation(seiModel.getTargetNamespace(),payloadName);
      if(operation == null || !packet.invocationProperties.containsKey(JSONCodec.JSON_MAP_KEY)){
        throw new RuntimeException("Operation %s input parameter(s) not found or invalid.");
      }
      JavaMethod       javaMethod   = seiModel.getJavaMethod(operation.getName());
      if(javaMethod == null && javaMethodAccessor != null){
        javaMethod = (JavaMethod) javaMethodAccessor.invoke(seiModel, operation.getName());
      }else{
        // TODO iterate all method and find
      }
      Method         seiMethod   = javaMethod.getSEIMethod();
      JSONWebService  jsonwebService  = javaMethod.getMethod().getAnnotation(JSONWebService.class);
      // Put codec specific properties in invoke
      invocationProperties.put(JSONCodec.globalMapKeyPattern_KEY, (jsonwebService == null || jsonwebService.listMapKey().isEmpty())?
          JSONCodec.globalMapKeyPattern : Pattern.compile(jsonwebService.listMapKey()));
      invocationProperties.put(JSONCodec.globalMapValuePattern_KEY, (jsonwebService == null || jsonwebService.listMapValue().isEmpty())?
          JSONCodec.globalMapValuePattern : Pattern.compile(jsonwebService.listMapValue()));
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

            }
            ValueObjectMetadata metaVo = getMetaVO(metadata);
            BeanProperty pkProperty = metaVo.getPkProperty();

            JavaField field;
            JavaMethod method;
            JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
            String[] modifiers = new String[isAbstract(metadata) ? 2 : 1];
            modifiers[0] = "public";
            if (isAbstract(metadata)) {
                modifiers[1] = "abstract";
            }
            retVal.setModifiers(modifiers);
            retVal.setSuperClass(new Type(getExtends(metadata)));

            String[] implementz = getImplements(metadata);
            Type[] implementzTypes = new Type[implementz.length];
            for (int j = 0; j < implementz.length; j++) {
                implementzTypes[j] = new Type(implementz[j]);
            }
            retVal.setImplementz(implementzTypes);

            if (getEjbUtils().isUseSoftLocking(metadata)) {
                field = new JavaField(new Type("int"), "_version");
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
            }

            ValueObjectFieldMetadata[] nonPkFields = metaVo.getNonPkFields();
            for (int j = 0; j < nonPkFields.length; j++) {
                ValueObjectFieldMetadata vField = nonPkFields[j];
                field = new JavaField(vField.getProperty().getType(), vField.getProperty().getName());
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
                field = new JavaField(new Type("boolean"), vField.getProperty().getName()+"HasBeenSet");
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
            }

            ValueObjectFieldMetadata[] pkFields = metaVo.getPkFields();
            for (int j = 0; j < pkFields.length; j++) {
                ValueObjectFieldMetadata vField = pkFields[j];
                field = new JavaField(vField.getProperty().getType(), vField.getProperty().getName());
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
                field = new JavaField(new Type("boolean"), vField.getProperty().getName()+"HasBeenSet");
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
            }

            ValueObjectRelationMetadata[] nonCollectionRel = metaVo.getNonCollectionRelations();
            for (int j = 0; j < nonCollectionRel.length; j++) {
                ValueObjectRelationMetadata vRelation = nonCollectionRel[j];
                field = new JavaField(vRelation.getProperty().getType(), vRelation.getProperty().getName());
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
                field = new JavaField(new Type("boolean"), vRelation.getProperty().getName()+"HasBeenSet");
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
            }
            ValueObjectRelationMetadata[] collectionRel = metaVo.getCollectionRelations();
            for (int j = 0; j < collectionRel.length; j++) {
                ValueObjectRelationMetadata vRelation = collectionRel[j];
                field = new JavaField(vRelation.getProperty().getType(), vRelation.getProperty().getName());
                field.setModifiers(new String[] { "private" });
                retVal.addField(field);
            }

            method = new JavaMethod(getDestinationClassname(metadata));
            method.setConstructor(true);
            method.setModifiers(new String[] { "public" });
            retVal.addMethod(method);

            if (metaVo.isGeneratePKConstructor() && metaVo.hasPk()) {
                if(!isEmpty(nonPkFields) || !metaVo.isSimplePkProperty()) {
                    method = new JavaMethod(getDestinationClassname(metadata));
                    method.setConstructor(true);
                    method.setModifiers(new String[] { "public" });
                    method.setParameters(new JavaParameter[]{new JavaParameter(pkProperty.getType(), pkProperty.getName())});
                    retVal.addMethod(method);
                }
                if(!isEmpty(nonPkFields) && !metaVo.isSimplePkProperty()) {
                    method = new JavaMethod(getDestinationClassname(metadata));
                    method.setConstructor(true);
                    method.setModifiers(new String[] { "public" });
                    JavaParameter[] params = new JavaParameter[nonPkFields.length + 1];
                    params[0] = new JavaParameter(pkProperty.getType(), pkProperty.getName());
                    for (int j = 0; j < nonPkFields.length; j++) {
                        ValueObjectFieldMetadata nonPkField = nonPkFields[j];
                        params[j+1] = new JavaParameter(nonPkField.getProperty().getType(), nonPkField.getProperty().getName());
                    }
                    method.setParameters(params);
                    retVal.addMethod(method);
                }
            }

            ValueObjectFieldMetadata[] fields = metaVo.getFields();
            if (!isEmpty(fields)) {
                method = new JavaMethod(getDestinationClassname(metadata));
                method.setConstructor(true);
                method.setModifiers(new String[] { "public" });
                JavaParameter[] params = new JavaParameter[fields.length];
                for (int j = 0; j < fields.length; j++) {
                    ValueObjectFieldMetadata vField = fields[j];
                    params[j] = new JavaParameter(vField.getProperty().getType(), vField.getProperty().getName());
                }
                method.setParameters(params);
                retVal.addMethod(method);
            }

            if (metaVo.hasPk() && !metaVo.isSimplePkProperty()) {
                method = new JavaMethod(pkProperty.getType(), pkProperty.getAccessor().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod(pkProperty.getMutator().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(pkProperty.getType(), pkProperty.getName())});
                retVal.addMethod(method);
            }

            if (getEjbUtils().isUseSoftLocking(metadata)) {
                method = new JavaMethod(new Type("int"), "getVersion");
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod("setVersion");
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type("int"), "version")});
                retVal.addMethod(method);
            }

            for (int j = 0; (fields != null) && (j < fields.length); j++) {
                ValueObjectFieldMetadata vField = fields[j];
                method = new JavaMethod(vField.getProperty().getType(), vField.getProperty().getAccessor().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod(vField.getProperty().getMutator().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(vField.getProperty().getType(), vField.getProperty().getName())});
                retVal.addMethod(method);

                method = new JavaMethod(new Type("boolean"), vField.getProperty().getName()+"HasBeenSet");
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);
            }

            for (int k = 0; k < nonCollectionRel.length; k++) {
                ValueObjectRelationMetadata nonColRel = nonCollectionRel[k];

                method = new JavaMethod(nonColRel.getProperty().getType(), nonColRel.getProperty().getAccessor().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod(nonColRel.getProperty().getMutator().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(nonColRel.getProperty().getType(), nonColRel.getProperty().getName())});
                retVal.addMethod(method);

                method = new JavaMethod(new Type("boolean"), nonColRel.getProperty().getName()+"HasBeenSet");
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);
            }

            for (int k = 0; k < collectionRel.length; k++) {
                ValueObjectRelationMetadata colRel = collectionRel[k];

                field = new JavaField(colRel.getProperty().getType(), "added" + colRel.getProperty().getName());
                field.setModifiers(new String[]{"protected"});
                retVal.addField(field);
                field = new JavaField(colRel.getProperty().getType(), "onceAdded" + colRel.getProperty().getName());
                field.setModifiers(new String[]{"protected"});
                retVal.addField(field);
                field = new JavaField(colRel.getProperty().getType(), "removed" + colRel.getProperty().getName());
                field.setModifiers(new String[]{"protected"});
                retVal.addField(field);
                field = new JavaField(colRel.getProperty().getType(), "updated" + colRel.getProperty().getName());
                field.setModifiers(new String[]{"protected"});
                retVal.addField(field);

                method = new JavaMethod(colRel.getProperty().getType(), "getAdded" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                retVal.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getOnceAdded" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                retVal.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getRemoved" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                retVal.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getUpdated" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                retVal.addMethod(method);

                method = new JavaMethod(colRel.getProperty().getType(), colRel.getProperty().getAccessor().getName()+"Collection");
                method.setModifiers(new String[]{"public"});
                retVal.addMethod(method);

                method = new JavaMethod(new Type(colRel.getAggregate(),1), colRel.getProperty().getAccessor().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod(colRel.getProperty().getMutator().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type(colRel.getAggregate(),1), colRel.getProperty().getName())});
                retVal.addMethod(method);

                method = new JavaMethod("clear"+colRel.getProperty().getName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod("add"+colRel.getAggregateName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type(colRel.getAggregate()), "other")});
                retVal.addMethod(method);

                method = new JavaMethod("remove"+colRel.getAggregateName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type(colRel.getAggregate()), "other")});
                retVal.addMethod(method);

                method = new JavaMethod("update"+colRel.getAggregateName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type(colRel.getAggregate()), "other")});
                retVal.addMethod(method);

                method = new JavaMethod("clean"+colRel.getAggregateName());
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                retVal.addMethod(method);

                method = new JavaMethod("copy"+colRel.getProperty().getName()+"From");
                modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
                modifiers[0] = "public";
                if (metaVo.isFullSynchronization()) {
                    modifiers[1] = "synchronized";
                }
                method.setModifiers(modifiers);
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type(getDestinationFullyQualifiedClassName(metadata)), "other")});
                retVal.addMethod(method);
            }

            method = new JavaMethod(new Type("java.lang.String"), "toString");
            modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
            modifiers[0] = "public";
            if (metaVo.isFullSynchronization()) {
                modifiers[1] = "synchronized";
            }
            method.setModifiers(modifiers);
            retVal.addMethod(method);

            method = new JavaMethod(new Type("boolean"), "hasIdentity");
            modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
            modifiers[0] = "protected";
            if (metaVo.isFullSynchronization()) {
                modifiers[1] = "synchronized";
            }
            method.setModifiers(modifiers);
            retVal.addMethod(method);

            method = new JavaMethod(new Type("boolean"), "equals");
            method.setModifiers(new String[]{"public"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.lang.Object"), "other")});
            retVal.addMethod(method);

            if (metaVo.isStrictOrdering()) {
                method = new JavaMethod(new Type("int"), "compareTo");
                method.setModifiers(new String[]{"public"});
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.lang.Object"), "other")});
                retVal.addMethod(method);
            }

            method = new JavaMethod(new Type("java.lang.Object"), "clone");
            modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
            modifiers[0] = "public";
            if (metaVo.isFullSynchronization()) {
                modifiers[1] = "synchronized";
            }
            method.setModifiers(modifiers);
            retVal.addMethod(method);

            method = new JavaMethod(new Type("int"), "hashCode");
            modifiers = new String[metaVo.isFullSynchronization() ? 2 : 1];
            modifiers[0] = "public";
            if (metaVo.isFullSynchronization()) {
                modifiers[1] = "synchronized";
            }
            method.setModifiers(modifiers);
            retVal.addMethod(method);

            JavaClass innerClass = createDynamicJavaClass("ReadOnly" + getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
            innerClass.setModifiers(new String[]{"final","private"});
            retVal.addClass(innerClass);

            method = new JavaMethod(innerClass.asType(), "getReadOnly"+getDestinationClassname(metadata));
            method.setModifiers(new String[]{"public"});
            retVal.addMethod(method);

            method = new JavaMethod(new Type("java.util.Collection"), "wrapCollection");
            method.setModifiers(new String[]{"private", "static"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.util.Collection"), "input")});
            retVal.addMethod(method);

            method = new JavaMethod(new Type("java.util.Set"), "wrapCollection");
            method.setModifiers(new String[]{"private", "static"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.util.Set"), "input")});
            retVal.addMethod(method);

            method = new JavaMethod(new Type("java.util.Collection"), "wrapReadOnly");
            method.setModifiers(new String[]{"private", "static"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.util.Collection"), "input")});
            retVal.addMethod(method);

            method = new JavaMethod(new Type("java.util.Set"), "wrapReadOnly");
            method.setModifiers(new String[]{"private", "static"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.util.Set"), "input")});
            retVal.addMethod(method);

            // handle inner class

            implementz = getImplements(metadata);
            implementzTypes = new Type[implementz.length];
            for (int j = 0; j < implementz.length; j++) {
                implementzTypes[j] = new Type(implementz[j]);
            }
            innerClass.setImplementz(implementzTypes);

            method = new JavaMethod(retVal.asType(), "underlying");
            method.setModifiers(new String[]{"private"});
            innerClass.addMethod(method);

            for (int j = 0; (fields != null) && (j < fields.length); j++) {
                ValueObjectFieldMetadata vField = fields[j];
                method = new JavaMethod(vField.getProperty().getType(), vField.getProperty().getAccessor().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);

                method = new JavaMethod(new Type("boolean"), vField.getProperty().getName()+"HasBeenSet");
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
            }

            for (int k = 0; k < nonCollectionRel.length; k++) {
                ValueObjectRelationMetadata nonColRel = nonCollectionRel[k];

                method = new JavaMethod(nonColRel.getProperty().getType(), nonColRel.getProperty().getAccessor().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);

                method = new JavaMethod(new Type("boolean"), nonColRel.getProperty().getName()+"HasBeenSet");
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
            }

            for (int k = 0; k < collectionRel.length; k++) {
                ValueObjectRelationMetadata colRel = collectionRel[k];

                method = new JavaMethod(colRel.getProperty().getType(), "getAdded" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getOnceAdded" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getRemoved" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
                method = new JavaMethod(colRel.getProperty().getType(), "getUpdated" + colRel.getProperty().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);

                method = new JavaMethod(colRel.getProperty().getType(), colRel.getProperty().getAccessor().getName()+"Collection");
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);

                method = new JavaMethod(new Type(colRel.getAggregate(),1), colRel.getProperty().getAccessor().getName());
                method.setModifiers(new String[]{"public"});
                innerClass.addMethod(method);
            }

            method = new JavaMethod(new Type("int"), "hashCode");
            method.setModifiers(new String[]{"public"});
            innerClass.addMethod(method);

            method = new JavaMethod(new Type("boolean"), "equals");
            method.setModifiers(new String[]{"public"});
            method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.lang.Object"), "other")});
            innerClass.addMethod(method);

            if (metaVo.isStrictOrdering()) {
                method = new JavaMethod(new Type("int"), "compareTo");
                method.setModifiers(new String[]{"public"});
                method.setParameters(new JavaParameter[]{new JavaParameter(new Type("java.lang.Object"), "other")});
                innerClass.addMethod(method);
            }

            // add to list
            retLst.add(retVal);
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

        if (!shouldGenerate(metadata)) {
            return null;
        }

        JavaField field;
        JavaMethod method;
        JavaClass retVal = createDynamicJavaClass(getDestinationClassname(metadata), getDestinationPackage(metadata), null, getMetadataProvider());
        retVal.setInterface(true);
        retVal.setModifiers(new String[]{"public"});
        String[] extendz = getExtends(metadata);
        Type[] extendzTypes = new Type[extendz.length];
        for (int j = 0; j < extendz.length; j++) {
            extendzTypes[j] = new Type(extendz[j]);
        }
        retVal.setImplementz(extendzTypes);

        field = new JavaField(new Type("java.lang.String"), ejbHomeUtils.getCompleteNameConst());
        field.setModifiers(new String[]{"public","static","final"});
        retVal.addField(field);

        field = new JavaField(new Type("java.lang.String"), ejbHomeUtils.getJndiNameConst());
        field.setModifiers(new String[]{"public","static","final"});
        retVal.addField(field);

        Collection methods = getCreateMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
            method = new DuplicatedJavaMethod((JavaMethod)iter.next());
            method.setModifiers(new String[0]);
            retVal.addMethod(method);
        }

        if (ejbUtils.isEntityBean(metadata)) {
            methods = getFinderMethods(metadata);
            for (Iterator iter = methods.iterator(); iter.hasNext();) {
                method = new DuplicatedJavaMethod((JavaMethod)iter.next());
                method.setModifiers(new String[0]);
                retVal.addMethod(method);
            }
        }
        methods = getHomeMethods(metadata);
        for (Iterator iter = methods.iterator(); iter.hasNext();) {
            method = new DuplicatedJavaMethod((JavaMethod)iter.next());
            method.setModifiers(new String[0]);
            retVal.addMethod(method);
        }

        return new JavaClass[]{retVal};
    }
View Full Code Here

Examples of com.thoughtworks.qdox.model.JavaMethod

    public Collection getInterfaceMethods(final JavaClass clazz, final int viewType) {
        return
                CollectionUtils.select(Arrays.asList(clazz.getMethods(true)),
                        new Predicate() {
                            public boolean evaluate(Object object) {
                                JavaMethod method = (JavaMethod) object;
                                boolean retVal = EjbUtils.hasFlag(ejbUtils.getMethodType(method),
                                        EjbUtils.IFACE_METHOD_COMPONENT);
                                retVal = retVal && EjbUtils.hasFlag(ejbUtils.getViewType(method, clazz), viewType);
                                return retVal;
                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.