Package org.apache.ws.jaxme.js

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


    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

      } 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

      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

    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

    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

    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

    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

  private JavaMethod getXMLSerializersMarshalChildsMethod(GroupSG pController, JavaSource pSource) throws SAXException {
    final String mName = "getXMLSerializersMarshalChildsMethod";
    log.finest(mName, "->", pSource.getQName());
    ParticleSG[] myParticles = pController.getParticles();
    JavaMethod jm = null;
    LocalJavaField pElement = null;
    XMLSerializersMarshalChildsSGlet sgLet = null;
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG particle = myParticles[i];
      if (jm == null) {
        jm = pSource.newJavaMethod("marshalChilds", JavaQNameImpl.VOID, JavaSource.PROTECTED);
        DirectAccessible pData = jm.addParam(JavaQNameImpl.getInstance(JMXmlSerializer.Data.class), "pData");
        sgLet = new XMLSerializersMarshalChildsSGlet(pData);
        JavaQName elementInterface = pController.getClassContext().getXMLInterfaceName();
        DirectAccessible pObject = jm.addParam(Object.class, "pObject");
        pElement = jm.newJavaField(elementInterface);
        pElement.addLine("(", elementInterface, ") ", pObject);
        jm.addThrows(SAXException.class);
      }

      if (!particle.isElement()) {
        // TODO: Implement handling for wildcards and subgroups
View Full Code Here

    jm.addSwitch("--", pLevelVar);
    jm.addCase("0");
    jm.addBreak();
    jm.addCase("1");
    JavaQName elementInterface = pController.getClassContext().getXMLInterfaceName();
    LocalJavaField element = jm.newJavaField(elementInterface);
    element.addLine("(", elementInterface, ") getResult()");
    jm.addSwitch(pStateVar);
    for (int i = 0;  i < myParticles.length;  i++) {
      ParticleSG child = myParticles[i];
      // TODO: process group case properly.
      if (myParticles[i].isGroup()) continue;
View Full Code Here

TOP

Related Classes of org.apache.ws.jaxme.js.LocalJavaField

Copyright © 2018 www.massapicom. 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.