private void outputModules( StructuredTextDocument doc, Hashtable modulesTable, String mainTag, MimeMediaType encodeAs) { Enumeration allClasses = modulesTable.keys(); while (allClasses.hasMoreElements()) { ModuleClassID mcid = (ModuleClassID) allClasses.nextElement(); Object val = modulesTable.get(mcid); // For applications, we ignore the role ID. It is not meaningfull, // and a new one is assigned on the fly when loading this adv. if (val instanceof Advertisement) { TextElement m = doc.createElement(mainTag); doc.appendChild(m); if (!(modulesTable == appsTable || mcid.equals(mcid.getBaseClass()))) { // It is not an app and there is a role ID. Output it. TextElement i = doc.createElement(mcidTag, mcid.toString()); m.appendChild(i); } StructuredTextDocument advdoc = (StructuredTextDocument) ((Advertisement) val).getDocument(encodeAs); StructuredDocumentUtils.copyElements(doc, m, advdoc); } else if (val instanceof ModuleSpecID) { TextElement m; if (modulesTable == appsTable || mcid.equals(mcid.getBaseClass())) { // Either it is an app or there is no role ID. // So the specId is good enough. m = doc.createElement(mainTag, ((ModuleSpecID) val).toString()); doc.appendChild(m); } else { // The role ID matters, so the classId must be separate. m = doc.createElement(mainTag); doc.appendChild(m); TextElement i; i = doc.createElement(mcidTag, mcid.toString()); m.appendChild(i); i = doc.createElement(msidTag, ((ModuleSpecID) val).toString()); m.appendChild(i); } } else { if (LOG.isEnabledFor(Level.WARN)) LOG.warn("unsupported class in modules table"); } } }
/** {@inheritDoc} */ public void serializeTo(Element element) throws DocumentSerializationException { for (Iterator i = transportMetrics.iterator(); i.hasNext(); ) { TransportMetric transportMetric = (TransportMetric) i.next(); DocumentSerializableUtilities.addDocumentSerializable( element, "transportMetric", transportMetric); } if (moduleClassID != null) { DocumentSerializableUtilities.addString(element, "moduleClassID", moduleClassID.toString()); } }