Package org.teiid.api.exception.query

Examples of org.teiid.api.exception.query.FunctionExecutionException


                return new Double(context.getNextRand());
            } else if(seed instanceof Integer) {
                return new Double(context.getNextRand(((Integer)seed).longValue()));
            }
        }
        throw new FunctionExecutionException("ERR.015.001.0069", QueryPlugin.Util.getString("ERR.015.001.0069", "rand", seed)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$       
    }
View Full Code Here


       
    public static Object rand(CommandContext context) throws FunctionExecutionException {
        if(context != null) {
            return new Double(context.getNextRand());
        }
        throw new FunctionExecutionException("ERR.015.001.0069", QueryPlugin.Util.getString("ERR.015.001.0069", "rand")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
View Full Code Here

  public static Object quarter(Date date)
    throws FunctionExecutionException {
    int month = getField(date, Calendar.MONTH);
   
    if (month > 11) {
      throw new FunctionExecutionException("ERR.015.001.0066", QueryPlugin.Util.getString("ERR.015.001.0066", //$NON-NLS-1$ //$NON-NLS-2$
          new Object[] {"quarter", date.getClass().getName()})); //$NON-NLS-1$
    }
    return Integer.valueOf(month/3 + 1);
  }
View Full Code Here

  public static Object left(String string, Integer count)
    throws FunctionExecutionException {
    int countValue = count.intValue();
        if(countValue < 0) {
            throw new FunctionExecutionException("ERR.015.001.0017", QueryPlugin.Util.getString("ERR.015.001.0017", countValue)); //$NON-NLS-1$ //$NON-NLS-2$
        }
        if(string.length() < countValue) {
            return string;
        }
        return new String(string.substring(0, countValue));
View Full Code Here

  public static Object right(String string, Integer count)
    throws FunctionExecutionException {
    int countValue = count.intValue();
        if(countValue < 0) {
            throw new FunctionExecutionException("ERR.015.001.0017", QueryPlugin.Util.getString("ERR.015.001.0017", countValue)); //$NON-NLS-1$ //$NON-NLS-2$
        } else if(string.length() < countValue) {
            return string;
    } else {
      return new String(string.substring(string.length() - countValue));
        }
View Full Code Here

    int startValue = start.intValue();
    int len = length.intValue();

    // Check some invalid cases
    if(startValue < 1 || (startValue-1) > string1.length()) {
      throw new FunctionExecutionException("ERR.015.001.0061", QueryPlugin.Util.getString("ERR.015.001.0061", start, string1)); //$NON-NLS-1$ //$NON-NLS-2$
    } else if (len < 0) {
      throw new FunctionExecutionException("ERR.015.001.0062", QueryPlugin.Util.getString("ERR.015.001.0062", len)); //$NON-NLS-1$ //$NON-NLS-2$
    } else if (string1.length() == 0 && (startValue > 1 || len >0) ) {
      throw new FunctionExecutionException("ERR.015.001.0063", QueryPlugin.Util.getString("ERR.015.001.0063")); //$NON-NLS-1$ //$NON-NLS-2$
    }

    StringBuffer result = new StringBuffer();
    result.append(string1.substring(0, startValue-1));
    int endValue = startValue + len - 1;
View Full Code Here

    public static Object pad(String str, Integer padLength, String padStr, boolean left)
    throws FunctionExecutionException {
      int length = padLength.intValue();
      if(length < 1) {
          throw new FunctionExecutionException("ERR.015.001.0025", QueryPlugin.Util.getString("ERR.015.001.0025")); //$NON-NLS-1$ //$NON-NLS-2$
      }
      if(length < str.length()) {
          return new String(str.substring(0, length));
      }
      if(length > DataTypeManager.MAX_STRING_LENGTH) {
        length = DataTypeManager.MAX_STRING_LENGTH;
      }
      // Get pad character
      if(padStr.length() == 0) {
          throw new FunctionExecutionException("ERR.015.001.0027", QueryPlugin.Util.getString("ERR.015.001.0027")); //$NON-NLS-1$ //$NON-NLS-2$
      }
      // Pad string
      StringBuffer outStr = new StringBuffer(str);
      while(outStr.length() < length) {
        if (left) {
View Full Code Here

    // ================== Function = translate =====================

    public static Object translate(String str, String in, String out)
        throws FunctionExecutionException {
        if(in.length() != out.length()) {
            throw new FunctionExecutionException("ERR.015.001.0031", QueryPlugin.Util.getString("ERR.015.001.0031")); //$NON-NLS-1$ //$NON-NLS-2$
        }

        if(in.length() == 0 || str.length() == 0) {
            return str;
        }
View Full Code Here

  public static Object convert(Object src, String type)
    throws FunctionExecutionException {
    try {
      return DataTypeManager.transformValue(src, DataTypeManager.getDataTypeClass(type));
    } catch(TransformationException e) {
      throw new FunctionExecutionException(e, "ERR.015.001.0033", QueryPlugin.Util.getString("ERR.015.001.0033", new Object[]{src, DataTypeManager.getDataTypeName(src.getClass()), type})); //$NON-NLS-1$ //$NON-NLS-2$
    }
  }
View Full Code Here

     * @return Same as expression
     */
    public static Object context(Object context, Object expression)
        throws FunctionExecutionException {

        throw new FunctionExecutionException("ERR.015.001.0035", QueryPlugin.Util.getString("ERR.015.001.0035")); //$NON-NLS-1$ //$NON-NLS-2$
    }
View Full Code Here

TOP

Related Classes of org.teiid.api.exception.query.FunctionExecutionException

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.