Package com.sun.codemodel

Examples of com.sun.codemodel.JDefinedClass.method()


            "A " + Calendar.class.getName() + " instance created from {@code " + value.name()
            + "} or {@code null} if {@code " + value.name() + "} is {@code null}." );

        // createXMLGregorianCalendar
        final JMethod createXMLGregorianCalendar =
            of.method( JMod.STATIC, XMLGregorianCalendar.class, "createXMLGregorianCalendar" );

        createXMLGregorianCalendar.body().directStatement( "// " + getMessage( "title" ) );
        value = createXMLGregorianCalendar.param( JMod.FINAL, Calendar.class, "value" );

        final JTryBlock tryBlock = createXMLGregorianCalendar.body()._try();
View Full Code Here


            writerBuilder = new ElementWriterBuilderImpl(buildContext,writerClassName);

        if(contextClassName!=null) {
            try {
                JDefinedClass cc = buildContext.getCodeModel()._class(contextClassName);
                cc.method(JMod.PUBLIC, Reader.class,"createReader")
                    .body()._return( parserBuilder!=null
                        ? JExpr._new(parserBuilder.getReaderClass())
                        : JExpr._null());
                cc.method(JMod.PUBLIC, Writer.class,"createWriter")
                    .body()._return( writerBuilder!=null
View Full Code Here

                JDefinedClass cc = buildContext.getCodeModel()._class(contextClassName);
                cc.method(JMod.PUBLIC, Reader.class,"createReader")
                    .body()._return( parserBuilder!=null
                        ? JExpr._new(parserBuilder.getReaderClass())
                        : JExpr._null());
                cc.method(JMod.PUBLIC, Writer.class,"createWriter")
                    .body()._return( writerBuilder!=null
                        ? JExpr._new(writerBuilder.getWriterClass())
                        : JExpr._null());
            } catch (JClassAlreadyExistsException e) {
                throw new BuildException(e);
View Full Code Here

        if(contextClassName!=null) {
            try {
                JDefinedClass cc = buildContext.getCodeModel()._class(contextClassName);
                cc._extends(Context.class);
                cc.method(JMod.PUBLIC, Reader.class,"createReader")
                    .body()._return( parserBuilder!=null
                        ? JExpr._new(parserBuilder.getReaderClass()).arg(JExpr._this())
                        : JExpr._null());
                cc.method(JMod.PUBLIC, Writer.class,"createWriter")
                    .body()._return( writerBuilder!=null
View Full Code Here

                cc._extends(Context.class);
                cc.method(JMod.PUBLIC, Reader.class,"createReader")
                    .body()._return( parserBuilder!=null
                        ? JExpr._new(parserBuilder.getReaderClass()).arg(JExpr._this())
                        : JExpr._null());
                cc.method(JMod.PUBLIC, Writer.class,"createWriter")
                    .body()._return( writerBuilder!=null
                        ? JExpr._new(writerBuilder.getWriterClass()).arg(JExpr._this())
                        : JExpr._null());
            } catch (JClassAlreadyExistsException e) {
                throw new BuildException(e);
View Full Code Here

    private void addToStringMethod(ClassOutline co,
                                   JClass delegateImpl,
                                   JFieldRef toStringDelegateStyleParam) {
        final JDefinedClass implementation = co.implClass;
        final JMethod toStringMethod = implementation.method(JMod.PUBLIC, String.class, "toString");
        final JInvocation invoke = delegateImpl.staticInvoke("valueOf");
        invoke.arg(JExpr._this());
        invoke.arg(toStringDelegateStyleParam);
        toStringMethod.body()._return(invoke);
       
View Full Code Here

    private void addToStringMethod(ClassOutline co,
                                   JClass delegateImpl,
                                   JFieldRef toStringDelegateStyleParam) {
        final JDefinedClass implementation = co.implClass;
        final JMethod toStringMethod = implementation.method(JMod.PUBLIC, String.class, "toString");
        final JInvocation invoke = delegateImpl.staticInvoke("valueOf");
        invoke.arg(JExpr._this());
        invoke.arg(toStringDelegateStyleParam);
        toStringMethod.body()._return(invoke);
       
View Full Code Here

     * {@link JAXBContext} object can be used.
     */
    private void generateClassList() {
        try {
            JDefinedClass jc = codeModel.rootPackage()._class("JAXBDebug");
            JMethod m = jc.method(JMod.PUBLIC|JMod.STATIC,JAXBContext.class,"createContext");
            JVar $classLoader = m.param(ClassLoader.class,"classLoader");
            m._throws(JAXBException.class);
            JInvocation inv = codeModel.ref(JAXBContext.class).staticInvoke("newInstance");
            m.body()._return(inv);

View Full Code Here

                $loc.annotate(XmlLocation.class);
                $loc.annotate(XmlTransient.class);

                impl._implements(Locatable.class);

                impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);
               
                JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
                JVar $newLoc = setter.param(Locator.class, "newLocator");
                setter.body().assign($loc, $newLoc);
            }
View Full Code Here

                impl._implements(Locatable.class);

                impl.method(JMod.PUBLIC, Locator.class, "sourceLocation").body()._return($loc);
               
                JMethod setter = impl.method(JMod.PUBLIC, Void.TYPE, "setSourceLocation");
                JVar $newLoc = setter.param(Locator.class, "newLocator");
                setter.body().assign($loc, $newLoc);
            }
        }
       
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.