use of org.jdom2.filter.Filter in project pcgen by PCGen.
the class Initiative method checkDeadTabs.
/**
* Check for dead combatants
*/
private void checkDeadTabs() {
initList.stream().filter(anInitList -> anInitList.getStatus() == State.Dead).forEach(anInitList -> {
if (showDead.isSelected() && (anInitList instanceof Combatant) && (tpaneInfo.indexOfTab(anInitList.getName()) == -1)) {
Combatant cbt = (Combatant) anInitList;
addTab(cbt);
} else {
removeTab(anInitList);
}
});
}
use of org.jdom2.filter.Filter in project coprhd-controller by CoprHD.
the class ServiceCatalogBuilder method build.
/**
* Parses xml file to ServiceCatalog with Jdom
*
* @param xmlFile
* The instance of xml file
* @return instance of ServiceCatalog
*/
public static ServiceCatalog build(final File xmlFile) {
String fileName = xmlFile.getName().trim().toLowerCase();
// remove suffix
if (fileName.endsWith(Constants.XML_FILE_SUFFIX)) {
fileName = fileName.substring(0, fileName.length() - Constants.XML_FILE_SUFFIX.length() - 1);
} else {
throw new IllegalArgumentException("API file is not xml format: " + fileName);
}
// filter name
int separatorIndex = fileName.indexOf(Constants.NAME_STRING_SEPARATOR);
if (separatorIndex == -1) {
throw new IllegalArgumentException("API file name should split with " + Constants.NAME_STRING_SEPARATOR + " actually: " + fileName);
}
String serviceName = fileName.substring(0, separatorIndex);
String version = fileName.substring(separatorIndex + 1, fileName.length());
Document document;
try {
document = new SAXBuilder().build(xmlFile);
} catch (Exception ex) {
throw new IllegalArgumentException("Invalid XML file:\n " + xmlFile.getAbsolutePath(), ex);
}
if (document == null) {
return null;
}
// Navigates to resource tag, it's a little tricky here, depends on structure of xml file completely.
List<Element> resourceList = document.getRootElement().getChild(Constants.REST_NODE).getChild(Constants.RESOURCES_NODE).getChildren();
// Navigates to element tag, it's a little tricky here, depends on structure of xml file completely.
List<Element> elementList = document.getRootElement().getChild(Constants.DATA_NODE).getChild(Constants.DATA_SCHEMA_NODE).getChild(Constants.ELEMENTS_NODE).getChildren();
return new ServiceCatalog(parseResource(resourceList), parseElement(elementList), serviceName, version);
}
use of org.jdom2.filter.Filter in project JMRI by JMRI.
the class JmriUserPreferencesManager method saveComboBoxLastSelections.
private void saveComboBoxLastSelections() {
this.setChangeMade(false);
if (this.allowSave && !comboBoxLastSelection.isEmpty()) {
Element element = new Element(COMBOBOX_ELEMENT, COMBOBOX_NAMESPACE);
// Do not store blank last entered/selected values
comboBoxLastSelection.entrySet().stream().filter((cbls) -> (cbls.getValue() != null && !cbls.getValue().isEmpty())).map((cbls) -> {
Element combo = new Element("comboBox");
combo.setAttribute("name", cbls.getKey());
combo.setAttribute("lastSelected", cbls.getValue());
return combo;
}).forEach((combo) -> {
element.addContent(combo);
});
this.saveElement(element);
this.resetChangeMade();
}
}
use of org.jdom2.filter.Filter in project JMRI by JMRI.
the class RpsPositionIconXml method store.
/**
* Default implementation for storing the contents of a RpsPositionIcon
*
* @param o Object to store, of type RpsPositionIcon
* @return Element containing the complete info
*/
@Override
public Element store(Object o) {
RpsPositionIcon p = (RpsPositionIcon) o;
if (!p.isActive()) {
// if flagged as inactive, don't store
return null;
}
Element element = new Element("sensoricon");
storeCommonAttributes(p, element);
// include contents
element.setAttribute("active", p.getActiveIcon().getURL());
element.setAttribute("error", p.getErrorIcon().getURL());
element.setAttribute("rotate", String.valueOf(p.getActiveIcon().getRotation()));
element.setAttribute("momentary", p.getMomentary() ? "true" : "false");
element.setAttribute("sxscale", "" + p.getXScale());
element.setAttribute("syscale", "" + p.getYScale());
element.setAttribute("sxorigin", "" + p.getXOrigin());
element.setAttribute("syorigin", "" + p.getYOrigin());
element.setAttribute("showid", p.isShowID() ? "true" : "false");
if (p.getFilter() != null) {
element.setAttribute("filter", "" + p.getFilter());
}
element.addContent(storeIcon("active", p.getActiveIcon()));
element.addContent(storeIcon("error", p.getErrorIcon()));
element.setAttribute("class", "jmri.jmrit.display.configurexml.RpsPositionIconXml");
return element;
}
use of org.jdom2.filter.Filter in project jPOS by jpos.
the class ChannelAdaptor method addFilters.
protected void addFilters(FilteredChannel channel, Element e, QFactory fact) throws ConfigurationException {
for (Object o : e.getChildren("filter")) {
Element f = (Element) o;
String clazz = f.getAttributeValue("class");
ISOFilter filter = (ISOFilter) fact.newInstance(clazz);
fact.setLogger(filter, f);
fact.setConfiguration(filter, f);
String direction = f.getAttributeValue("direction");
if (direction == null)
channel.addFilter(filter);
else if ("incoming".equalsIgnoreCase(direction))
channel.addIncomingFilter(filter);
else if ("outgoing".equalsIgnoreCase(direction))
channel.addOutgoingFilter(filter);
else if ("both".equalsIgnoreCase(direction)) {
channel.addIncomingFilter(filter);
channel.addOutgoingFilter(filter);
}
}
}
Aggregations