/** * Directly decodes an attribute out of an XML fragment. */ public Attribute decodeAttribute (final org.jdom.Element elt) throws CodingException { AttributeCoder coder = getAttributeCoder(elt.getName()); if (coder == null) throw new CodingException("No coder for '"+elt.getName()+"'"); return coder.decode(elt, null); }
public org.jdom.Element encodeAttribute (final Attribute a) throws CodingException { if (a == null) return null; AttributeCoder coder = (AttributeCoder)getPerClassMap() .get(a.getClass().getName()); if (coder == null) { org.jdom.Element elt = new org.jdom.Element("error"); org.jdom.Comment cmt = new org.jdom.Comment ("No coder for Attribute of class '"+ a.getClass().getName()+"'"); elt.addContent(cmt); return elt; } return (org.jdom.Element)coder.encode(a, null); }
public void init (final String name, final java.util.List attributeCoders, final ListenerReplyCoder replyCoder, final java.util.Map params) { this.name = name; perClassMap = new java.util.HashMap(attributeCoders.size()); java.util.Iterator it = attributeCoders.iterator(); while (it.hasNext()) { AttributeCoder coder = (AttributeCoder)it.next(); perClassMap.put(coder.getAttributeClassName(), coder); } this.replyCoder = replyCoder; this.params = params; }
protected AttributeCoder buildAttributeCoder (WorkItemCoder workItemCoder, org.jdom.Element conf) throws ServiceException { String coderClassName = conf.getAttributeValue("class"); if (coderClassName == null) { throw new ServiceException ("Attribute 'coderClass' "+ "is missing from AttributeCoder configuration"); } log.debug("buildAttributeCoder() coderClassName is "+coderClassName); AttributeCoder coder = null; try { Class coderClass = Class.forName(coderClassName); coder = (AttributeCoder)coderClass.newInstance(); java.util.Map params = Parameters.extractAttributes(conf); coder.init(workItemCoder, params); } catch (Exception e) { throw new ServiceException ("Failed to instantiate AttributeCoder for class '"+ coderClassName+"'", e); } return coder; }
private Attribute decodeElement (final org.jdom.Element elt) throws CodingException { //log.debug ("decodeElement() for elt named '"+elt.getName()+"'"); final AttributeCoder coder = getXmlWorkItemCoder() .getAttributeCoder(elt.getName()); return coder.decode(elt, null); }
protected void encode (final java.sql.Statement st, final Long workitemId, final StringMapAttribute smap) throws java.sql.SQLException, CodingException { final String sWhere = " WHERE "+WID+" = '"+workitemId+"'"; st.addBatch("DELETE FROM "+ATTRIBUTE_TABLE+sWhere); final java.util.Map params = AbstractSqlAttributeCoder.prepareParams (st, workitemId, 0, -1); Long lid = (Long)this.getAttributeCoder(smap) .encode(smap, params); log.debug ("encode() seem to have inserted "+(lid.longValue()+1)+ " attributes"); }
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; }
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; }
protected void decodeWorkItem (final WorkItem target, final org.jdom.Element elt) throws CodingException { //log.debug("decodeWorkItem()"); target.setLastModified (elt.getAttributeValue(LAST_MODIFIED)); // // parse attributes org.jdom.Element attElt = elt.getChild(ATTRIBUTES, elt.getNamespace()); if (attElt != null) { attElt = attElt.getChild(SMAP, elt.getNamespace()); if (attElt != null) { final AttributeCoder coder = getAttributeCoder(SMAP); target.setAttributes((StringMapAttribute)coder .decode(attElt, null)); } } }
.encode(child, childParams);
.decode(new Long(0), args));
.decode(dmElt, null);