private static void writeNonePrimitiveType( StringBuilder sb, Map<String, List<Content>> listNonPrimitive) { for (String s : listNonPrimitive.keySet()) { for (Content c : listNonPrimitive.get(s)) { writeOpenTag(s, sb); if (c.isPrimitive()) sb.append(c.getValue()); else writeNonePrimitiveType(sb, c.getMapValues()); writeCloseTag(s, sb); } } }
/** * Returns the index of a content from its Parent point of view, and using JDOM specifications. * * @param parent * @param content * @return The index of the Content * @throws robusta.commons.exceptions.XmlException */ public int getContentIndex(Element parent, Content content) throws XmlException { List contents = parent.getContent(); for (int i = 0; i < contents.size(); i++) { if (contents.get(i) == content) { return i; } } throw new XmlException( "can't find content " + content.getValue() + " in element " + parent.getName()); }
/** * Creates an StringBuilder from a Map of Parameters which then can be send through ROADfactory * * @param toConvertMap The Map which contains the values of the parameters * @return A StringBuilder with the content of the XML document */ public static StringBuilder getXmlString(Map<String, List<Content>> toConvertMap) { StringBuilder sb = new StringBuilder(); sb.append("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); for (String s : toConvertMap.keySet()) { for (Content c : toConvertMap.get(s)) { writeOpenTag(s, sb); if (c.isPrimitive()) sb.append(c.getValue()); else writeNonePrimitiveType(sb, c.getMapValues()); writeCloseTag(s, sb); } } return sb; }