List of usage examples for java.util Deque forEach
default void forEach(Consumer<? super T> action)
From source file:com.ggvaidya.scinames.model.Project.java
public void serializeToDocument(Document doc) { // Add top-level element. Element project = doc.createElement("project"); project.setAttribute("name", getName()); doc.appendChild(project);// w w w . j a v a 2s.c om // Set up some properties. properties.put(PROP_NAME_EXTRACTORS, getNameExtractors().stream().map(lne -> NameExtractorFactory.serializeExtractorsToString(lne)) .distinct().sorted().collect(Collectors.joining("; "))); // Write out properties. Element propertiesElement = doc.createElement("properties"); for (String key : properties.keySet()) { Element p = doc.createElement("property"); p.setAttribute("name", key); p.setTextContent(properties.get(key)); propertiesElement.appendChild(p); } project.appendChild(propertiesElement); // Add filters. Element filtersElement = doc.createElement("filters"); Deque<ChangeFilter> changeFilters = new LinkedList<>(); { // We need to read the filters inside-out, so they'll be recreated // the right way around. ChangeFilter cf = getChangeFilter(); while (cf != null) { changeFilters.addLast(cf); cf = cf.getPrevChangeFilter(); } } changeFilters.forEach(cf -> { // Skip any nulls. if (cf.getShortName().equals("null")) return; filtersElement.appendChild(cf.serializeToElement(doc)); }); project.appendChild(filtersElement); // List all timepoints. Element timepointsElement = doc.createElement("datasets"); for (Dataset tp : getDatasets()) { Element t = tp.serializeToElement(doc); timepointsElement.appendChild(t); } project.appendChild(timepointsElement); }
From source file:org.dataconservancy.packaging.tool.impl.generator.IPMUtil.java
public static String path(Node node, String suffix) { Deque<String> pathStack = new ArrayDeque<>(); pathStack.push(suffix);/*w ww. j a v a 2s .co m*/ pathStack.push(name(node)); while (!node.isRoot()) { node = node.getParent(); if (node.getFileInfo() != null && !node.getFileInfo().isFile()) { pathStack.push("/"); pathStack.push(name(node)); } } StringBuilder builder = new StringBuilder(); pathStack.forEach(builder::append); return builder.toString(); }