Package com.sun.codemodel

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


    // toString
    final JMethod unmarshal = booleanConverter.method(JMod.PUBLIC, Boolean.class, "unmarshal");
    final JVar stringConstructorArg = unmarshal.param(JMod.FINAL, Integer.class, "i");
    unmarshal.annotate(Override.class);
    unmarshal._throws(Exception.class);
    unmarshal.body()._return(JOp.cond(stringConstructorArg.eq(JExpr._null()), JExpr._null(), stringConstructorArg.eq(JExpr.lit(1))));
   
    // toString
    final JMethod marshal = booleanConverter.method(JMod.PUBLIC, Integer.class, "marshal");
    final JVar unmarshallparam = marshal.param(JMod.FINAL, Boolean.class, "b");
    marshal.annotate(Override.class);
View Full Code Here


    // toString
    final JMethod marshal = booleanConverter.method(JMod.PUBLIC, Integer.class, "marshal");
    final JVar unmarshallparam = marshal.param(JMod.FINAL, Boolean.class, "b");
    marshal.annotate(Override.class);
    marshal._throws(Exception.class);
    marshal.body()._return(JOp.cond(unmarshallparam.eq(JExpr._null()), JExpr._null(), JOp.cond(unmarshallparam, JExpr.lit(1), JExpr.lit(0))));

  }


  @Override
View Full Code Here

    //    http://code.google.com/p/javaapiforkml/issues/detail?id=10
    //    changed:
    //      String[] coords = coordinates.replaceAll(",[ ]+?", ",").trim().split(",");
    //      to:
    //      String[] coords = coordinates.replaceAll(",\\s+", ",").trim().split(",");
    final JVar varCoords = stringArgConstructor.body().decl(stringClass.array(), "coords",
        stringConstructorArg.invoke("replaceAll").arg(",\\s+").arg(",").invoke("trim").invoke("split").arg(","));
    // CODE: if ((coords < 1) && (coords > 3)) {throw IllegalArgumentException}
    stringArgConstructor.body()._if(
        JExpr.ref(varCoords.name()).ref("length").lt(JExpr.lit(1)).cand(JExpr.ref(varCoords.name()).ref("length").gt(JExpr.lit(3))))
        ._then()._throw(JExpr._new(illegalArgumentExceptionClass));
View Full Code Here

    //      to:
    //      String[] coords = coordinates.replaceAll(",\\s+", ",").trim().split(",");
    final JVar varCoords = stringArgConstructor.body().decl(stringClass.array(), "coords",
        stringConstructorArg.invoke("replaceAll").arg(",\\s+").arg(",").invoke("trim").invoke("split").arg(","));
    // CODE: if ((coords < 1) && (coords > 3)) {throw IllegalArgumentException}
    stringArgConstructor.body()._if(
        JExpr.ref(varCoords.name()).ref("length").lt(JExpr.lit(1)).cand(JExpr.ref(varCoords.name()).ref("length").gt(JExpr.lit(3))))
        ._then()._throw(JExpr._new(illegalArgumentExceptionClass));
   
    stringArgConstructor.body().assign(JExpr.refthis(longitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[0]")));
View Full Code Here

    // CODE: if ((coords < 1) && (coords > 3)) {throw IllegalArgumentException}
    stringArgConstructor.body()._if(
        JExpr.ref(varCoords.name()).ref("length").lt(JExpr.lit(1)).cand(JExpr.ref(varCoords.name()).ref("length").gt(JExpr.lit(3))))
        ._then()._throw(JExpr._new(illegalArgumentExceptionClass));
   
    stringArgConstructor.body().assign(JExpr.refthis(longitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[0]")));
    stringArgConstructor.body().assign(JExpr.refthis(latitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[1]")));
    stringArgConstructor.body()._if(JExpr.ref(varCoords.name()).ref("length").eq(JExpr.lit(3)))._then().assign(
        JExpr.refthis(altitude.name()), JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[2]")));
View Full Code Here

        JExpr.ref(varCoords.name()).ref("length").lt(JExpr.lit(1)).cand(JExpr.ref(varCoords.name()).ref("length").gt(JExpr.lit(3))))
        ._then()._throw(JExpr._new(illegalArgumentExceptionClass));
   
    stringArgConstructor.body().assign(JExpr.refthis(longitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[0]")));
    stringArgConstructor.body().assign(JExpr.refthis(latitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[1]")));
    stringArgConstructor.body()._if(JExpr.ref(varCoords.name()).ref("length").eq(JExpr.lit(3)))._then().assign(
        JExpr.refthis(altitude.name()), JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[2]")));

    // toString
View Full Code Here

   
    stringArgConstructor.body().assign(JExpr.refthis(longitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[0]")));
    stringArgConstructor.body().assign(JExpr.refthis(latitude.name()),
        JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[1]")));
    stringArgConstructor.body()._if(JExpr.ref(varCoords.name()).ref("length").eq(JExpr.lit(3)))._then().assign(
        JExpr.refthis(altitude.name()), JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[2]")));

    // toString
    final JMethod toString = coordinateClass.method(JMod.PUBLIC, stringClass, "toString");
    toString.annotate(Override.class);
View Full Code Here

        JExpr.refthis(altitude.name()), JExpr.ref("Double").invoke("parseDouble").arg(JExpr.direct("coords[2]")));

    // toString
    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));
View Full Code Here

    // toString
    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"));
View Full Code Here

    // toString
    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"));
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.