public void toRawValue(JBlock block, JVar $var) { JCodeModel cm = outline().getCodeModel(); JClass elementType = ei.toType(outline(),EXPOSED).boxify(); // [RESULT] // $var = new ArrayList(); // for( JAXBElement e : [core.toRawValue] ) { // if(e==null) // $var.add(null); // else // $var.add(e.getValue()); // } block.assign($var,JExpr._new(cm.ref(ArrayList.class).narrow(itemType().boxify()))); JVar $col = block.decl(core.getRawType(), "col" + hashCode()); acc.toRawValue(block,$col); JForEach loop = block.forEach(elementType, "v" + hashCode()/*unique string handling*/, $col); JConditional cond = loop.body()._if(loop.var().eq(JExpr._null())); cond._then().invoke($var,"add").arg(JExpr._null()); cond._else().invoke($var,"add").arg(loop.var().invoke("getValue")); }
private void writeResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getResource").arg(wsdlLocation)); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null())); ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg( "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath.")); staticBlock.assign(exField, exVar); }
private void writeClassLoaderResourceWSDLLocation(String className, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JBlock staticBlock = cls.init(); staticBlock.assign(urlField, JExpr.dotclass(cm.ref(className)).invoke("getClassLoader").invoke("getResource").arg(wsdlLocation)); JVar exVar = staticBlock.decl(cm.ref(WebServiceException.class), "e", JExpr._null()); JConditional ifBlock = staticBlock._if(urlField.eq(JExpr._null())); ifBlock._then().assign(exVar, JExpr._new(cm.ref(WebServiceException.class)).arg( "Cannot find "+JExpr.quotify('\'', wsdlLocation)+" wsdl. Place the resource correctly in the classpath.")); staticBlock.assign(exField, exVar); }
public void toRawValue(JBlock block, JVar $var) { // [RESULT] // if([core.hasSetValue]) // $var = [core.toRawValue].getValue(); // else // $var = null; JConditional cond = block._if(acc.hasSetValue()); JVar $v = cond._then().decl(core.getRawType(), "v" + hashCode());// TODO: unique value control acc.toRawValue(cond._then(),$v); cond._then().assign($var,$v.invoke("getValue")); cond._else().assign($var, JExpr._null()); }
private void writeGetWsdlLocation(JType retType, JDefinedClass cls, JFieldVar urlField, JFieldVar exField) { JMethod m = cls.method(JMod.PRIVATE|JMod.STATIC , retType, "__getWsdlLocation"); JConditional ifBlock = m.body()._if(exField.ne(JExpr._null())); ifBlock._then()._throw(exField); m.body()._return(urlField); }