diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java index 56758a84e..1ea4f33bf 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java @@ -708,23 +708,13 @@ private void setItemValue(String itemName, Object itemValue, boolean append) { @SuppressWarnings("rawtypes") private boolean validateItemValue(Object itemValue) { - if (itemValue==null) { - return true; - } - // convert Calendar instance into Date! issue #52 if (itemValue instanceof Calendar) { - itemValue=((Calendar)itemValue).getTime(); + itemValue = ((Calendar) itemValue).getTime(); } - // array? - if (itemValue != null && itemValue.getClass().isArray()) { - for (int i = 0; i < Array.getLength(itemValue); i++) { - Object singleValue = Array.get(itemValue, i); - if (!validateItemValue(singleValue)) { - return false; - } - } + // first we test if basic type? + if (isBasicType(itemValue)) { return true; } @@ -738,7 +728,18 @@ private boolean validateItemValue(Object itemValue) { return true; } else - // map + // array? + if (itemValue != null && itemValue.getClass().isArray()) { + for (int i = 0; i < Array.getLength(itemValue); i++) { + Object singleValue = Array.get(itemValue, i); + if (!validateItemValue(singleValue)) { + return false; + } + } + return true; + } else + + // map? if ((itemValue instanceof Map)) { Map map = (Map) itemValue; for (Object value : map.values()) { @@ -747,9 +748,10 @@ private boolean validateItemValue(Object itemValue) { } } return true; - } else { - return (isBasicType(itemValue)); } + + // unknown type + return false; } /** @@ -776,13 +778,14 @@ private static boolean isBasicType(java.lang.Object o) { // test package name Class c = o.getClass(); String name = c.getName(); - if (!name.startsWith("java.lang.") && !name.startsWith("java.math.") && !"java.util.Date".equals(name) - && !"org.imixs.workflow.xml.XMLItem".equals(name) - && !"org.imixs.workflow.xml.XMLItemCollection".equals(name)) { - return false; + if (name.startsWith("java.lang.") || name.startsWith("java.math.") || "java.util.Date".equals(name) + || "org.imixs.workflow.xml.XMLItem".equals(name) + || "org.imixs.workflow.xml.XMLItemCollection".equals(name)) { + return true; } - return true; + // no basic type + return false; } /** diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java index 1190d1f87..e98e78943 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java @@ -679,4 +679,21 @@ public void testItemCollectionNoBasictype() { } + /** + * Test raw type int, double, boolean + */ + @Test + @Category(org.imixs.workflow.ItemCollection.class) + public void testItemCollectionRawtype() { + ItemCollection itemCollection = new ItemCollection(); + itemCollection.replaceItemValue("txtTitel", "Hello"); + double d=5.20; + itemCollection.replaceItemValue("price", d); + + byte[] bytes="Some Data".getBytes(); + itemCollection.replaceItemValue("data", bytes); + + Assert.assertNotNull(itemCollection); + + } }