Package com.sun.codemodel

Examples of com.sun.codemodel.JMethod.body()


    final JMethod toString = coordinateClass.method(JMod.PUBLIC, stringClass, "toString");
    toString.annotate(Override.class);
    final JVar sbVar = toString.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    toString.body().add(sbVar.invoke("append").arg(longitude));
    toString.body().add(sbVar.invoke("append").arg(","));
    toString.body().add(sbVar.invoke("append").arg(latitude));
    toString.body()._if(JExpr.ref(altitude.name()).ne(JExpr.lit(0.0)))._then().add(sbVar.invoke("append").arg(",")).add(
        sbVar.invoke("append").arg(altitude));
    toString.body()._return(sbVar.invoke("toString"));

    addSimpleSetterAndGetter(coordinateClass, longitude);
View Full Code Here


    final JFieldVar KML_21 = namespaceFilterHandler.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, stringClass, "KML_21", JExpr.lit("http://earth.google.com/kml/2.1"));
    final JFieldVar KML_22 = namespaceFilterHandler.field(JMod.PRIVATE | JMod.STATIC | JMod.FINAL, stringClass, "KML_22", JExpr.lit("http://www.opengis.net/kml/2.2"));
    final JFieldVar content = namespaceFilterHandler.field(JMod.PRIVATE, contentHandlerClass, "contentHandler");
    final JMethod constructor = namespaceFilterHandler.constructor(JMod.PUBLIC);
    final JVar constructorParam = constructor.param(contentHandlerClass, "contentHandler");
    constructor.body().assign(JExpr._this().ref(content), constructorParam);
   
    final JMethod startElement = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "startElement");
    startElement._throws(SAXException.class);
    final JVar uri = startElement.param(stringClass, "uri");
    final JVar localName = startElement.param(stringClass, "localName");
View Full Code Here

    toString.annotate(Override.class);
    final JVar sbVar = toString.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    toString.body().add(sbVar.invoke("append").arg(longitude));
    toString.body().add(sbVar.invoke("append").arg(","));
    toString.body().add(sbVar.invoke("append").arg(latitude));
    toString.body()._if(JExpr.ref(altitude.name()).ne(JExpr.lit(0.0)))._then().add(sbVar.invoke("append").arg(",")).add(
        sbVar.invoke("append").arg(altitude));
    toString.body()._return(sbVar.invoke("toString"));

    addSimpleSetterAndGetter(coordinateClass, longitude);
    addSimpleSetterAndGetter(coordinateClass, latitude);
View Full Code Here

    toString.body().add(sbVar.invoke("append").arg(longitude));
    toString.body().add(sbVar.invoke("append").arg(","));
    toString.body().add(sbVar.invoke("append").arg(latitude));
    toString.body()._if(JExpr.ref(altitude.name()).ne(JExpr.lit(0.0)))._then().add(sbVar.invoke("append").arg(",")).add(
        sbVar.invoke("append").arg(altitude));
    toString.body()._return(sbVar.invoke("toString"));

    addSimpleSetterAndGetter(coordinateClass, longitude);
    addSimpleSetterAndGetter(coordinateClass, latitude);
    addSimpleSetterAndGetter(coordinateClass, altitude);
View Full Code Here

    startElement._throws(SAXException.class);
    final JVar uri = startElement.param(stringClass, "uri");
    final JVar localName = startElement.param(stringClass, "localName");
    final JVar qName = startElement.param(stringClass, "qName");
    final JVar atts = startElement.param(Attributes.class, "atts");
    final JConditional if1 = startElement.body()._if(uri.invoke("equals").arg(KML_20).cor(uri.invoke("equals").arg(KML_21)));
    if1._then().block().add(content.invoke("startElement").arg(KML_22).arg(localName).arg(qName).arg(atts));
    if1._else().block().add(content.invoke("startElement").arg(uri).arg(localName).arg(qName).arg(atts));
   
    final JMethod characters = namespaceFilterHandler.method(JMod.PUBLIC, cc.implClass.owner().VOID, "characters");
    final JVar charCh = characters.param(cc.implClass.owner().CHAR.array(), "ch");
