Package com.sun.codemodel

Examples of com.sun.codemodel.JBlock.decl()


        JMethod fromValue = _enum.method(JMod.PUBLIC | JMod.STATIC, _enum, "fromValue");
        JVar valueParam = fromValue.param(String.class, "value");

        JBlock body = fromValue.body();
        JVar constant = body.decl(_enum, "constant");
        constant.init(quickLookupMap.invoke("get").arg(valueParam));

        JConditional _if = body._if(constant.eq(JExpr._null()));

        JInvocation illegalArgumentException = JExpr._new(_enum.owner().ref(IllegalArgumentException.class));
View Full Code Here


  private void generateSetup(ClassGenerator<?> g, JVar[] workspaceJVars) {
    JCodeModel m = g.getModel();
    JBlock sub = new JBlock(true, true);

    // declare and instantiate argument ObjectInspector's
    JVar oiArray = sub.decl(
      m._ref(ObjectInspector[].class),
      "argOIs",
      JExpr.newArray(m._ref(ObjectInspector.class), argTypes.length));

    JClass oih = m.directClass(ObjectInspectorHelper.class.getCanonicalName());
View Full Code Here

                   
                                block.add(new JBlankLine());

                                // convert raw value into bound type
                                Class targetType = toClass(mapping.getComponentType());
                                JVar valueVar = block.decl(context.toJClass(targetType), propertyName);
                                JTryBlock tryBlock = block._try();
                                tryBlock.body().assign(valueVar, adapterVar.invoke("unmarshal").arg(value));

                                JCatchBlock catchException = tryBlock._catch(context.toJClass(Exception.class));
                                JBlock catchBody = catchException.body();
View Full Code Here

                            JVar itemVar;
                            if (toClass(property.getComponentType()) == String.class) {
                                itemVar = outerVar;
                            } else {
                                String itemName = builder.getWriteVariableManager().createId("string");
                                itemVar = block.decl(context.toJClass(String.class), itemName, JExpr.cast(context.toJClass(String.class), outerVar));
                            }
                            writeSimpleTypeElement(builder, itemVar, String.class, block);
                        }

                        ElementMapping nilMapping = null;
View Full Code Here

                            JVar itemVar;
                            if (toClass(property.getComponentType()) == itemType) {
                                itemVar = outerVar;
                            } else {
                                String itemName = builder.getWriteVariableManager().createId(itemType.getSimpleName());
                                itemVar = block.decl(context.toJClass(itemType), itemName, JExpr.cast(context.toJClass(itemType), outerVar));
                            }
                            writeElement(builder, block, mapping, itemVar, itemType, false, property.isXmlList());
                        }

                        // if item was null, write xsi:nil or report an error
View Full Code Here

                            itemType = context.getGenericType(property.getComponentType());
                        } else {
                            itemType = context.toJType((Class<?>) toClass(property.getComponentType()));
                        }

                        firstVar = collectionNotNull.decl(context.toJType(boolean.class), builder.getWriteVariableManager().createId(property.getName() + "First"), JExpr.TRUE);

                        String itemName = builder.getWriteVariableManager().createId( property.getName() + "Item");
                        JForEach each = collectionNotNull.forEach(itemType, itemName, propertyVar);

                        JBlock newBody = each.body();
View Full Code Here

        JInvocation invocation = JExpr.invoke(nextMethod).arg(xsrVar).arg(rtContextVar);
        for (JVar v : b.variables) {
            invocation.arg(v);
        }
       
        return block.decl(type, varName, invocation);
    }

    public CodeBody getBody() {
        return new CodeBodyImpl(this);
    }
View Full Code Here

       
        if (attributes.size() > 0) {
            writeAttributeReader(b);
        }
       
        JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));
        JVar targetDepthVar;
        JVar event;
        if (depth == 1) {
            targetDepthVar = b.decl(model._ref(int.class), "targetDepth", JExpr.lit(depth));
            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("getEventType"));
View Full Code Here

       
        JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));
        JVar targetDepthVar;
        JVar event;
        if (depth == 1) {
            targetDepthVar = b.decl(model._ref(int.class), "targetDepth", JExpr.lit(depth));
            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("getEventType"));
        } else {
            targetDepthVar = b.decl(model._ref(int.class), "targetDepth", depthVar.plus(JExpr.lit(1)));
            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
        }
View Full Code Here

        JVar depthVar = b.decl(model._ref(int.class), "depth", xsrVar.invoke("getDepth"));
        JVar targetDepthVar;
        JVar event;
        if (depth == 1) {
            targetDepthVar = b.decl(model._ref(int.class), "targetDepth", JExpr.lit(depth));
            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("getEventType"));
        } else {
            targetDepthVar = b.decl(model._ref(int.class), "targetDepth", depthVar.plus(JExpr.lit(1)));
            event = b.decl(model._ref(int.class), "event", xsrVar.invoke("nextTagIgnoreAll"));
        }
       
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.