use of org.jdom.Namespace in project libresonic by Libresonic.
the class LyricsService method parseSearchResult.
private LyricsInfo parseSearchResult(String xml) throws Exception {
SAXBuilder builder = new SAXBuilder();
Document document = builder.build(new StringReader(xml));
Element root = document.getRootElement();
Namespace ns = root.getNamespace();
String lyric = StringUtils.trimToNull(root.getChildText("Lyric", ns));
String song = root.getChildText("LyricSong", ns);
String artist = root.getChildText("LyricArtist", ns);
return new LyricsInfo(lyric, artist, song);
}
use of org.jdom.Namespace in project intellij-plugins by JetBrains.
the class FlexCompilerConfigFileUtilBase method removeLibs.
private static Collection<String> removeLibs(final Element rootElement, final boolean removeExternal, final boolean removeIncluded) {
final Namespace namespace = rootElement.getNamespace();
final Collection<String> result = new ArrayList<>();
//noinspection unchecked
for (Element compilerElement : rootElement.getChildren(COMPILER, namespace)) {
if (removeExternal) {
//noinspection unchecked
for (Element externalLibraryPathElement : compilerElement.getChildren(EXTERNAL_LIBRARY_PATH, namespace)) {
final Collection<Element> pathElementsToRemove = new ArrayList<>();
//noinspection unchecked
for (Element pathElement : externalLibraryPathElement.getChildren(PATH_ELEMENT, namespace)) {
final String path = pathElement.getText();
final String fileName = path.substring(FileUtil.toSystemIndependentName(path).lastIndexOf("/") + 1);
if (fileName.startsWith("playerglobal") || fileName.startsWith("airglobal")) {
continue;
}
result.add(path);
pathElementsToRemove.add(pathElement);
}
for (Element pathElement : pathElementsToRemove) {
externalLibraryPathElement.removeContent(pathElement);
}
}
}
if (removeIncluded) {
//noinspection unchecked
for (Element includeLibrariesElement : compilerElement.getChildren(INCLUDE_LIBRARIES, namespace)) {
final Collection<Element> libraryElementsToRemove = new ArrayList<>();
//noinspection unchecked
for (Element libraryElement : includeLibrariesElement.getChildren(LIBRARY, namespace)) {
result.add(libraryElement.getText());
libraryElementsToRemove.add(libraryElement);
}
for (Element pathElement : libraryElementsToRemove) {
includeLibrariesElement.removeContent(pathElement);
}
}
}
}
return result;
}
use of org.jdom.Namespace in project intellij-plugins by JetBrains.
the class FlexCommonUtils method parseAirVersionFromDescriptorFile.
@Nullable
public static String parseAirVersionFromDescriptorFile(final String descriptorFilePath) {
if (StringUtil.isEmpty(descriptorFilePath))
return null;
try {
final Element rootElement = JDOMUtil.load(new File(descriptorFilePath));
final String localName = rootElement.getName();
final Namespace namespace = rootElement.getNamespace();
if ("application".equals(localName) && namespace != null && namespace.getURI().startsWith(AIR_NAMESPACE_BASE)) {
return namespace.getURI().substring(AIR_NAMESPACE_BASE.length());
}
} catch (JDOMException | IOException e) {
/*unlucky*/
}
return null;
}
use of org.jdom.Namespace in project intellij-community by JetBrains.
the class ExtensionsAreaImpl method extractEPName.
public static String extractEPName(final Element extensionElement) {
String epName = extensionElement.getAttributeValue("point");
if (epName == null) {
final Element parentElement = extensionElement.getParentElement();
final String ns = parentElement != null ? parentElement.getAttributeValue("defaultExtensionNs") : null;
if (ns != null) {
epName = ns + '.' + extensionElement.getName();
} else {
Namespace namespace = extensionElement.getNamespace();
epName = namespace.getURI() + '.' + extensionElement.getName();
}
}
return epName;
}
use of org.jdom.Namespace in project fabric8 by jboss-fuse.
the class StandaloneInstaller method updateAriesBlueprintCompatibility.
public int updateAriesBlueprintCompatibility() throws Exception {
Namespace NS = Namespace.getNamespace("http://karaf.apache.org/xmlns/features/v1.2.0");
File xmlFile = new File(karafBase, "system/org/apache/karaf/assemblies/features/standard/2.4.0.redhat-620133/standard-2.4.0.redhat-620133-features.xml");
if (!xmlFile.exists()) {
LOG.error("File not found: " + xmlFile);
return 0;
}
SAXBuilder builder = new SAXBuilder();
Document doc = (Document) builder.build(xmlFile);
Element rootNode = doc.getRootElement();
for (Element feature : findChildrenWith(rootNode, "feature", "name", "aries-blueprint", NS)) {
// Is it not installed?
String compatBundle = "mvn:org.apache.aries.blueprint/org.apache.aries.blueprint.core.compatibility/1.0.0";
if (findChildrenWithText(feature, "bundle", compatBundle, NS).isEmpty()) {
Element bundle = new Element("bundle", NS).setText(compatBundle);
bundle.setAttribute("start-level", "20");
feature.addContent(bundle);
XMLOutputter xmlOutput = new XMLOutputter();
xmlOutput.setFormat(Format.getRawFormat());
xmlOutput.output(doc, new FileWriter(xmlFile));
LOG.info("Updated: " + xmlFile);
return 1;
}
}
return 0;
}
Aggregations