Package org.gdbms.engine.values

Examples of org.gdbms.engine.values.Value


   
    public void testBetweenClause() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where id between 0 and 2;");
        d.start();
        Value v0 = ValueFactory.createValue(1);
        Value v1 = ValueFactory.createValue("huracan");
        Value v2 = ValueFactory.createValue("gonsales");
        assertTrue(d.getRowCount() == 1);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        d.stop();

        d = ds.executeSQL("select * from persona where id not between 0 and 2;");
        d.start();
        v0 = ValueFactory.createValue(0);
        v1 = ValueFactory.createValue("fernando");
        v2 = ValueFactory.createValue("gonzalez");
        Value v3 = ValueFactory.createValue(2);
        Value v4 = ValueFactory.createValue("fernan");
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 0).equals(v3)).getValue());
View Full Code Here


    public void testInClause() throws Exception {
        DataSource d = ds.executeSQL(
                "select * from persona where id in (0, 2);");
       
        d.start();
        Value v0 = ValueFactory.createValue(0);
        Value v1 = ValueFactory.createValue("fernando");
        Value v2 = ValueFactory.createValue("gonzalez");
        Value v3 = ValueFactory.createValue(2);
        Value v4 = ValueFactory.createValue("fernan");
        assertTrue(d.getRowCount() == 2);
        assertTrue(((BooleanValue) d.getFieldValue(0, 0).equals(v0)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 1).equals(v1)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(0, 2).equals(v2)).getValue());
        assertTrue(((BooleanValue) d.getFieldValue(1, 0).equals(v3)).getValue());
View Full Code Here

   */
  public Value evaluate(long row) throws EvaluationException {
    Expression c = (Expression) getChilds()[0];

    try {
      Value value = c.evaluateExpression(row);

      if (not) {
        ((BooleanValue) value).setValue(!((BooleanValue) value).getValue());
      }

View Full Code Here

  public int getInt(long row, String fieldName) throws DriverException {
    return getInt(row, getFieldIndexByName(fieldName));
  }

  public int getInt(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return 0;
    } else {
      return ((NumericValue) v).intValue();
    }
View Full Code Here

  public byte[] getBinary(long row, String fieldName) throws DriverException {
    return getBinary(row, getFieldIndexByName(fieldName));
  }

  public byte[] getBinary(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return null;
    } else {
      return ((BinaryValue) v).getValue();
    }
View Full Code Here

  public boolean getBoolean(long row, String fieldName) throws DriverException {
    return getBoolean(row, getFieldIndexByName(fieldName));
  }

  public boolean getBoolean(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return false;
    } else {
      return ((BooleanValue) v).getValue();
    }
View Full Code Here

  public byte getByte(long row, String fieldName) throws DriverException {
    return getByte(row, getFieldIndexByName(fieldName));
  }

  public byte getByte(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return 0;
    } else {
      return ((ByteValue) v).getValue();
    }
View Full Code Here

   *
   * @throws SemanticException Si se produce un error sem�ntico
   * @throws DriverException Si se produce un error de I/O
   */
  public Value evaluate(long row) throws EvaluationException {
    Value ret = null;

    Adapter[] expr = (Adapter[]) getChilds();

    if (expr.length > 0) {
      ret = ((Expression) expr[0]).evaluateExpression(row);

      if (expr.length == 2) {
        try {
            if (getOperator(this.getEntity()) == PRODUCTO) {
                        ret = ret.producto(((Expression) expr[1]).evaluateExpression(
                              row));
          } else if (getOperator(this.getEntity()) == DIVISION) {
            ret = ret.producto(((Expression) expr[1]).evaluateExpression(
                  row).inversa());
          }
                } catch (IncompatibleTypesException e) {
                    throw new EvaluationException(e);
                }
View Full Code Here

  public Date getDate(long row, String fieldName) throws DriverException {
    return getDate(row, getFieldIndexByName(fieldName));
  }

  public Date getDate(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return null;
    } else {
      return ((DateValue) v).getValue();
    }
View Full Code Here

  public double getDouble(long row, String fieldName) throws DriverException {
    return getDouble(row, getFieldIndexByName(fieldName));
  }

  public double getDouble(long row, int fieldId) throws DriverException {
    Value v = getFieldValue(row, fieldId);
    if (v instanceof NullValue) {
      return 0;
    } else {
      return ((DoubleValue) v).getValue();
    }
View Full Code Here

TOP

Related Classes of org.gdbms.engine.values.Value

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.