Package org.teiid.language

Examples of org.teiid.language.Expression


    Comparison compareCriteria = (Comparison)criteria; 
    if (compareCriteria.getOperator() != Operator.EQ) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaNotEqualsError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression leftExpr = compareCriteria.getLeftExpression();
    if (!(leftExpr instanceof ColumnReference)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaLHSNotElementError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    // call utility method to get NameInSource/Name for element
    String nameLeftExpr = getNameFromElement((ColumnReference)leftExpr);
    if (!(nameLeftExpr.toUpperCase().equals("DN"))) {   //$NON-NLS-1$
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaSrcColumnError",nameLeftExpr); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Expression rightExpr = compareCriteria.getRightExpression();
    if (!(rightExpr instanceof Literal)) {
            final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.criteriaRHSNotLiteralError"); //$NON-NLS-1$
      throw new TranslatorException(msg);
    }
    Object valueRightExpr = ((Literal)rightExpr).getValue();
View Full Code Here


        this.langFactory = langFactory;
    }
   
    @Override
    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);
View Full Code Here

    public LocateFunctionModifier(LanguageFactory languageFactory) {
        this.languageFactory = languageFactory;
   
  @Override
  public List<?> translate(Function function) {
        Expression a = function.getParameters().get(0);
        Expression b = function.getParameters().get(1);
       
        return Arrays.asList(languageFactory.createFunction("locate", new Expression[] {b, a}, TypeFacility.RUNTIME_TYPES.INTEGER)); //$NON-NLS-1$
  }
View Full Code Here

    @Test public void testDoubleToString() throws Exception {
        helpTest(LANG_FACTORY.createLiteral(new Double(1.0), Double.class), "string", "1.0");
    }   
   
  @Test public void testInDecompose() throws Exception {
      Expression left = LANG_FACTORY.createLiteral("1", String.class);
      List<Expression> right = new ArrayList<Expression>();
      right.add(LANG_FACTORY.createLiteral("2", String.class));
      right.add(LANG_FACTORY.createLiteral("3", String.class));
       
        In expr = LANG_FACTORY.createIn(left,right, false);
View Full Code Here

       
        assertEquals("'1' IN ('2', '3')", helpGetString(expr));
    }   
 
  @Test public void testSingleInDecompose() throws Exception {
      Expression left = LANG_FACTORY.createLiteral("1", String.class);
      List<Expression> right = new ArrayList<Expression>();
      right.add(LANG_FACTORY.createLiteral("2", String.class));
       
        In expr = LANG_FACTORY.createIn(left,right, false);
       
View Full Code Here

       
        assertEquals("'1' IN ('2')", helpGetString(expr));
   
 
  @Test public void testInDecomposeNonLiterals() throws Exception {
      Expression left = LANG_FACTORY.createLiteral("1", String.class);
      List<Expression> right = new ArrayList<Expression>();
      right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
      right.add(LANG_FACTORY.createLiteral("3", String.class));
       
        In expr = LANG_FACTORY.createIn(left,right, false);
View Full Code Here

       
        assertEquals("'1' = func() OR '1' = '3'", helpGetString(expr));
    }
 
  @Test public void testNegatedInDecomposeNonLiterals() throws Exception {
      Expression left = LANG_FACTORY.createLiteral("1", String.class);
      List<Expression> right = new ArrayList<Expression>();
      right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
      right.add(LANG_FACTORY.createLiteral("3", String.class));
       
        In expr = LANG_FACTORY.createIn(left,right, true);
View Full Code Here

       
        assertEquals("'1' <> func() AND '1' <> '3'", helpGetString(expr));
    }
 
  @Test public void testsingleInDecomposeNonLiterals() throws Exception {
      Expression left = LANG_FACTORY.createLiteral("1", String.class);
      List<Expression> right = new ArrayList<Expression>();
      right.add(LANG_FACTORY.createFunction("func", new Expression[] {}, Date.class));
       
        In expr = LANG_FACTORY.createIn(left,right, false);
       
View Full Code Here

      convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", TIME_FORMAT)); //$NON-NLS-1$
      convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
      @Override
      public List<?> translate(Function function) {
        //if column and type is date, just use date format
        Expression ex = function.getParameters().get(0);
        String format = TIMESTAMP_FORMAT;
        if (ex instanceof ColumnReference && "date".equalsIgnoreCase(((ColumnReference)ex).getMetadataObject().getNativeType())) { //$NON-NLS-1$
          format = DATETIME_FORMAT;
        } else if (!(ex instanceof Literal) && !(ex instanceof Function)) {
          //this isn't needed in every case, but it's simpler than inspecting the expression more
View Full Code Here

      super(alias);
    }

    @Override
    public List<?> translate(Function function) {
      Expression arg = function.getParameters().get(0);
      if (arg instanceof Literal && ((Literal)arg).getValue() == null) {
        ((Literal)function.getParameters().get(1)).setValue(this.alias);
        return null;
      }
      return super.translate(function);
View Full Code Here

TOP

Related Classes of org.teiid.language.Expression

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.