Esempio n. 1
0
 private void output(String name, Object attr) {
   if (attr instanceof CompositeDataSupport) {
     CompositeDataSupport cds = (CompositeDataSupport) attr;
     for (Iterator it = cds.getCompositeType().keySet().iterator(); it.hasNext(); ) {
       String key = it.next().toString();
       System.out.println(name + "." + key + ".value " + format(cds.get(key)));
     }
   } else System.out.println(name + ".value " + format(attr));
 }
Esempio n. 2
0
 /**
  * create result as property with name from property prefix When result is an array and
  * isSeparateArrayResults is true, resultproperty used as prefix (<code>
  * resultproperty.0-array.length</code> and store the result array length at <code>
  * resultproperty.length</code>. Other option is that you delimit your result with a delimiter
  * (java.util.StringTokenizer is used).
  *
  * @param propertyPrefix
  * @param result
  */
 protected void createProperty(String propertyPrefix, Object result) {
   if (propertyPrefix == null) propertyPrefix = "";
   if (result instanceof CompositeDataSupport) {
     CompositeDataSupport data = (CompositeDataSupport) result;
     CompositeType compositeType = data.getCompositeType();
     Set<String> keys = compositeType.keySet();
     for (Iterator<String> iter = keys.iterator(); iter.hasNext(); ) {
       String key = iter.next();
       Object value = data.get(key);
       OpenType<?> type = compositeType.getType(key);
       if (type instanceof SimpleType<?>) {
         setProperty(propertyPrefix + "." + key, value);
       } else {
         createProperty(propertyPrefix + "." + key, value);
       }
     }
   } else if (result instanceof TabularDataSupport) {
     TabularDataSupport data = (TabularDataSupport) result;
     for (Iterator<Object> iter = data.keySet().iterator(); iter.hasNext(); ) {
       Object key = iter.next();
       for (Iterator<?> iter1 = ((List<?>) key).iterator(); iter1.hasNext(); ) {
         Object key1 = iter1.next();
         CompositeData valuedata = data.get(new Object[] {key1});
         Object value = valuedata.get("value");
         OpenType<?> type = valuedata.getCompositeType().getType("value");
         if (type instanceof SimpleType<?>) {
           setProperty(propertyPrefix + "." + key1, value);
         } else {
           createProperty(propertyPrefix + "." + key1, value);
         }
       }
     }
   } else if (result.getClass().isArray()) {
     if (isSeparatearrayresults()) {
       int size = 0;
       for (int i = 0; i < Array.getLength(result); i++) {
         if (setProperty(propertyPrefix + "." + size, Array.get(result, i))) {
           size++;
         }
       }
       if (size > 0) {
         setProperty(propertyPrefix + ".Length", Integer.toString(size));
       }
     }
   } else {
     String delim = getDelimiter();
     if (delim != null) {
       StringTokenizer tokenizer = new StringTokenizer(result.toString(), delim);
       int size = 0;
       for (; tokenizer.hasMoreTokens(); ) {
         String token = tokenizer.nextToken();
         if (setProperty(propertyPrefix + "." + size, token)) {
           size++;
         }
       }
       if (size > 0) setProperty(propertyPrefix + ".Length", Integer.toString(size));
     } else {
       setProperty(propertyPrefix, result.toString());
     }
   }
 }