/** * Turns an OpenWFE ListAttribute into a java ArrayList */ public static java.util.List list2java (final ListAttribute la) { java.util.List result = new java.util.ArrayList(la.size()); java.util.Iterator it = la.iterator(); while (it.hasNext()) { Attribute v = (Attribute)it.next(); result.add(owfe2java(v)); } return result; }
private static ListAttribute array2owfe (final Object array) { //log.debug("array2owfe()"); final ListAttribute result = new ListAttribute(Array.getLength(array)); //result.setArray(true); for (int i=0; i<Array.getLength(array); i++) result.add(java2owfe(Array.get(array, i))); return result; }
final ListAttribute la = new ListAttribute(); if (i < end && inc < 0) break; final Attribute a = get(i); if (a != null) la.add(a); final ListAttribute la = new ListAttribute(); la.add(this.get(Integer.parseInt(ss[i]))); return get(Integer.parseInt(key));
public synchronized Object clone () { ListAttribute clone = new ListAttribute(this.size()); java.util.Iterator it = this.list.iterator(); while (it.hasNext()) { Attribute a = (Attribute)it.next(); clone.add((Attribute)a.clone()); } return clone; }
/** * Returns a String of the contained values, separated by commas. */ public String toString () { final StringBuffer sb = new StringBuffer(); //sb.append("[ "); final java.util.Iterator it = this.iterator(); while (it.hasNext()) { sb.append(it.next().toString()); if (it.hasNext()) sb.append(", "); } //sb.append(" ]"); return sb.toString(); }
public Attribute decode (final Object o, final java.util.Map args) throws CodingException { final java.util.List attributeRecordList = AbstractSqlAttributeCoder .fetchAttributeRecordList(args); final Long attId = (Long)o; SqlWorkItemCoder.removeRecord(attributeRecordList, attId); ListAttribute result = null; try { final Class attributeClass = Class.forName(this.attributeClassName); result = (ListAttribute)attributeClass.newInstance(); } catch (Exception e) { throw new CodingException ("Failed instantiate list attribute", e); } final java.util.List entries = SqlWorkItemCoder .lookupRecords(attributeRecordList, attId.longValue()); final java.util.Iterator it = entries.iterator(); while (it.hasNext()) { final SqlWorkItemCoder.AttributeRecord record = (SqlWorkItemCoder.AttributeRecord)it.next(); result.add(decodeChild(record.id, record.type, args)); } return result; }
/** * The implementation of cget() as defined in the parent * class CollectionAttribute. */ public Attribute cget (final String key) { if (key.equals(K_KEYSET)) return new ListAttribute(this.map.keySet()); return (Attribute)this.map.get(new StringAttribute(key)); }
private void flatten (final InFlowWorkItem wi, final String fieldName, final String toFieldName, final ListAttribute la, final String separator, final boolean trim) { StringBuffer sb = new StringBuffer(); final java.util.Iterator it = la.iterator(); while (it.hasNext()) { final Attribute a = (Attribute)it.next(); if (sb.length() > 0) sb.append(separator); sb.append(a.toString()); } String fn = fieldName; if (toFieldName != null) fn = toFieldName; wi.getAttributes().puts(fn, sb.toString()); if (log.isDebugEnabled()) log.debug("flatten() '"+fn+"' -> '"+sb.toString()+"'"); }
/** * Turns an OpenWFE Attribute into a list of string, you can specify * the separator for the final string splitting */ public static java.util.List owfe2list (final Attribute a, final String separator) { if (a instanceof ListAttribute) { final ListAttribute la = (ListAttribute)a; final java.util.List result = new java.util.ArrayList(la.size()); final java.util.Iterator it = la.iterator(); while (it.hasNext()) result.add((it.next()).toString()); return result; } String s = ""; if (a != null) s = a.toString(); final String[] ss = s.split(separator); final java.util.List result = new java.util.ArrayList(ss.length); for (int i=0; i<ss.length; i++) result.add(ss[i]); return result; }
/** * Turns a java List into an OpenWFE ListAttribute */ public static ListAttribute list2owfe (java.util.List l) { ListAttribute result = new ListAttribute(); java.util.Iterator it = l.iterator(); while (it.hasNext()) { result.add(java2owfe(it.next())); } return result; }
public Object encode (final Attribute a, final java.util.Map args) throws CodingException { if (a == null) return null; ListAttribute la = (ListAttribute)a; final org.jdom.Element elt = newElement(); java.util.Iterator it = la.iterator(); while (it.hasNext()) { Attribute value = (Attribute)it.next(); AttributeCoder coder = getXmlWorkItemCoder() .getAttributeCoder(value); elt.addContent((org.jdom.Element)coder.encode(value, null)); } return elt; }
public Attribute decode (final Object o, final java.util.Map args) throws CodingException { final org.jdom.Element elt = enforceElement(o); ListAttribute la = new ListAttribute(); java.util.Iterator it = elt.getChildren().iterator(); // // there's no getChildren(ns) method... // going on without it for now... while (it.hasNext()) { org.jdom.Element child = (org.jdom.Element)it.next(); AttributeCoder coder = getXmlWorkItemCoder() .getAttributeCoder(child.getName()); Attribute a = coder.decode(child, null); la.add(a); } return la; }
final java.util.Iterator it = la.iterator(); while (it.hasNext())
private void expand (final InFlowWorkItem wi, final String fieldName, final String toFieldName, final Attribute a, String separator, final boolean trim) { if (separator.equals("|")) separator = "\\|"; // // there may be other special cases, but for now, it's sufficient // // do the job final String value = a.toString(); final String[] ss = value.split(separator); final ListAttribute la = new ListAttribute(ss.length); for (int i=0; i<ss.length; i++) { String s = ss[i]; if (trim) s = s.trim(); la.add(new StringAttribute(s)); if (log.isDebugEnabled()) log.debug("expand() "+i+" -> '"+s+"'"); } String fn = fieldName; if (toFieldName != null) fn = toFieldName; wi.getAttributes().put(fn, la); }
@Override public void init() { super.init(); item = WorkflowUtil.getWorkItem(getWorkItemId()); if (item == null) { throw new RuntimeException("can't read workitem"); } rootPath = item.getAttribute("path").toString(); repository = item.getAttribute("repository").toString(); hm = MgnlContext.getHierarchyManager(repository); ListAttribute versions = (ListAttribute) item.getAttribute(Context.ATTRIBUTE_VERSION_MAP); for (Iterator iter = versions.iterator(); iter.hasNext();) { Map versionMap = (Map) iter.next(); String version = versionMap.get("version").toString(); String uuid = versionMap.get("uuid").toString(); try { Content node = hm.getContentByUUID(uuid); if (!node.getHandle().equals(rootPath)) { this.subPages.add(new SubPage(node, version)); } } catch (RepositoryException e) { log.error("can't read subpage for [" + rootPath + "]", e); } } }
archive = new ListAttribute(); archive.add(definition);