Examples of LocalJavaField


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

                }
          }
        }
       
        JavaMethod jm = pJs.newJavaMethod(pMethod);
        LocalJavaField v = jm.newJavaField(Vector.class);
        v.addLine("new ", Vector.class, "()");
        Parameter[] params = jm.getParams();
        for (int i = 0;  i < params.length;  i++) {
          Parameter p = params[i];
            jm.addLine(v, ".add(", getInputValue(jm, p.getType(), p), ");");
        }
View Full Code Here

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

        comment.addLine("Called for invocation of method <code>pName</code> with");
        comment.addLine("the parameters given by <code>pParams</code>.");
        Parameter name = jm.addParam(String.class, "pName");
        Parameter args = jm.addParam(Vector.class, "pParams");
        jm.addThrows(Exception.class);
        LocalJavaField invoker = jm.newJavaField(pInvoker);
        invoker.addLine("getInvoker(", name, ")");
        jm.addIf(invoker, " == null");
        jm.addThrowNew(IllegalStateException.class,
                       JavaSource.getQuoted("Unknown method name: "),
                       " + ", name);
        jm.addEndIf();
View Full Code Here

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

      } else if (Column.Type.TINYINT.equals(type)) {
        pMethod.addLine(pStmt, ".setByte(", pParamNum, ", ", pValue, ");");
      }
    } else {
      if (!(pValue instanceof DirectAccessible)) {
         LocalJavaField v = pMethod.newJavaField(pTypeSG.getRuntimeType());
         v.addLine(pValue);
         pValue = v;
      }
      pMethod.addIf(pValue, " == null");
      pMethod.addLine(pStmt, ".setNull(", pParamNum, ", ", Types.class, ".", type, ");");
      pMethod.addElse();
View Full Code Here

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

      if (pColumn.isStringColumn()) {
        return new Object[]{pRs, ".getString(", pParamNum, ")"};
      } else if (pColumn.isBinaryColumn()) {
        return new Object[]{pRs, ".getBytes(", pParamNum, ")"};
      } else if (Column.Type.DATE.equals(type)) {
        LocalJavaField cal = pMethod.newJavaField(Calendar.class);
        LocalJavaField date = pMethod.newJavaField(Date.class);
        date.addLine(pRs, ".getDate(", pParamNum, ")");
        pMethod.addIf(date, " == null");
        pMethod.addLine(cal, " = null;");
        pMethod.addElse();
        pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
        pMethod.addLine(cal, ".setTime(", date, ");");
        pMethod.addLine(cal, ".set(", Calendar.class, ".HOUR, 0);");
        pMethod.addLine(cal, ".set(", Calendar.class, ".MINUTE, 0);");
        pMethod.addLine(cal, ".set(", Calendar.class, ".SECOND, 0);");
        pMethod.addLine(cal, ".set(", Calendar.class, ".MILLISECOND, 0);");
        pMethod.addEndIf();
        return cal;
      } else if (Column.Type.TIME.equals(type)) {
        LocalJavaField cal = pMethod.newJavaField(Calendar.class);
        LocalJavaField date = pMethod.newJavaField(Time.class);
        date.addLine(pRs, ".getTime(", pParamNum, ")");
        pMethod.addIf(date, " == null");
        pMethod.addLine(cal, " = null;");
        pMethod.addElse();
        pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
        pMethod.addLine(cal, ".setTime(", date, ");");
        pMethod.addLine(cal, ".set(", Calendar.class, ".YEAR, 0);");
        pMethod.addLine(cal, ".set(", Calendar.class, ".MONTH, 0);");
        pMethod.addLine(cal, ".set(", Calendar.class, ".DAY_OF_MONTH, 0);");
        pMethod.addEndIf();
        return cal;
      } else if (Column.Type.TIMESTAMP.equals(type)) {
        LocalJavaField cal = pMethod.newJavaField(Calendar.class);
        LocalJavaField date = pMethod.newJavaField(Timestamp.class);
        date.addLine(pRs, ".getTimestamp(", pParamNum, ")");
        pMethod.addIf(date, " == null");
        pMethod.addLine(cal, " = null;");
        pMethod.addElse();
        pMethod.addLine(cal, " = ", Calendar.class, ".getInstance();");
        pMethod.addLine(cal, ".setTime(", date, ");");
        pMethod.addEndIf();
        return cal;
      } else if (Column.Type.BIT.equals(type)) {
        LocalJavaField b = pMethod.newJavaField(boolean.class);
        b.addLine(pRs, ".getBoolean(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : ",
                               b, " ? ", Boolean.class, ".TRUE : ", Boolean.class, ".FALSE)"};
      } else if (Column.Type.BIGINT.equals(type)) {
        LocalJavaField l = pMethod.newJavaField(long.class);
        l.addLine(pRs, ".getLong(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Long(", l, ")"};
      } else if (Column.Type.DOUBLE.equals(type)) {
        LocalJavaField d = pMethod.newJavaField(double.class);
        d.addLine(pRs, ".getDouble(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Double(", d, ")"};
      } else if (Column.Type.FLOAT.equals(type)) {
        LocalJavaField f = pMethod.newJavaField(float.class);
        f.addLine(pRs, ".getFloat(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Float(", f, ")"};
      } else if (Column.Type.INTEGER.equals(type)) {
        LocalJavaField i = pMethod.newJavaField(int.class);
        i.addLine(pRs, ".getInt(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Integer(", i, ")"};
      } else if (Column.Type.SMALLINT.equals(type)) {
        LocalJavaField s = pMethod.newJavaField(short.class);
        s.addLine(pRs, ".getShort(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Short(", s, ")"};
      } else if (Column.Type.TINYINT.equals(type)) {
        LocalJavaField b = pMethod.newJavaField(byte.class);
        b.addLine(pRs, ".getByte(", pParamNum, ")");
        return new Object[]{"(", pRs, ".wasNull() ? null : new Byte(", b, ")"};
      } else {
        throw new IllegalStateException("Unknown column type: " + type);
      }
    }
