Examples of JConstructor


Examples of org.exolab.javasource.JConstructor

        fHash.getModifiers().setStatic(true);

        JSourceCode jsc = null;

        //-- modify constructor
        JConstructor constructor = jClass.getConstructor(0);
        constructor.getModifiers().makePrivate();
        constructor.addParameter(new JParameter(JType.INT, "type"));
        constructor.addParameter(new JParameter(SGTypes.STRING, "value"));
        jsc = constructor.getSourceCode();
        jsc.add("this.type = type;");
        jsc.add("this.stringValue = value;");

        createValueOfMethod(jClass, className);
        createEnumerateMethod(jClass, className);
View Full Code Here

Examples of org.exolab.javasource.JConstructor

        JMethod toStringMethod = new JMethod("toString",
                new JClass("java.lang.String"), "the value of this constant");
        toStringMethod.setSourceCode("return this.value;");
        jEnum.addMethod(toStringMethod, false);

        JConstructor constructor = jEnum.createConstructor();
        constructor.addParameter(new JParameter(new JClass("java.lang.String"), "value"));
        constructor.setSourceCode("this.value = value;");
        modifiers = new JModifiers();
        modifiers.makePrivate();
        constructor.setModifiers(modifiers);
        jEnum.addConstructor(constructor);

        int enumCount = 0;
        while (enumeration.hasMoreElements()) {
            Facet facet = (Facet) enumeration.nextElement();
View Full Code Here

Examples of org.exolab.javasource.JConstructor

        JField      fValues = null;
        JDocComment jdc     = null;
        JSourceCode jsc     = null;

        //-- modify constructor
        JConstructor constructor = jClass.getConstructor(0);
        constructor.getModifiers().makePrivate();

        fValues = new JField(new JArrayType(
                baseType.getJType(), getConfig().useJava50()), "values");

        //-- Loop through "enumeration" facets
View Full Code Here

Examples of org.exolab.javasource.JConstructor

       JDODescriptorJClass classDesc =
           new JDODescriptorJClass(_config, descriptorClassName, jClass);
       JDOClassInfoNature cNature = new JDOClassInfoNature(classInfo);

       //-- get handle to default constructor
       JConstructor ctor   = classDesc.getConstructor(0);
       JSourceCode jsc     = ctor.getSourceCode();

       jsc = createClassInfoPart(classInfo, jsc);

       //=================
       // FieldDescriptors
View Full Code Here

Examples of org.exolab.javasource.JConstructor

    /**
     * Adds our default constructor.
     */
    private void addDefaultConstructor() {
        addConstructor(createConstructor());
        JConstructor cons = getConstructor(0);
        JSourceCode jsc = cons.getSourceCode();
        jsc.add("super();");
        jsc.add("ClassMapping mapping = new ClassMapping();");
        jsc.add("ClassChoice choice = new ClassChoice();");
        jsc.add("MapTo mapTo = new MapTo();");
    }
View Full Code Here

Examples of org.exolab.javasource.JConstructor

        XMLInfoNature xmlNature = new XMLInfoNature(textFieldInfo);
       
        // create constructor
        JClass jClass = classInfo.getJClass();
        JParameter parameter = new JParameter(new JClass("java.lang.String"), "defaultValue");
        JConstructor constructor = jClass.createConstructor(new JParameter[] {parameter});
        JSourceCode sourceCode = new JSourceCode();

        if (inherited) {
            sourceCode.add("super(defaultValue);");
        } else {
            sourceCode.add("try {");
            String defaultValue =
                xmlNature.getSchemaType().createDefaultValueWithString("defaultValue");
            sourceCode.addIndented("setContent(" + defaultValue + ");");
            sourceCode.add(" } catch(Exception e) {");
            sourceCode.addIndented("throw new RuntimeException(\"Unable to cast default value for simple content!\");");
            sourceCode.add(" } ");
        }

        constructor.setSourceCode(sourceCode);
        jClass.addConstructor(constructor);
    }
View Full Code Here

Examples of org.exolab.javasource.JConstructor

        while (annotations.hasMoreElements()) {
            Annotation annotation = annotations.nextElement();
            Enumeration<Documentation> documentations = annotation.getDocumentation();
            while (documentations.hasMoreElements()) {
                Documentation documentation = documentations.nextElement();
                JConstructor defaultConstructor = jClass.getConstructor(0);
                String documentationContent = normalize(documentation.getContent());
                documentationContent =
                    StringUtil.replaceAll(documentationContent, "\n", "\"\n+ \" ");
                defaultConstructor.getSourceCode().add("_xmlSchemaDocumentations.put(\""
                        +  documentation.getSource() + "\", \""
                        + documentationContent + "\");");
            }
        }
View Full Code Here

Examples of org.exolab.javasource.JConstructor

            serial.setValue(new String[] {"\"serial\""});
            jClass.addAnnotation(serial);
        }

        //-- add default constructor
        JConstructor con = jClass.createConstructor();
        jClass.addConstructor(con);
        con.getSourceCode().add("super();");
    } //-- initialize
View Full Code Here

Examples of org.exolab.javasource.JConstructor


        jClass.addInterface("java.io.Serializable");

        //-- add default constructor
        JConstructor con = jClass.createConstructor();
        jClass.addConstructor(con);
        con.getSourceCode().add("super();");

        //-- add default import list
        if (_createMarshalMethods) {
           jClass.addImport("org.exolab.castor.xml.Marshaller");
           jClass.addImport("org.exolab.castor.xml.Unmarshaller");
View Full Code Here

Examples of org.exolab.javasource.JConstructor

        JDocComment jdc = null;
        JSourceCode jsc = null;

        //-- modify constructor
        JConstructor constructor = jClass.getConstructor(0);
        constructor.getModifiers().makePrivate();
        constructor.addParameter(new JParameter(JType.Int, "type"));
        constructor.addParameter(new JParameter(SGTypes.String, "value"));
        jsc = constructor.getSourceCode();
        jsc.add("this.type = type;");
        jsc.add("this.stringValue = value;");


        //-- #valueOf method
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.