@Test public void issue200() { JexlExpressionEvaluator anyEvaluator = new JexlExpressionEvaluator(); Context emptyContext = new Context(); Iterable<Object> ret = Util.transformToIterableObject(anyEvaluator, "notExisting", emptyContext); assertFalse("Collection must be empty", ret.iterator().hasNext()); }
public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context) { Object collectionObject = expressionEvaluator.evaluate(collectionName, context.toMap()); if (collectionObject == null) { return Collections.emptyList(); } else if (collectionObject instanceof Object[]) { collectionObject = Arrays.asList((Object[]) collectionObject); } else if (!(collectionObject instanceof Iterable)) { throw new JxlsException(collectionName + " expression is not a collection or an array"); } List<Object> ret = new ArrayList<>(); for (Object i : (Iterable<?>) collectionObject) { ret.add(i); } return ret; }
Util { public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context) { Object collectionObject = expressionEvaluator.evaluate(collectionName, context.toMap()); if (collectionObject == null) { return Collections.emptyList(); } else if (collectionObject instanceof Object[]) { collectionObject = Arrays.asList((Object[]) collectionObject); } else if (!(collectionObject instanceof Iterable)) { throw new JxlsException(collectionName + " expression is not a collection or an array"); } List<Object> ret = new ArrayList<>(); for (Object i : (Iterable<?>) collectionObject) { ret.add(i); } return ret; } }
Util { public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context) { Object collectionObject = expressionEvaluator.evaluate(collectionName, context.toMap()); if (collectionObject == null) { return Collections.emptyList(); } else if (collectionObject instanceof Object[]) { collectionObject = Arrays.asList((Object[]) collectionObject); } else if (!(collectionObject instanceof Iterable)) { throw new JxlsException(collectionName + " expression is not a collection or an array"); } List<Object> ret = new ArrayList<>(); for (Object i : (Iterable<?>) collectionObject) { ret.add(i); } return ret; }  }
Util { public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context) { Object collectionObject = expressionEvaluator.evaluate(collectionName, context.toMap()); if (collectionObject == null) { return Collections.emptyList(); } else if (collectionObject instanceof Object[]) { collectionObject = Arrays.asList((Object[]) collectionObject); } else if (!(collectionObject instanceof Iterable)) { throw new JxlsException(collectionName + " expression is not a collection or an array"); } List<Object> ret = new ArrayList<>(); for (Object i : (Iterable<?>) collectionObject) { ret.add(i); } return ret; }  static List<String> getFormulaCellRefs(String formula); static List<String> getJointedCellRefs(String formula); static List<String> getCellRefsFromJointedCellRef(String jointedCellRef); static boolean formulaContainsJointedCellRef(String formula); static String createTargetCellRef(List<CellRef> targetCellDataList); static String joinStrings(List<String> strings, String separator); static List<List<CellRef>> groupByRanges(List<CellRef> cellRefList, int targetRangeCount); static List<List<CellRef>> groupByColRange(List<CellRef> cellRefList); static List<List<CellRef>> groupByRowRange(List<CellRef> cellRefList); static Boolean isConditionTrue(ExpressionEvaluator evaluator, String condition, Context context); static Boolean isConditionTrue(ExpressionEvaluator evaluator, Context context); static void setObjectProperty(Object obj, String propertyName, String propertyValue, boolean ignoreNonExisting); static void setObjectProperty(Object obj, String propertyName, String propertyValue); static Object getObjectProperty(Object obj, String propertyName, boolean failSilently); static Object getObjectProperty(Object obj, String propertyName); static Collection<GroupData> groupCollection(Collection<?> collection, String groupProperty, String groupOrder); static Collection<GroupData> groupIterable(Iterable<?> iterable, String groupProperty, String groupOrder); static byte[] toByteArray(InputStream stream); static Collection<?> transformToCollectionObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context); static String sheetNameRegex(Map.Entry<CellRef, List<CellRef>> cellRefEntry); static List<CellRef> createTargetCellRefListByColumn(CellRef targetFormulaCellRef, List<CellRef> targetCells,
            List<CellRef> cellRefsToExclude); static int countOccurences(String str, char ch); static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context); static String getStrictCellNameRegex(String name); }
Util { public static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context) { Object collectionObject = expressionEvaluator.evaluate(collectionName, context.toMap()); if (collectionObject == null) { return Collections.emptyList(); } else if (collectionObject instanceof Object[]) { collectionObject = Arrays.asList((Object[]) collectionObject); } else if (!(collectionObject instanceof Iterable)) { throw new JxlsException(collectionName + " expression is not a collection or an array"); } List<Object> ret = new ArrayList<>(); for (Object i : (Iterable<?>) collectionObject) { ret.add(i); } return ret; }  static List<String> getFormulaCellRefs(String formula); static List<String> getJointedCellRefs(String formula); static List<String> getCellRefsFromJointedCellRef(String jointedCellRef); static boolean formulaContainsJointedCellRef(String formula); static String createTargetCellRef(List<CellRef> targetCellDataList); static String joinStrings(List<String> strings, String separator); static List<List<CellRef>> groupByRanges(List<CellRef> cellRefList, int targetRangeCount); static List<List<CellRef>> groupByColRange(List<CellRef> cellRefList); static List<List<CellRef>> groupByRowRange(List<CellRef> cellRefList); static Boolean isConditionTrue(ExpressionEvaluator evaluator, String condition, Context context); static Boolean isConditionTrue(ExpressionEvaluator evaluator, Context context); static void setObjectProperty(Object obj, String propertyName, String propertyValue, boolean ignoreNonExisting); static void setObjectProperty(Object obj, String propertyName, String propertyValue); static Object getObjectProperty(Object obj, String propertyName, boolean failSilently); static Object getObjectProperty(Object obj, String propertyName); static Collection<GroupData> groupCollection(Collection<?> collection, String groupProperty, String groupOrder); static Collection<GroupData> groupIterable(Iterable<?> iterable, String groupProperty, String groupOrder); static byte[] toByteArray(InputStream stream); static Collection<?> transformToCollectionObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context); static String sheetNameRegex(Map.Entry<CellRef, List<CellRef>> cellRefEntry); static List<CellRef> createTargetCellRefListByColumn(CellRef targetFormulaCellRef, List<CellRef> targetCells,
            List<CellRef> cellRefsToExclude); static int countOccurences(String str, char ch); static Iterable<Object> transformToIterableObject(ExpressionEvaluator expressionEvaluator, String collectionName, Context context); static String getStrictCellNameRegex(String name); static final String regexJointedLookBehind; static final String regexSimpleCellRef; static final String regexCellRef; static final String regexAreaRef; static final Pattern regexAreaRefPattern; static final String regexCellRefExcludingJointed; static final String regexJointedCellRef; static final String regexExcludePrefixSymbols; }