View Full Code Here

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

    Parameter pElement = jm.addParam(Element.class, "pElement");
    jm.addThrows(PMException.class);
    Table table = pData.getTable();

    String q = table.getSchema().getSQLFactory().newSQLGenerator().getQuery(table.getInsertStatement());
    LocalJavaField query = jm.newJavaField(String.class);
    query.setFinal(true);
    query.addLine(JavaSource.getQuoted(q));

    JavaQName qName = pController.getComplexTypeSG().getClassContext().getXMLInterfaceName();
    LocalJavaField elem = jm.newJavaField(qName);
    elem.addLine("(", qName, ") ", pElement);

    LocalJavaField connection = jm.newJavaField(Connection.class);
    connection.addLine("null");
    jm.addTry();
    jm.addLine(connection, " = getConnection();");
    LocalJavaField stmt = jm.newJavaField(PreparedStatement.class);
    stmt.addLine(connection, ".prepareStatement(", query, ")");
    jm.addTry();
    getPreparedStatementParameters(jm, stmt, elem, table.getColumns(), 0);
    jm.addLine(stmt, ".executeUpdate();");
    getFinally(jm, stmt, null, null);
    getFinally(jm, connection, new Object[]{JavaSource.getQuoted("Failed to execute query "),
View Full Code Here

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

    Parameter pElement = jm.addParam(Element.class, "pElement");
    jm.addThrows(PMException.class);
    Table table = pData.getTable();

    String q = table.getSchema().getSQLFactory().newSQLGenerator().getQuery(table.getUpdateStatement());
    LocalJavaField query = jm.newJavaField(String.class);
    query.setFinal(true);
    query.addLine(JavaSource.getQuoted(q));

    JavaQName qName = pController.getComplexTypeSG().getClassContext().getXMLInterfaceName();
    LocalJavaField elem = jm.newJavaField(qName);
    elem.addLine("(", qName, ") ", pElement);

    LocalJavaField connection = jm.newJavaField(Connection.class);
    connection.addLine("null");
    jm.addTry();
    jm.addLine(connection, " = getConnection();");

    LocalJavaField stmt = jm.newJavaField(PreparedStatement.class);
    stmt.addLine(connection, ".prepareStatement(", query, ")");
    jm.addTry();

    List nonKeyColumns = new ArrayList();
    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column col = (Column) iter.next();
View Full Code Here

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

    Parameter pElement = jm.addParam(Element.class, "pElement");
    jm.addThrows(PMException.class);
    Table table = pData.getTable();

    JavaQName qName = pController.getComplexTypeSG().getClassContext().getXMLInterfaceName();
    LocalJavaField elem = jm.newJavaField(qName);
    elem.addLine("(", qName, ") ", pElement);

    String q = table.getSchema().getSQLFactory().newSQLGenerator().getQuery(table.getDeleteStatement());   
    LocalJavaField query = jm.newJavaField(String.class);
    query.setFinal(true);
    query.addLine(JavaSource.getQuoted(q));

    LocalJavaField connection = jm.newJavaField(Connection.class);
    connection.addLine("null");
    jm.addTry();
    jm.addLine(connection, " = getConnection();");

    LocalJavaField stmt = jm.newJavaField(PreparedStatement.class);
    stmt.addLine(connection, ".prepareStatement(", query, ")");
    jm.addTry();
    getPreparedStatementParameters(jm, stmt, elem, table.getPrimaryKey().getColumns(), 0);
    jm.addLine(stmt, ".executeUpdate();");

    getFinally(jm, stmt, null, null);
View Full Code Here

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

    for (Iterator iter = table.getColumns();  iter.hasNext()) {
      Column col = (Column) iter.next();
      if (sb.length() > 0) sb.append(", ");
      sb.append(col.getName().getName());
    }
    LocalJavaField query = jm.newJavaField(String.class);
    jm.addIf(pParams, " != null  &&  pParams.isDistinct()");
    jm.addLine(query, " = ", JavaSource.getQuoted("SELECT DISTINCT"), ";");
    jm.addElse();
    jm.addLine(query, " = ", JavaSource.getQuoted("SELECT"), ";");
    jm.addEndIf();
    jm.addLine(query, " += ", JavaSource.getQuoted(" " + sb + " FROM " + table.getQName()), ";");
    jm.addIf(pQuery, " != null");
    jm.addLine(query, " += ", JavaSource.getQuoted(" WHERE "), " + ", pQuery, ";");
    jm.addEndIf();

    LocalJavaField connection = jm.newJavaField(Connection.class);
    connection.addLine("null");
    jm.addTry();
    jm.addLine(connection, " = getConnection();");
    LocalJavaField stmt = jm.newJavaField(PreparedStatement.class);
    stmt.addLine(connection, ".prepareStatement(", query, ")");
    jm.addTry();
    LocalJavaField rs = jm.newJavaField(ResultSet.class);
    rs.addLine(stmt, ".executeQuery();");
    jm.addTry();
    jm.addWhile(rs, ".next()");
    LocalJavaField elem = jm.newJavaField(qName);
    elem.addLine("(", qName, ") create()");
    getResultSet(jm, rs, elem, table.getColumns(), 0);
    jm.addLine(pObserver, ".notify(", elem, ");");
    jm.addEndWhile();

    getFinally(jm, rs, null, null);
View Full Code Here

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

        typeSG.getSimpleTypeSG().forAllValues(pMethod, pController.getValue(pElement), pSGlet);
      }
      pMethod.addEndIf();
    } else {
      if (typeSG.isComplex()) {
        LocalJavaField f = pMethod.newJavaField(typeSG.getComplexTypeSG().getClassContext().getXMLInterfaceName());
        f.addLine(pController.getValue(pElement));
        pMethod.addIf(f, " != null");
        pSGlet.generate(pMethod, pController.getValue(pElement));
        pMethod.addEndIf();
      } else {
        typeSG.getSimpleTypeSG().forAllNonNullValues(pMethod, pController.getValue(pElement), pSGlet);
View Full Code Here

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

        pMethod.addLine(pController.getXMLSetMethodName(), "(", pValue, ");");
      } else {
        pMethod.addLine(pElement, ".", pController.getXMLSetMethodName(), "(", pValue, ");");
      }
    } else {
      LocalJavaField list = pMethod.newJavaField(List.class);
      list.addLine(pController.getValue(pElement));
      pMethod.addLine(list, ".clear();");
      pMethod.addLine(list, ".addAll(", pValue, ");");
    }
  }
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.