Package org.apache.ws.jaxme.js

Examples of org.apache.ws.jaxme.js.JavaMethod.addIf()


    JavaMethod fromValueMethod = js.newJavaMethod("fromValue", qName, JavaSource.PUBLIC);
    pValue = fromValueMethod.addParam(valueType, "pValue");
    fromValueMethod.setStatic(true);
    DirectAccessible i = fromValueMethod.addForArray(instances);
    fromValueMethod.addIf(pController.getEqualsCheck(fromValueMethod, new Object[]{instances, "[", i, "].value"}, pValue));
    fromValueMethod.addLine("return ", instances, "[", i, "];");
    fromValueMethod.addEndIf();
    fromValueMethod.addEndFor();
    fromValueMethod.addThrowNew(IllegalArgumentException.class, JavaSource.getQuoted("Invalid value: "),
                                " + ", pValue);
View Full Code Here


    JavaMethod fromNameMethod = js.newJavaMethod("fromName", qName, JavaSource.PUBLIC);
    pName = fromNameMethod.addParam(String.class, "pName");
    fromNameMethod.setStatic(true);
    i = fromNameMethod.addForArray(instances);
    fromNameMethod.addIf(instances, "[", i, "].name.equals(", pName, ")");
    fromNameMethod.addLine("return ", instances, "[", i, "];");
    fromNameMethod.addEndIf();
    fromNameMethod.addEndFor();
    fromNameMethod.addThrowNew(IllegalArgumentException.class, JavaSource.getQuoted("Invalid name: "),
                                " + ", pName);
View Full Code Here

   getInstanceByName.addLine(String.class, " s = pName.intern();");
   boolean first = true;
   for (int i = 0;  i < pItems.length;  i++) {
    Item item = pItems[i];
    Object[] args = new Object[]{JavaSource.getQuoted(item.getName()), " == s"};
     getInstanceByName.addIf(first, args);
     getInstanceByName.addLine("return ", item.getName(), ";");
     first = false;
   }
   getInstanceByName.addElse();
   getInstanceByName.addLine("throw new ", IllegalArgumentException.class, "(",
View Full Code Here

   getInstanceByValue.addLine(String.class, " s = pValue.intern();");
   first = true;
   for (int i = 0;  i < pItems.length;  i++) {
    Item item = pItems[i];
    Object[] args = new Object[]{JavaSource.getQuoted(item.getValue()), " == s"};
    getInstanceByValue.addIf(first, args);
    getInstanceByValue.addLine("return ", item.getName(), ";");
    first = false;
   }
   getInstanceByValue.addElse();
   getInstanceByValue.addLine("throw new ", IllegalArgumentException.class, "(",
View Full Code Here

   if (isAddingEquals()) {
     JavaMethod equals = pSource.newJavaMethod("equals", JavaQNameImpl.BOOLEAN,
                                               JavaSource.PUBLIC);
     equals.addParam(Object.class, "o");
     equals.addIf("o == null  ||  !(o instanceof ", pSource.getQName(), ")");
     equals.addLine("return false;");
     equals.addEndIf();
     equals.addLine("return name.equals(((", pSource.getQName(), ") o).name);");

      JavaMethod hashCode = pSource.newJavaMethod("hashCode", JavaQNameImpl.INT,
View Full Code Here

       LocalJavaField hashCodeResult = jm.newJavaField(int.class, "result");
       hashCodeResult.addLine(name, ".hashCode() + ", values, ".length;");
       DirectAccessible loopVar = jm.addForArray(values);
       LocalJavaField o = jm.newJavaField(Object.class, "o");
       o.addLine(values, "[", loopVar, "]");
       jm.addIf(o, " != null");
       jm.addLine(hashCodeResult, " += ", o, ".hashCode();");
       jm.addEndIf();
       jm.addEndFor();
       jm.addLine("return ", hashCodeResult, ";");
     }
View Full Code Here

     }

     {
       JavaMethod jm = jic.newJavaMethod("equals", boolean.class, JavaSource.PUBLIC);
       DirectAccessible o = jm.addParam(Object.class, "o");
       jm.addIf(o, " == null  ||  !(", o, " instanceof ", jic.getQName(), ")");
       jm.addLine("return false;");
       jm.addEndIf();
       LocalJavaField other = jm.newJavaField(jic.getQName(), "other");
       other.addLine("(", jic.getQName(), ") ", o);
       jm.addIf("!", name, ".equals(", other, ".name)  ||  ", values, ".length != ",
View Full Code Here

       jm.addIf(o, " == null  ||  !(", o, " instanceof ", jic.getQName(), ")");
       jm.addLine("return false;");
       jm.addEndIf();
       LocalJavaField other = jm.newJavaField(jic.getQName(), "other");
       other.addLine("(", jic.getQName(), ") ", o);
       jm.addIf("!", name, ".equals(", other, ".name)  ||  ", values, ".length != ",
                other, ".values.length");
       jm.addLine("return false;");
       jm.addEndIf();
       DirectAccessible loopVar = jm.addForArray(values);
       LocalJavaField v = jm.newJavaField(Object.class, "v");
View Full Code Here

       jm.addLine("return false;");
       jm.addEndIf();
       DirectAccessible loopVar = jm.addForArray(values);
       LocalJavaField v = jm.newJavaField(Object.class, "v");
       v.addLine(values, "[", loopVar, "]");
       jm.addIf(v, " == null");
       jm.addIf(other, ".values[", loopVar, "] != null");
       jm.addLine("return false;");
       jm.addEndIf();
       jm.addElse();
       jm.addIf("!", v, ".equals(", other, ".values[", loopVar, "])");
View Full Code Here

       jm.addEndIf();
       DirectAccessible loopVar = jm.addForArray(values);
       LocalJavaField v = jm.newJavaField(Object.class, "v");
       v.addLine(values, "[", loopVar, "]");
       jm.addIf(v, " == null");
       jm.addIf(other, ".values[", loopVar, "] != null");
       jm.addLine("return false;");
       jm.addEndIf();
       jm.addElse();
       jm.addIf("!", v, ".equals(", other, ".values[", loopVar, "])");
       jm.addLine("return false;");
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.