use of org.jdom.Attribute in project vcell by virtualcell.
the class BiomodelsDB_TestSuite method writeSupportedModelsReport.
public static Document writeSupportedModelsReport(File supportInfoDir, File saveSupportedXMLPathname) throws Exception {
if (!supportInfoDir.isDirectory()) {
throw new IllegalArgumentException("File " + supportInfoDir.getAbsolutePath() + " must be a directory.");
}
File[] xmlReportFiles = supportInfoDir.listFiles(new FileFilter() {
public boolean accept(File pathname) {
if (pathname.isFile()) {
if (pathname.getName().endsWith("_report.xml")) {
return true;
}
}
return false;
}
});
Document supportedDocument = new Document(new Element("Supported_BioModelsNet"));
List<Element> supportedElements = new ArrayList<Element>();
for (int i = 0; i < xmlReportFiles.length; i++) {
byte[] xmlBytes = new byte[(int) xmlReportFiles[i].length()];
FileInputStream fis = new FileInputStream(xmlReportFiles[i]);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
dis.readFully(xmlBytes);
dis.close();
Document document = XmlUtil.stringToXML(new String(xmlBytes), null);
Element bioModelElement = document.getRootElement().getChild(BioModelsNetPanel.BIOMODELINFO_ELEMENT_NAME);
Attribute supportedAttribute = bioModelElement.getAttribute(BioModelsNetPanel.SUPPORTED_ATTRIBUTE_NAME);
if (supportedAttribute.getBooleanValue()) {
Element newBioModelElement = new Element(BioModelsNetPanel.BIOMODELINFO_ELEMENT_NAME);
@SuppressWarnings("unchecked") List<Attribute> attrList = bioModelElement.getAttributes();
Iterator<Attribute> iterAttr = attrList.iterator();
while (iterAttr.hasNext()) {
newBioModelElement.setAttribute((Attribute) iterAttr.next().clone());
}
supportedElements.add(newBioModelElement);
}
}
// Collections.sort(supportedElements, new ElementComparer());
Element root = supportedDocument.getRootElement();
for (Element e : supportedElements) {
root.addContent(e);
}
if (saveSupportedXMLPathname != null) {
try (FileWriter fw = new FileWriter(saveSupportedXMLPathname.getAbsolutePath())) {
Format format = Format.getPrettyFormat();
XMLOutputter out = new XMLOutputter(format);
out.output(supportedDocument, fw);
}
}
return supportedDocument;
}
use of org.jdom.Attribute in project che by eclipse.
the class JdomUtil method getHash.
private static int getHash(int hash, Element element) {
hash = sumHash(hash, element.getName());
for (Object object : element.getAttributes()) {
Attribute attribute = (Attribute) object;
hash = sumHash(hash, attribute.getName());
hash = sumHash(hash, attribute.getValue());
}
for (Object o : element.getContent()) {
if (o instanceof Element) {
hash = getHash(hash, (Element) o);
} else if (o instanceof Text) {
String text = ((Text) o).getText();
if (!isNullOrWhitespace(text)) {
hash = sumHash(hash, text);
}
}
}
return hash;
}
use of org.jdom.Attribute in project intellij-community by JetBrains.
the class LwXmlReader method getColorDescriptor.
public static ColorDescriptor getColorDescriptor(final Element element) throws Exception {
Attribute attr = element.getAttribute(UIFormXmlConstants.ATTRIBUTE_COLOR);
if (attr != null) {
return new ColorDescriptor(new Color(attr.getIntValue()));
}
String swingColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SWING_COLOR);
if (swingColor != null) {
return ColorDescriptor.fromSwingColor(swingColor);
}
String systemColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_SYSTEM_COLOR);
if (systemColor != null) {
return ColorDescriptor.fromSystemColor(systemColor);
}
String awtColor = element.getAttributeValue(UIFormXmlConstants.ATTRIBUTE_AWT_COLOR);
if (awtColor != null) {
return ColorDescriptor.fromAWTColor(awtColor);
}
return new ColorDescriptor(null);
}
use of org.jdom.Attribute in project freud by LMAX-Exchange.
the class MethodCallJdom method getMethodName.
@SuppressWarnings("unchecked")
public String getMethodName() {
if (methodName == null) {
final Attribute idAttr = methodCallElement.getAttribute(JdomTreeAdaptor.ID_ATTR);
if (idAttr != null) {
methodName = idAttr.getValue();
instanceReferences = EMPTY_ARRAY;
} else {
JXPathContext context = JXPathContext.newContext(methodCallElement);
final List<Element> identElementList = context.selectNodes("//" + JavaSourceTokenType.IDENT.getName());
Collections.sort(identElementList, JdomTreePositionComparator.getInstance());
final int methodNameIndex = identElementList.size() - 1;
methodName = identElementList.get(methodNameIndex).getText();
instanceReferences = new String[methodNameIndex];
for (int i = 0, size = instanceReferences.length; i < size; i++) {
instanceReferences[i] = identElementList.get(i).getText();
}
}
}
return methodName;
}
use of org.jdom.Attribute in project intellij-plugins by JetBrains.
the class FlexCompilerConfigFileUtilBase method makeLibrariesMergedIntoCode.
private static void makeLibrariesMergedIntoCode(final Element rootElement, final boolean externalLibs, final boolean includedLibs) {
final Namespace namespace = rootElement.getNamespace();
final Collection<String> paths = removeLibs(rootElement, externalLibs, includedLibs);
if (!paths.isEmpty()) {
final Element compilerElement = rootElement.getChild(COMPILER, namespace);
Element libraryPathElement = compilerElement.getChild(LIBRARY_PATH, namespace);
if (libraryPathElement == null) {
libraryPathElement = new Element(LIBRARY_PATH, namespace);
libraryPathElement.setAttribute(new Attribute(APPEND, "true"));
compilerElement.addContent(libraryPathElement);
}
for (final String path : paths) {
final Element pathElement = new Element(PATH_ELEMENT, namespace);
pathElement.addContent(path);
libraryPathElement.addContent(pathElement);
}
}
}
Aggregations