Package org.teiid.language

Examples of org.teiid.language.Literal


        return new Literal(c.getValue(), c.getType());
    }

    public static Literal example(Object val) {
        Constant c = helpExample(val);
        return new Literal(c.getValue(), c.getType());
    }
View Full Code Here


    }
   
    public void testGetColumnDataTypes(){
        Class<?>[] expectedResults = new Class[2];
        List<DerivedColumn> symbols = new ArrayList<DerivedColumn>();
        symbols.add(new DerivedColumn("c1", new Literal("3", DataTypeManager.DefaultDataClasses.STRING)))//$NON-NLS-1$//$NON-NLS-2$
        expectedResults[0] = DataTypeManager.DefaultDataClasses.STRING;
        symbols.add(new DerivedColumn("c2", new Literal(new Integer(5), DataTypeManager.DefaultDataClasses.INTEGER)))//$NON-NLS-1$
        expectedResults[1] = DataTypeManager.DefaultDataClasses.INTEGER;
        Select query = new Select(symbols, false, null, null, null, null, null);
        Class<?>[] results = query.getColumnTypes()
        assertEquals( results[0], expectedResults[0]);
        assertEquals( results[1], expectedResults[1]);    
View Full Code Here

        ColumnReference element = columns.get(i);
        Column column = element.getMetadataObject();
        Object value = values.get(i);
        String val;
        if(value instanceof Literal) {
          Literal literalValue = (Literal)value;
          val = literalValue.getValue().toString();
          if(null != val && !val.isEmpty()) {
            val = this.stripQutes(val);
          }
        } else {
          val = value.toString();
View Full Code Here

            queryString.append(columnName).append(SPACE);
            queryString.append(comparisonOperators.get(compCriteria.getOperator()));
            queryString.append(' ');
            Expression rExp = compCriteria.getRightExpression();
            if(rExp instanceof Literal) {
              Literal literal = (Literal)rExp;
              if (column.getJavaType().equals(Boolean.class)) {
                queryString.append(((Boolean)literal.getValue()).toString());
              } else if (column.getJavaType().equals(java.sql.Timestamp.class)) {
                Timestamp datetime = (java.sql.Timestamp)literal.getValue();
                String value = Util.getSalesforceDateTimeFormat().format(datetime);
                String zoneValue = Util.getTimeZoneOffsetFormat().format(datetime);
                queryString.append(value).append(zoneValue.subSequence(0, 3)).append(':').append(zoneValue.subSequence(3, 5));
              } else if (column.getJavaType().equals(java.sql.Time.class)) {
                String value = Util.getSalesforceDateTimeFormat().format((java.sql.Time)literal.getValue());
                queryString.append(value);
              } else if (column.getJavaType().equals(java.sql.Date.class)) {
                String value = Util.getSalesforceDateFormat().format((java.sql.Date)literal.getValue());
                queryString.append(value);
              } else {
                queryString.append(compCriteria.getRightExpression().toString());
              }
            } else if(rExp instanceof ColumnReference) {
              ColumnReference right = (ColumnReference)lExpr;
                column = left.getMetadataObject();
                columnName = column.getNameInSource();
                queryString.append(columnName);
            }

            criteriaList.add(queryString.toString());

            if (columnName.equals("IsDeleted")) { //$NON-NLS-1$
                Literal isDeletedLiteral = (Literal)compCriteria.getRightExpression();
                Boolean isDeleted = (Boolean)isDeletedLiteral.getValue();
                if (isDeleted) {
                    this.queryAll = isDeleted;
                }
            }
        }
View Full Code Here

        if (expr instanceof ColumnReference) {
            ColumnReference element = (ColumnReference)expr;
            Column element2 = element.getMetadataObject();
            result = element2.getNameInSource();
        } else if (expr instanceof Literal) {
            Literal literal = (Literal)expr;
            result = literal.getValue().toString();
        } else {
            throw new RuntimeException("unknown type in SalesforceQueryExecution.getValue(): " + expr.toString()); //$NON-NLS-1$
        }
        return result;
    }
View Full Code Here

    public List<?> translate(Function function) {
        Expression a = function.getParameters().get(0);
        Expression b = function.getParameters().get(1);
        List<Condition> crits = new ArrayList<Condition>();
       
        Literal nullValue = langFactory.createLiteral(null, TypeFacility.RUNTIME_TYPES.STRING);
        if (isNull(a)) {
          return Arrays.asList(nullValue);
        } else if (!isNotNull(a)) {
          crits.add(langFactory.createIsNullCriteria(a, false));
        }
View Full Code Here

        return Arrays.asList(langFactory.createSearchedCaseExpression(cases, function, TypeFacility.RUNTIME_TYPES.STRING));
    }
   
    public static boolean isNotNull(Expression expr) {
      if (expr instanceof Literal) {
        Literal literal = (Literal)expr;
        return literal.getValue() != null;
      }
      if (expr instanceof Function) {
        Function function = (Function)expr;
        if (function.getName().equalsIgnoreCase("NVL") || function.getName().equalsIgnoreCase(SourceSystemFunctions.IFNULL)) { //$NON-NLS-1$
          return isNotNull(function.getParameters().get(1));
View Full Code Here

      return false;
    }
   
    private boolean isNull(Expression expr) {
      if (expr instanceof Literal) {
        Literal literal = (Literal)expr;
        return literal.getValue() == null;
      }
      return false;
    }
View Full Code Here

        }
        throw new AssertionError();
    }

    Literal translate(Constant constant) {
        Literal result = new Literal(constant.getValue(), constant.getType());
        result.setBindValue(constant.isMultiValued());
        result.setMultiValued(constant.isMultiValued());
        result.setBindEligible(constant.isBindEligible());
        return result;
    }
View Full Code Here

                  continue;
            }
           
            ProcedureParameter metadataParam = metadataFactory.getParameter(param);
            //we can assume for now that all arguments will be literals, which may be multivalued
            Literal value = null;
            if (direction != Direction.OUT) {
              value = (Literal)translate(param.getExpression());
            }
            Argument arg = new Argument(direction, value, param.getClassType(), metadataParam);
            translatedParameters.add(arg);
View Full Code Here

TOP

Related Classes of org.teiid.language.Literal

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.