List of usage examples for org.jdom2 Element setAttribute
public Element setAttribute(final String name, final String value)
This sets an attribute value for this element.
From source file:es.ucm.fdi.ac.NullTokenizer.java
License:Open Source License
public Element saveToXML() throws IOException { Element e = new Element("tokenizer"); e.setAttribute("class", getClass().getSimpleName()); return e;// ww w .j a va2 s . c o m }
From source file:es.ucm.fdi.ac.SourceSet.java
License:Open Source License
public Element saveToXML() throws IOException { Element sourcesElement = new Element("sources"); // Create and add roots node Hasher h = new Hasher(); Element rootsElement = new Element("roots"); for (FileTreeNode sourceRoot : sourceRoots) { // Create node Element rootElement = new Element("root"); rootElement.setAttribute("path", sourceRoot.toString()); rootElement.setAttribute("sha1", h.showBytes(h.hash(sourceRoot.getFile()).getSha1())); // Add node rootsElement.addContent(rootElement); }/*from w ww . j a va 2 s . co m*/ sourcesElement.addContent(rootsElement); Element mainFilterElement; // Create and add rootFilter node Element rootFilterElement = new Element("rootFilter"); mainFilterElement = rootFilter.saveToXML(); mainFilterElement.setName("filter"); rootFilterElement.addContent(mainFilterElement); sourcesElement.addContent(rootFilterElement); // Create and add fileFilter node Element fileFilterElement = new Element("fileFilter"); mainFilterElement = sourceFilter.saveToXML(); mainFilterElement.setName("filter"); fileFilterElement.addContent(mainFilterElement); sourcesElement.addContent(fileFilterElement); return sourcesElement; }
From source file:es.ucm.fdi.ac.Submission.java
License:Open Source License
public Element saveToXML() throws IOException { Element se = new Element("submission"); se.setAttribute("id", id); for (Annotation annotation : annotations) { se.addContent(annotation.saveToXML()); }// w w w . j a v a 2s. co m return se; }
From source file:es.ucm.fdi.clover.gui.CloverSave.java
License:Open Source License
/** * Saves the CloverSave to an XML file//from ww w . jav a 2 s . c o m */ public static void save(Collection<ClusterView> views, File f) throws IOException { Element root = new Element("clover"); root.setAttribute("version", saveVersion); root.setAttribute("requiresVersion", compatibleWith); root.setAttribute("date", new Date().toString()); Element shared = new Element("shared"); root.addContent(shared); HashMap<Filter, String> filterToId = new HashMap<Filter, String>(); HashMap<ClusteringEngine, String> engineToId = new HashMap<ClusteringEngine, String>(); HashMap<ClusterHierarchy, String> hierarchyToId = new HashMap<ClusterHierarchy, String>(); for (ClusterView v : views) { Element view = new Element("view"); v.save(view); Element layoutCache = new Element("layoutCache"); v.getAnimator().getLayoutCache().save(layoutCache, v.getBase()); view.addContent(layoutCache); Element animatorProps = new Element("animatorProps"); v.getAnimator().save(animatorProps); view.addContent(animatorProps); ClusteredGraph cg = (ClusteredGraph) v.getBase(); ClusterHierarchy h = cg.getHierarchy(); BaseGraph bg = cg.getBase(); // create the hierarchy element (if necessary) if (!hierarchyToId.containsKey(h)) { String hierarchyId = "" + generateId(); hierarchyToId.put(h, hierarchyId); Element hierarchy = new Element("hierarchy"); hierarchy.setAttribute("id", hierarchyId); h.save(hierarchy); // save the filtering used in the hierarchy (if necessary) if (bg instanceof FilteredGraph) { Filter filter = ((FilteredGraph) bg).getFilter(); if (!filterToId.containsKey(filter)) { String filterId = "" + generateId(); filterToId.put(filter, filterId); Element fe = new Element("filter"); fe.setAttribute("id", filterId); filter.save(fe); shared.addContent(fe); } hierarchy.setAttribute("filterId", filterToId.get(filter)); } // save the hierarchy itself: clustering and update-engine ClusteringEngine e = h.getEngine(); Element engine = new Element("engine"); engine.setAttribute("engineClass", e.getClass().getName()); e.save(engine); hierarchy.addContent(engine); shared.addContent(hierarchy); } view.setAttribute("hierarchyId", hierarchyToId.get(h)); root.addContent(view); } XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat()); outputter.output(new Document(root), new FileOutputStream(f)); }
From source file:es.ucm.fdi.clover.layout.LayoutCache.java
License:Open Source License
/** * Save a layoutCache to a jdom element/*from w w w . j a va 2 s. co m*/ */ public void save(Element e, BaseGraph g) { e.setAttribute("maxSize", "" + maxSize); for (CacheKey key : cache.keySet()) { SavedLayout sl = cache.get(key); if (sl == null) continue; Element entry = new Element("entry"); entry.setAttribute("key", key.save(g)); for (Object o : sl.getData().keySet()) { Rectangle2D r = sl.getData().get(o); Element box = new Element("box"); box.setAttribute("id", "" + g.getId(o)); box.setAttribute("x", "" + r.getX()); box.setAttribute("y", "" + r.getY()); box.setAttribute("w", "" + r.getWidth()); box.setAttribute("h", "" + r.getHeight()); entry.addContent(box); } e.addContent(entry); } }
From source file:es.ucm.fdi.clover.model.ClusterHierarchy.java
License:Open Source License
private void save(Cluster c, Element pe) { Element e = null; if (c.isLeafCluster()) { e = new Element("vertex"); Object v = c.getVertex(); e.setAttribute("id", base.getId(v)); } else {/*from www . jav a 2 s.c o m*/ e = new Element("cluster"); if (c.getName() != null) { e.setAttribute("name", c.getName()); } for (int i = 0; i < c.getChildCount(); i++) { save((Cluster) c.getChildAt(i), e); } } pe.addContent(e); }
From source file:es.ucm.fdi.clover.view.Animator.java
License:Open Source License
/** * Saves the animator's settings to a string *//*from w ww .j a v a 2 s .c o m*/ public void save(Element e) { e.setAttribute("maxInterpolationTime", "" + maxInterpolationTime); e.setAttribute("initialLayoutArea", "" + initialLayoutArea); e.setAttribute("initialLayoutTime", "" + initialLayoutTime); e.setAttribute("cacheSloppynessLimit", "" + cacheSloppynessLimit); e.setAttribute("incrementalRefinementPasses", "" + incrementalRefinementPasses); }
From source file:es.ucm.fdi.clover.view.BaseView.java
License:Open Source License
public void save(Element e) { e.setAttribute("zoom", "" + (layoutZoom > 1 ? layoutZoom : getScale())); String topCorner = "" + getVisibleRect().getX() + "," + getVisibleRect().getY(); e.setAttribute("topCorner", topCorner); }
From source file:es.ucm.fdi.clover.view.ClusterView.java
License:Open Source License
/** * Saves this view as an element of a JDom tree. *//* w w w .j av a 2s .c o m*/ public void save(Element e) { super.save(e); StringBuffer sb = null; e.setAttribute("poiVertex", getBase().getId(getCurrentPoI())); e.setAttribute("focusSize", "" + getFocusSize()); e.setAttribute("maxClusters", "" + maxClusters); e.setAttribute("isClusterLock", isClusterLock() ? "true" : "false"); // frozen set (may be empty) sb = new StringBuffer(); if (!frozen.isEmpty()) { for (Object v : frozen) { sb.append(getBase().getId(v) + ","); } sb.deleteCharAt(sb.length() - 1); } e.setAttribute("frozenVertices", sb.toString()); // visible slice sb = new StringBuffer(); for (Cluster c : ((ClusteredGraph) getBase()).getSlice()) { sb.append(getBase().getId(c.getVertex()) + ","); } sb.deleteCharAt(sb.length() - 1); e.setAttribute("visibleSlice", sb.toString()); }
From source file:es.upm.dit.xsdinferencer.generation.generatorimpl.statisticsgeneration.StatisticResultsDocGeneratorImpl.java
License:Apache License
/** * This method generates an element with the info of subpatterns. * @param elementName the element name/* ww w . jav a 2s. com*/ * @param subpatternsInfo the info of subpatterns * @return An element with all the information described */ protected Element generateSubpatternsInfoElement(String elementName, Map<List<SchemaElement>, Integer> subpatternsInfo) { Element element = new Element(elementName, STATISTICS_NAMESPACE); for (List<SchemaElement> subpattern : subpatternsInfo.keySet()) { int occurrences = subpatternsInfo.get(subpattern); Element occurrencesElement = new Element("occurrences", STATISTICS_NAMESPACE); occurrencesElement.setText("" + occurrences); element.addContent(occurrencesElement); Element subpatternElementsElement = new Element("subpatternElements", STATISTICS_NAMESPACE); for (int i = 0; i < subpattern.size(); i++) { SchemaElement schemaElement = subpattern.get(i); Element subpatternElementElement = new Element("subpatternElement", STATISTICS_NAMESPACE); subpatternElementElement.setAttribute("name", schemaElement.getName()); subpatternElementElement.setAttribute("namespace", schemaElement.getNamespace()); subpatternElementsElement.addContent(subpatternElementElement); } element.addContent(subpatternElementsElement); } return element; }