View Full Code Here

    // toString
    final JMethod marshall = coordinateClassConverter.method(JMod.PUBLIC, String.class, "marshal");
    final JVar stringConstructorArg = marshall.param(JMod.FINAL, listGenericsCoordinates, "dt");
    marshall._throws(Exception.class);
    marshall.annotate(Override.class);
    final JVar sbVarMarshall = marshall.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    final JForEach forMarshall = marshall.body().forEach(coordinateClass, "coord", stringConstructorArg);
    // forMarshall.body().add(sbVarMarshall.invoke("append").arg(forMarshall.var().name() + " + \" \""));
    forMarshall.body().add(sbVarMarshall.invoke("append").arg(JExpr.direct("coord + \" \"")));
    marshall.body()._return(sbVarMarshall.invoke("toString").invoke("trim"));
View Full Code Here

    final JMethod marshall = coordinateClassConverter.method(JMod.PUBLIC, String.class, "marshal");
    final JVar stringConstructorArg = marshall.param(JMod.FINAL, listGenericsCoordinates, "dt");
    marshall._throws(Exception.class);
    marshall.annotate(Override.class);
    final JVar sbVarMarshall = marshall.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    final JForEach forMarshall = marshall.body().forEach(coordinateClass, "coord", stringConstructorArg);
    // forMarshall.body().add(sbVarMarshall.invoke("append").arg(forMarshall.var().name() + " + \" \""));
    forMarshall.body().add(sbVarMarshall.invoke("append").arg(JExpr.direct("coord + \" \"")));
    marshall.body()._return(sbVarMarshall.invoke("toString").invoke("trim"));

    // toString
View Full Code Here

    marshall.annotate(Override.class);
    final JVar sbVarMarshall = marshall.body().decl(stringBuilderClass, "sb", JExpr._new(stringBuilderClass));
    final JForEach forMarshall = marshall.body().forEach(coordinateClass, "coord", stringConstructorArg);
    // forMarshall.body().add(sbVarMarshall.invoke("append").arg(forMarshall.var().name() + " + \" \""));
    forMarshall.body().add(sbVarMarshall.invoke("append").arg(JExpr.direct("coord + \" \"")));
    marshall.body()._return(sbVarMarshall.invoke("toString").invoke("trim"));

    // toString
    final JMethod unmarshall = coordinateClassConverter.method(JMod.PUBLIC, listGenericsCoordinates, "unmarshal");
    final JVar unmarshallparam = unmarshall.param(JMod.FINAL, String.class, "s");
    unmarshall._throws(Exception.class);
View Full Code Here

      m.javadoc().append("Create an instance of ").append(cc.ref);
      final JInvocation returntype = JExpr._new(cc.implRef);
      final JVar arg = m.param(JMod.FINAL, String.class, "coordinates");
      m.javadoc().addParam(arg).append("required parameter");
      returntype.arg(arg);
      m.body()._return(returntype);
      return;
    }
   
   
    final Collection<JFieldVar> requiredConstructorFields = Util.getConstructorRequiredFields(cc);
View Full Code Here

    //    http://code.google.com/p/javaapiforkml/issues/detail?id=10
    //    changed:
    //      String[] coords = s.replaceAll(",[ ]+?", ",").trim().split(" ");
    //      to:
    //      String[] coords = s.replaceAll(",\\s+", ",").trim().split("\\s+");
    final JVar varCoords1 = unmarshall.body().decl(stringClass.array(), "coords",
        unmarshallparam.invoke("replaceAll").arg(",[\\s]+").arg(",").invoke("trim").invoke("split").arg("\\s+"));

    final JVar coordinateslist = unmarshall.body().decl(listGenericsCoordinates, "coordinates", JExpr._new(arraylistGenericsCoordinates));
    unmarshall.body()._if(JExpr.ref(varCoords1.name()).ref("length").lte(JExpr.lit(0)))._then().block()._return(coordinateslist);
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.