/** * This function should never actually be called - it is here solely so the * xml context function can be resolved properly. The actual function is * implemented in the XML planner. * @param context The context to apply the criteria in * @param expression The expression on the left side of the criteria * @return Same as expression */ public static Object context(Object context, Object expression) throws FunctionExecutionException { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30406, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30406)); }
public static long abs(long x) throws FunctionExecutionException { if (x == Long.MIN_VALUE) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31169, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31169, BigInteger.valueOf(Long.MAX_VALUE).add(BigInteger.valueOf(1)))); } return Math.abs(x); }
public static long multiply(long x, long y) throws FunctionExecutionException { if ((y > 0 && (x > Long.MAX_VALUE/y || x < Long.MIN_VALUE/y)) || ((y < -1) && (x > Long.MIN_VALUE/y || x < Long.MAX_VALUE/y)) || (y == -1 && x == Long.MIN_VALUE)) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31169, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31169, BigInteger.valueOf(x).multiply(BigInteger.valueOf(y)))); } return x * y; }
public static int divide(int x, int y) throws FunctionExecutionException { if (x == Integer.MIN_VALUE && y == -1) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31169, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31169, (long)Integer.MAX_VALUE + 1)); } return x / y; }
public static Object right(String string, Integer count) throws FunctionExecutionException { int countValue = count.intValue(); if(countValue < 0) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30396, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30396, countValue)); } else if(string.length() < countValue) { return string; } else { return new String(string.substring(string.length() - countValue)); } }
public static Object left(String string, Integer count) throws FunctionExecutionException { int countValue = count.intValue(); if(countValue < 0) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30396, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30396, countValue)); } if(string.length() < countValue) { return string; } return new String(string.substring(0, countValue)); }
public static int array_length(Object array) throws FunctionExecutionException, SQLException { if (array instanceof java.sql.Array) { return Array.getLength(((java.sql.Array)array).getArray()); } if (array.getClass().isArray()) { return Array.getLength(array); } throw new FunctionExecutionException(QueryPlugin.Event.TEIID30416, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30416, array.getClass())); }
public static String format(CommandContext context, Number number, String format) throws FunctionExecutionException { try { DecimalFormat df = CommandContext.getDecimalFormat(context, format); return df.format(number); } catch (IllegalArgumentException iae) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30411, iae, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30411, iae.getMessage())); } }
public static String format(CommandContext context, Number number, String format) throws FunctionExecutionException { try { DecimalFormat df = CommandContext.getDecimalFormat(context, format); return df.format(number); } catch (IllegalArgumentException iae) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30411, iae, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30411, iae.getMessage())); } }
public static String format(CommandContext context, Date date, String format) throws FunctionExecutionException { try { SimpleDateFormat sdf = CommandContext.getDateFormat(context, format); return sdf.format(date); } catch (IllegalArgumentException iae) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30409, iae, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30409,iae.getMessage())); } }
private static Date parseDateHelper(CommandContext context, String date, String format) throws FunctionExecutionException { DateFormat df = CommandContext.getDateFormat(context, format); try { return df.parse(date); } catch (ParseException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30410, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30410, date, format)); } }
public static BigDecimal parseBigDecimal(CommandContext context, String number, String format) throws FunctionExecutionException { DecimalFormat df= CommandContext.getDecimalFormat(context, format); try { return (BigDecimal) df.parse(number); } catch (ParseException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30412, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30412,number,format)); } }
public static BigDecimal parseBigDecimal(CommandContext context, String number, String format) throws FunctionExecutionException { DecimalFormat df= CommandContext.getDecimalFormat(context, format); try { return (BigDecimal) df.parse(number); } catch (ParseException e) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30412, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30412,number,format)); } }
public static GeometryType geometryFromGml(ClobType gml, Integer srid) throws FunctionExecutionException { try { return geometryFromGml(gml.getCharacterStream(), srid); } catch (SQLException e) { throw new FunctionExecutionException(e); } }
private void checkMethod() throws FunctionExecutionException { // If descriptor is missing invokable method, find this VM's descriptor // give name and types from fd if(invocationMethod == null) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID30382, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30382, getFullName())); } }
@TeiidFunction(category=FunctionCategoryConstants.SYSTEM, determinism=Determinism.COMMAND_DETERMINISTIC, pushdown=PushDown.CANNOT_PUSHDOWN) public static Object teiid_session_set(CommandContext context, String key, Object value) throws FunctionExecutionException { SessionMetadata session = context.getSession(); Map<String, Object> variables = session.getSessionVariables(); if (variables.size() > MAX_VARIABLES && !variables.containsKey(key)) { throw new FunctionExecutionException(QueryPlugin.Event.TEIID31136, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31136, MAX_VARIABLES)); } return context.setSessionVariable(key, value); }
public static GeometryType geometryFromGml(ClobType gml, Integer srid) throws FunctionExecutionException { try { Geometry geom = geometryFromGml(gml.getCharacterStream(), srid); return getGeometryType(geom); } catch (SQLException e) { throw new FunctionExecutionException(e); } }
public static Geometry getGeometry(GeometryType geom) throws FunctionExecutionException { try { return getGeometry(geom.getBinaryStream(), geom.getSrid(), false); } catch (SQLException e) { throw new FunctionExecutionException(e); } }
private Object evaluateXMLForest(List<?> tuple, XMLForest function) throws ExpressionEvaluationException, BlockedException, TeiidComponentException, FunctionExecutionException { List<DerivedColumn> args = function.getArgs(); Evaluator.NameValuePair<Object>[] nameValuePairs = getNameValuePairs(tuple, args, true, true); try { return XMLSystemFunctions.xmlForest(context, namespaces(function.getNamespaces()), nameValuePairs); } catch (TeiidProcessingException e) { throw new FunctionExecutionException(e); } }
@TeiidFunction(category=FunctionCategoryConstants.SECURITY, nullOnNull=true) public static BinaryType aes_encrypt(BinaryType dataBytes, BinaryType keyBytes) throws FunctionExecutionException { try { byte[] encryptResult = SymmetricCryptor.getSymmectricCryptor(padkey(keyBytes.getBytesDirect()), "AES", "AES/CBC/PKCS5Padding", new IvParameterSpec(iv)).encrypt(dataBytes.getBytesDirect()); //$NON-NLS-1$ //$NON-NLS-2$ return new BinaryType(encryptResult); } catch (CryptoException e) { throw new FunctionExecutionException(e); } }