Examples of ConstructorInfo


Examples of com.strobel.reflection.ConstructorInfo

    // <editor-fold defaultstate="collapsed" desc="New and New Array Expressions">

    private void emitNewExpression(final Expression expr) {
        final NewExpression node = (NewExpression) expr;
        final ConstructorInfo constructor = node.getConstructor();

        if (constructor == null) {
            assert node.getArguments().size() == 0
                : "Node with arguments must have a constructor.";

            assert node.getType().isPrimitive()
                :
                "Only primitive type may have no constructor set.";

            generator.emitDefaultValue(node.getType());
            return;
        }

        generator.emitNew(constructor.getDeclaringType());
        generator.dup();
        emitArguments(constructor, node);
        generator.call(constructor);
    }
View Full Code Here

Examples of com.strobel.reflection.ConstructorInfo

            // array[i] = new StrongBox<T>(...);
            lc.generator.dup();
            lc.generator.emitInteger(i++);

            final Type boxType = getBoxType(v.getType());
            final ConstructorInfo constructor = boxType.getConstructor(v.getType());

            if (isMethod && lc.getParameters().contains(v)) {
                // array[i] = new StrongBox<T>(argument);
                final int index = lc.getParameters().indexOf(v);
                lc.generator.emitNew(boxType);
View Full Code Here

Examples of com.strobel.reflection.ConstructorInfo

    }

    @Test
    public void testNew() throws Exception {
        final Type<NeedsTwoCtorArgs> resultType = Type.of(NeedsTwoCtorArgs.class);
        final ConstructorInfo constructor = resultType.getConstructors(BindingFlags.All).get(0);
        final Type<?> callable = Type.of(Callable.class).makeGenericType(resultType);

        final LambdaExpression<Callable<NeedsTwoCtorArgs>> outer = lambda(
            callable,
            makeNew(
View Full Code Here

Examples of com.volantis.mcs.build.javadoc.ConstructorInfo

    List constructors = classInfo.getConstructors ();
    if (constructors.size () != 1) {
      throw new IllegalStateException ("Must be one constructor");
    }

    ConstructorInfo constructorInfo = (ConstructorInfo) constructors.get (0);
    List parameters = constructorInfo.getParameters ();

    // If the number of parameters is not the same as the total number of
    // fields then error.
    if (parameters.size () != fields.size ()) {
      throw new IllegalStateException ("Not enough parameters in constructor"
View Full Code Here

Examples of com.volantis.mcs.build.javadoc.ConstructorInfo

                                                   field.getName (),
                                                   field.getType ());
      constructorParameters.add (parameter);
    }
   
    ConstructorInfo constructor = new ConstructorInfo (constructorParameters);
    identityClassInfo.addConstructor (constructor);

    // Get the list of extra identity fields.
    if (guardianInfo == null) {
      extraIdentityFields = new ArrayList (allIdentityFields);
View Full Code Here

Examples of com.volantis.mcs.build.javadoc.ConstructorInfo

    }

    // Iterate over all constructors and replicate them in this class
    for (Iterator i = baseConstructors.iterator(); i.hasNext(); /* No ++ */) {

        ConstructorInfo baseConstructor = (ConstructorInfo)i.next();

        // Write the constructor comment.
        GenerateUtilities.openJavaDocComment(out, "  ");
        GenerateUtilities.addJavaDocComment(out, "  ", "Create a new <code>"
                + identityClassName + "</code>.");
        List constructorParameters = baseConstructor.getParameters();
        for (Iterator innerI = constructorParameters.iterator();
                                            innerI.hasNext(); /* No ++ */) {
            ParameterInfo param = (ParameterInfo)innerI.next();
            String paramName = param.getName();
            comment = "@param " + paramName + " " +
                    identityBaseClassInfo.getField(paramName, true).getComment();

            GenerateUtilities.addJavaDocComment(out, "  ", comment);
        }
        GenerateUtilities.closeJavaDocComment(out, "  ");

        // Write the constructor method declaration.
        String startLine = "  public " + identityClassName + " (";
        out.print(startLine);
        separator = null;
        for (Iterator innerI = constructorParameters.iterator();
                                            innerI.hasNext(); /* No ++ */) {
            ParameterInfo param = (ParameterInfo)innerI.next();

            // Output a parameter declaration.
            if (separator == null) {
                separator = ",\n" +
                        GenerateUtilities.getIndent(startLine.length());
            } else {
                out.print(separator);
            }
            out.print (param.getTypeName() + " " + param.getName());
        }
        if (identityFields.size () != 0) {
            for (Iterator fieldsIterator = identityFields.iterator();
                 fieldsIterator.hasNext(); /**/) {
                FieldInfo field = (FieldInfo)fieldsIterator.next();

                if (separator == null){
                    separator = ",\n" +
                             GenerateUtilities.getIndent(startLine.length());
                } else {
                    out.print(separator);
                }

                out.print (field.getTypeName() + " " + field.getName());
            }
        }
        out.println(") {");



        List parameters = baseConstructor.getParameters();
        ParameterInfo firstParam = (ParameterInfo) parameters.get(0);
       
        // If the Project is the first parameter, call the superclass
        // constructor.  If it isn't, call the superclass constructor with
        // null for the project.
View Full Code Here

Examples of com.volantis.mcs.build.javadoc.ConstructorInfo

    List constructors = dstClassInfo.getConstructors ();
    if (constructors.size () != 1) {
      throw new IllegalStateException ("Must be one constructor");
    }

    ConstructorInfo constructorInfo = (ConstructorInfo) constructors.get (0);
    List parameters = constructorInfo.getParameters ();

      String params = "";
      for (Iterator i = parameters.iterator(); i.hasNext(); /**/) {
          params += ((ParameterInfo)i.next()).getName();
          params += " ";
View Full Code Here

Examples of org.apache.commons.modeler.ConstructorInfo

        Node firstN;
        firstN = DomUtil.getChild(mbeanNode, "constructor");
        for (Node descN = firstN; descN != null; descN = DomUtil.getNext(descN)) {

            // Create new constructor info
            ConstructorInfo ci = new ConstructorInfo();
            DomUtil.setAttributes(ci, descN);

            // Process descriptor subnode
            Node firstDescriptorN = DomUtil.getChild(descN, "descriptor");
            if (firstDescriptorN != null) {
                Node firstFieldN = DomUtil.getChild(firstDescriptorN, "field");
                for (Node fieldN = firstFieldN; fieldN != null; fieldN = DomUtil.getNext(fieldN)) {
                    FieldInfo fi = new FieldInfo();
                    DomUtil.setAttributes(fi, fieldN);
                    ci.addField(fi);
                }
            }

            // Process parameter subnodes
            Node firstParamN = DomUtil.getChild(descN, "parameter");
            for (Node paramN = firstParamN; paramN != null; paramN = DomUtil.getNext(paramN)) {
                ParameterInfo pi = new ParameterInfo();
                DomUtil.setAttributes(pi, paramN);
                ci.addParameter(pi);
            }

            // Add this info to our managed bean info
            managed.addConstructor(ci);
View Full Code Here

Examples of org.apache.commons.modeler.ConstructorInfo

                firstN=DomUtil.getChild( mbeanN, "constructor");
                for (Node descN = firstN; descN != null;
                     descN = DomUtil.getNext( descN )) {

                    // Create new constructor info
                    ConstructorInfo ci=new ConstructorInfo();
                    DomUtil.setAttributes(ci, descN);

                    // Process descriptor subnode
                    Node firstDescriptorN =
                        DomUtil.getChild(descN, "descriptor");
                    if (firstDescriptorN != null) {
                        Node firstFieldN =
                            DomUtil.getChild(firstDescriptorN, "field");
                        for (Node fieldN = firstFieldN; fieldN != null;
                             fieldN = DomUtil.getNext(fieldN)) {
                            FieldInfo fi = new FieldInfo();
                            DomUtil.setAttributes(fi, fieldN);
                            ci.addField(fi);
                        }
                    }

                    // Process parameter subnodes
                    Node firstParamN=DomUtil.getChild( descN, "parameter");
                    for (Node paramN = firstParamN;  paramN != null;
                         paramN = DomUtil.getNext(paramN))
                    {
                        ParameterInfo pi=new ParameterInfo();
                        DomUtil.setAttributes(pi, paramN);
                        ci.addParameter( pi );
                    }

                    // Add this info to our managed bean info
                    managed.addConstructor( ci );
                    if (log.isTraceEnabled()) {
View Full Code Here

Examples of org.apache.commons.modeler.ConstructorInfo

                }
            }

            Constructor[] constructors = realClass.getConstructors();
            for(int i=0;i<constructors.length;i++) {
                ConstructorInfo info = new ConstructorInfo();
                String className = realClass.getName();
                int nIndex = -1;
                if((nIndex = className.lastIndexOf('.'))!=-1) {
                    className = className.substring(nIndex+1);
                }
                info.setName(className);
                info.setDescription(constructors[i].getName());
                Class classes[] = constructors[i].getParameterTypes();
                for(int j=0;j<classes.length;j++) {
                    ParameterInfo pi = new ParameterInfo();
                    pi.setType(classes[j].getName());
                    pi.setName("param" + j);
                    pi.setDescription("Introspected parameter param" + j);
                    info.addParameter(pi);
                }
                mbean.addConstructor(info);
            }
           
            if( log.isDebugEnabled())
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.