Examples of LocalJavaField


Examples of org.apache.ws.jaxme.js.LocalJavaField

    }
    return js;
  }

  public void forAllNonNullValues(SimpleTypeSG pController, JavaMethod pMethod, Object pValue, SGlet pSGlet) throws SAXException {
    LocalJavaField f = pMethod.newJavaField(qName);
    f.addLine(pValue);
    pMethod.addIf(f, " != null");
    pSGlet.generate(pMethod, pValue);
    pMethod.addEndIf();
  }
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

    result.addLine("return ", fieldName, ";");
    return result;
  }

  public void forAllValues(PropertySG pController, JavaMethod pMethod, DirectAccessible pElement, SGlet pSGlet) throws SAXException {
    LocalJavaField list = pMethod.newJavaField(List.class);
    list.addLine(pController.getValue(pElement));
    DirectAccessible i = pMethod.addForList(list);
    TypeSG typeSG = objectSG.getTypeSG();
    Object v;
    boolean isCasting = !OBJECT_TYPE.equals(typeSG.getRuntimeType());
    if (isCasting  &&  pSGlet instanceof SGlet.TypedSGlet) {
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

    }
    pMethod.addEndFor();
  }

  public void forAllNonNullValues(PropertySG pController, JavaMethod pMethod, DirectAccessible pElement, SGlet pSGlet) throws SAXException {
    LocalJavaField list = pMethod.newJavaField(List.class);
    list.addLine(pController.getValue(pElement));
    DirectAccessible i = pMethod.addForList(list);
    TypeSG typeSG = objectSG.getTypeSG();
    Object v;
    boolean isCasting = !OBJECT_TYPE.equals(typeSG.getRuntimeType());
    JavaQName qName = typeSG.getRuntimeType();
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

  public void setValue(PropertySG pController, JavaMethod pMethod, DirectAccessible pElement, Object pValue, JavaQName pType) throws SAXException {
    if (pValue != null) {
      pValue = new Object[]{"(", pType, ") ", pValue};
    }
    LocalJavaField list = pMethod.newJavaField(List.class);
    list.addLine(pController.getValue(pElement));
    pMethod.addLine(list, ".clear();");
    pMethod.addLine(list, ".addAll(", pValue, ");");
  }
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

   * @param pMethod The method in which a logging statement should be inserted
   * @param pValues An array of additional values, possibly null
   */
  protected void logEntering(JavaMethod pMethod, Object pValues) {
    if (isGeneratingLogging()) {
      LocalJavaField mName = pMethod.newJavaField(String.class, "mName");
      mName.addLine(JavaSource.getQuoted(pMethod.getLoggingSignature()));
      mName.setFinal(true);
      if (pValues == null) {
        pMethod.addLine("logger.entering(", mName, ");");
      } else {
        pMethod.addLine("logger.entering(", mName, ", ", pValues, ");");        
      }
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

    * @param pMethod The method in which a logging statement should be inserted
    * @param pValues An array of additional values, possibly null
   */
  protected void logFinestEntering(JavaMethod pMethod, Object pValues) {
    if (isGeneratingLogging()) {
      LocalJavaField mName = pMethod.newJavaField(String.class, "mName");
      mName.addLine(JavaSource.getQuoted(pMethod.getLoggingSignature()));
      mName.setFinal(true);
      logFinest(pMethod, JavaSource.getQuoted("->"), pValues);
    }
  }
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

     JavaMethod getValuesMethod = jic.newJavaMethod("getValues", Object[].class, JavaSource.PUBLIC);
     getValuesMethod.addLine("return ", values, ";");

     {
       JavaMethod jm = jic.newJavaMethod("toString", String.class, JavaSource.PUBLIC);
       LocalJavaField sb = jm.newJavaField(StringBuffer.class, "sb");
       sb.addLine("new ", StringBuffer.class, "(", name, ")");
       DirectAccessible loopVar = jm.addForArray(values);
       jm.addLine(sb, ".append(", JavaSource.getQuoted(", "), ").append(",
                  values, "[", loopVar, "]);");
       jm.addEndFor();
       jm.addLine("return ", sb, ".toString();");

     }

     {
       JavaMethod jm = jic.newJavaMethod("hashCode", int.class, JavaSource.PUBLIC);
       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, ";");
     }

     {
       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 != ",
                other, ".values.length");
       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();
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

                                   int pColumnNum, Object pTarget) {
    Integer p = new Integer(pColumnNum+1);

    Column.Type type = pColumn.getType();
    if (Column.Type.BIGINT.equals(type)) {
      LocalJavaField l = pMethod.newJavaField(long.class);
      l.addLine(pResultSet, ".getLong(", p, ");");
      pMethod.addIf("!", pResultSet, ".wasNull()");
      pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                      Long.class, "(", l, ");");
      pMethod.addEndIf();
    } else if (pColumn.isBinaryColumn()) {
      pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ",
                      pResultSet, ".getBytes(", p, ");");
    } else if (Column.Type.BIT.equals(type)) {
      LocalJavaField b = pMethod.newJavaField(boolean.class);
      b.addLine(pResultSet, ".getBoolean(", p, ");");
      pMethod.addIf("!", pResultSet, ".wasNull()");
      pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ", b,
                      " ? ", Boolean.class, ".TRUE : ", Boolean.class, ".FALSE;");
      pMethod.addEndIf();
    } else if (pColumn.isStringColumn()) {
      pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ",
                      pResultSet, ".getString(", p, ");");
    } else if (Column.Type.DATE.equals(type)) {
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ",
                       pResultSet, ".getDate(", p, ");");
    } else if (Column.Type.DOUBLE.equals(type)) {
       LocalJavaField d = pMethod.newJavaField(double.class);
       d.addLine(pResultSet, ".getDouble(", p, ");");
       pMethod.addIf("!", pResultSet, ".wasNull()");
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                       Double.class, "(", d, ");");
       pMethod.addEndIf();
    } else if (Column.Type.FLOAT.equals(type)) {
       LocalJavaField f = pMethod.newJavaField(float.class);
       f.addLine(pResultSet, ".getFloat(", p, ");");
       pMethod.addIf("!", pResultSet, ".wasNull()");
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                       Float.class, "(", f, ");");
       pMethod.addEndIf();
    } else if (Column.Type.INTEGER.equals(type)) {
       LocalJavaField i = pMethod.newJavaField(int.class);
       i.addLine(pResultSet, ".getInt(", p, ");");
       pMethod.addIf("!", pResultSet, ".wasNull()");
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                       Integer.class, "(", i, ");");
       pMethod.addEndIf();
    } else if (Column.Type.SMALLINT.equals(type)) {
       LocalJavaField s = pMethod.newJavaField(short.class);
       s.addLine(pResultSet, ".getShort(", p, ");");
       pMethod.addIf("!", pResultSet, ".wasNull()");
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                       Short.class, "(", s, ");");
       pMethod.addEndIf();
    } else if (Column.Type.TIME.equals(type)) {
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ",
                       pResultSet, ".getTime(", p, ");");
    } else if (Column.Type.TIMESTAMP.equals(type)) {
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = ",
                       pResultSet, ".getTimestamp(", p, ");");
    } else if (Column.Type.TINYINT.equals(type)) {
       LocalJavaField b = pMethod.newJavaField(short.class);
       b.addLine(pResultSet, ".getByte(", p, ");");
       pMethod.addIf("!", pResultSet, ".wasNull()");
       pMethod.addLine(pTarget, "[", Integer.toString(pColumnNum), "] = new ",
                       Byte.class, "(", b, ");");
       pMethod.addEndIf();
    } else {
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

   */
  protected void setPreparedStatementValue(JavaMethod pMethod, Column pColumn,
                                             Object pStmt, Object pParamNum,
                                             Object pValue) {
    if (!(pValue instanceof DirectAccessible)) {
       LocalJavaField v = pMethod.newJavaField(Object.class);
       v.addLine(pValue);
       pValue = v;
    }

    Column.Type type = pColumn.getType();
    pMethod.addIf(pValue, " == null");
View Full Code Here

Examples of org.apache.ws.jaxme.js.LocalJavaField

    SelectStatement statement = table.getSelectStatement();
    statement.getWhere().addColumnSetQuery(pColumnSet, statement.getTableReference());
    String s = table.getSchema().getSQLFactory().newSQLGenerator().getQuery(statement);
    Object query = JavaSource.getQuoted(s);
    if (isGeneratingLogging()) {
      LocalJavaField q = pMethod.newJavaField(String.class);
      q.addLine(query);
      query = q;
      logFinest(pMethod, query, pValues);
    }

    LocalJavaField stmt = pMethod.newJavaField(PreparedStatement.class);
    stmt.addLine(pConn, ".prepareStatement(", JavaSource.getQuoted(s), ");");
    LocalJavaField isStmtClosed = pMethod.newJavaField(boolean.class);
    isStmtClosed.addLine("false");
    pMethod.addTry();

    int paramNum = 0;
    for (Iterator iter = pColumnSet.getColumns();  iter.hasNext()) {
       Object v = new Object[]{pValues, "[", Integer.toString(paramNum), "]"};
       Column column = (Column) iter.next();
       setPreparedStatementValue(pMethod, column, stmt, Integer.toString(++paramNum), v);
    }
    LocalJavaField rs = pMethod.newJavaField(ResultSet.class, "rs");
    rs.addLine(stmt, ".executeQuery()");
    LocalJavaField isRsClosed = pMethod.newJavaField(boolean.class);
    isRsClosed.addLine("false");
    LocalJavaField result;
    if (pReturnValue) {
      result = pMethod.newJavaField(Object[].class, "result");
      result.addLine("null");
    } else {
      result = null;
    }
    pMethod.addTry();

    pMethod.addWhile(rs, ".next()");
    if (result != null) {
      pMethod.addIf(result, " != null");
      pMethod.addThrowNew(IllegalStateException.class,
                          JavaSource.getQuoted("Expected a single row only."));
      pMethod.addEndIf();
    }

    int resultColumnSize = 0;
    for (Iterator iter = table.getColumns();  iter.hasNext();  iter.next()) {
       ++resultColumnSize;
    }
    LocalJavaField row = pMethod.newJavaField(Object[].class, "row");
    row.addLine("new ", Object.class, "[" + resultColumnSize + "];");

    int resultColumnNum = 0;
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
       Column column = (Column) iter.next();
       setResultSetValue(pMethod, column, rs, resultColumnNum++, row);
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.