Example usage for org.jdom2 Attribute getValue

List of usage examples for org.jdom2 Attribute getValue

Introduction

In this page you can find the example usage for org.jdom2 Attribute getValue.

Prototype

public String getValue() 

Source Link

Document

This will return the actual textual value of this Attribute.

Usage

From source file:no.imr.stox.functions.utils.JDOMUtils.java

public static String getNodeValue(Element node, String nodeName, String missingStr) {
    String res;/*from  ww  w.  ja  va  2 s. c om*/
    if (node == null) {
        return null;
    }
    Attribute a = node.getAttribute(nodeName);
    if (a != null) {
        res = a.getValue();
    } else {
        res = node.getChildText(nodeName, node.getNamespace());
        if (res == null || res.isEmpty()) {
            res = missingStr;
        }
    }
    return res;
}

From source file:org.apache.marmotta.ldclient.provider.mediawiki.MediawikiProvider.java

License:Apache License

private static Map<String, String> getDefaultParams(String prop, Element queryContinue) {
    HashMap<String, String> params = new LinkedHashMap<String, String>();
    final String limit = "max";

    if ("info".equals(prop)) {
        params.put("inprop", "url");
    } else if ("revisions".equals(prop)) {
        // Revision info: first revision for creation
        params.put("rvdir", "newer");
        params.put("rvlimit", "1");
        params.put("rvprop", "ids|timestamp");
    } else if ("categories".equals(prop)) {
        params.put("cllimit", limit);
        // Categories: only visible cats
        params.put("clshow", "!hidden");
    } else if ("links".equals(prop)) {
        params.put("pllimit", limit);
        // Links: only links to same
        params.put("plnamespace", "0");
    } else if ("categorymembers".equals(prop)) {
        params.put("cmlimit", limit);
        params.put("cmprop", "title|type");
    }//from   w ww  .  j  av  a  2 s  .c  o m

    if (queryContinue != null && queryContinue.getName().equals(prop)
            && queryContinue.getAttributes().size() == 1) {
        final Attribute a = queryContinue.getAttributes().get(0);
        params.put(a.getName(), a.getValue());
    }

    return params;
}

From source file:org.bbsync.utility.file.Configuration.java

License:Apache License

private static boolean isNamedElement(Element elem, String name) {
    Attribute elemName = elem.getAttribute("name");

    if (elemName.getValue().equals(name)) {
        return true;
    }// w  w  w.  jav  a  2  s  .  c  o  m

    return false;
}

From source file:org.buddycloud.channelserver.XMPPAcceptanceTestHelper.java

License:Apache License

protected String getValue(Packet p, String xPath, boolean namespaceFeature) throws Exception {
    Object evaluateFirst = getEl(p, xPath, namespaceFeature);
    if (evaluateFirst instanceof Attribute) {
        Attribute attribute = (Attribute) evaluateFirst;
        return attribute.getValue();
    } else if (evaluateFirst instanceof Text) {
        return ((Text) evaluateFirst).getText();
    } else if (evaluateFirst instanceof Element) {
        throw new RuntimeErrorException(null, "XPath maps to element, not attribute");
    }/*  w ww .  ja  v  a2 s . c o m*/
    return evaluateFirst == null ? null : ((Attribute) evaluateFirst).getValue();
}

From source file:org.da4.urlminimizer.XmlConfiguration.java

License:Apache License

@Override
public ConfigVO getConfig(String filename) throws ConfigException {
    ConfigVO config = new ConfigVO();
    SAXBuilder builder = new SAXBuilder();
    Document doc = null;/*from  w w  w .  ja  v  a2 s  . c o  m*/
    try {
        doc = builder.build(new File(filename));
    } catch (JDOMException e) {
        throw new ConfigException("Error Parsing Config File", e);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        throw new ConfigException("Error Reading Config File", e);
    }

    Element rootElement = doc.getRootElement();
    Attribute attribProdName = rootElement.getAttribute("productName");
    if (attribProdName == null || attribProdName.getValue() == null
            || attribProdName.getValue().trim().isEmpty())
        throw new ConfigException("No Product name,or issue with product name");

    Attribute attribRootUrl = rootElement.getAttribute("rootUrl");
    if (attribRootUrl == null || attribRootUrl.getValue() == null || attribRootUrl.getValue().trim().isEmpty())
        throw new ConfigException("No Root Url,or issue with URL");

    config.setProductName(attribProdName.getValue());
    config.setRootUrl(attribRootUrl.getValue());

    List<PluginVO> pluginVos = new ArrayList<PluginVO>();
    List<Element> xmlPluginList = rootElement.getChildren("plugin");
    for (Element xmlPlugin : xmlPluginList) {
        String hooksRaw = xmlPlugin.getAttributeValue("hook");
        List<Hook> hooks = new ArrayList<Hook>();
        if (!"".equalsIgnoreCase(hooksRaw.trim())) {
            String[] hooksSplit = hooksRaw.split(",");
            for (String hook : hooksSplit) {
                hooks.add(Hook.get(hook));
            }
        }
        PluginVO pluginVo = new PluginVO(xmlPlugin.getAttributeValue("class"), hooks);
        Map<String, String> attribMap = new LinkedHashMap<String, String>();
        List<Element> xmlPluginAttribs = xmlPlugin.getChildren("attribute");
        for (Element xmlAttribute : xmlPluginAttribs) {

            attribMap.put(xmlAttribute.getAttributeValue("name"), xmlAttribute.getAttributeValue("value"));
        }
        pluginVo.setAttributes(attribMap);
        pluginVos.add(pluginVo);

    }
    config.setPluginConfigs(pluginVos);
    return config;
}

From source file:org.esa.nest.dat.layersrc.ObjectDetectionLayer.java

License:Open Source License

private void LoadTargets(final File file) {
    if (file == null)
        return;//w  w  w . j a va  2  s  . c  o  m

    Document doc;
    try {
        doc = XMLSupport.LoadXML(file.getAbsolutePath());
    } catch (IOException e) {
        return;
    }

    targetList.clear();

    final Element root = doc.getRootElement();

    final List children = root.getContent();
    for (Object aChild : children) {
        if (aChild instanceof Element) {
            final Element targetsDetectedElem = (Element) aChild;
            if (targetsDetectedElem.getName().equals("targetsDetected")) {
                final Attribute attrib = targetsDetectedElem.getAttribute("bandName");
                if (attrib != null && band.getName().equalsIgnoreCase(attrib.getValue())) {
                    final List content = targetsDetectedElem.getContent();
                    for (Object det : content) {
                        if (det instanceof Element) {
                            final Element targetElem = (Element) det;
                            if (targetElem.getName().equals("target")) {
                                final Attribute lat = targetElem.getAttribute("lat");
                                if (lat == null)
                                    continue;
                                final Attribute lon = targetElem.getAttribute("lon");
                                if (lon == null)
                                    continue;
                                final Attribute width = targetElem.getAttribute("width");
                                if (width == null)
                                    continue;
                                final Attribute length = targetElem.getAttribute("length");
                                if (length == null)
                                    continue;
                                final Attribute intensity = targetElem.getAttribute("intensity");
                                if (intensity == null)
                                    continue;

                                targetList.add(new ObjectDiscriminationOp.ShipRecord(
                                        Double.parseDouble(lat.getValue()), Double.parseDouble(lon.getValue()),
                                        (Double.parseDouble(width.getValue()) / rangeSpacing) + border,
                                        (Double.parseDouble(length.getValue()) / azimuthSpacing) + border,
                                        Double.parseDouble(intensity.getValue())));
                            }
                        }
                    }
                }
            }
        }
    }
}

From source file:org.esa.nest.dat.layersrc.WindFieldEstimationLayer.java

License:Open Source License

private void LoadTargets(final File file) {
    if (file == null)
        return;/*from  www.  j  ava2  s  . c om*/

    Document doc;
    try {
        doc = XMLSupport.LoadXML(file.getAbsolutePath());
    } catch (IOException e) {
        return;
    }

    targetList.clear();

    final Element root = doc.getRootElement();

    final List children = root.getContent();
    for (Object aChild : children) {
        if (aChild instanceof Element) {
            final Element targetsDetectedElem = (Element) aChild;
            if (targetsDetectedElem.getName().equals("windFieldEstimated")) {
                final Attribute attrib = targetsDetectedElem.getAttribute("bandName");
                if (attrib != null && band.getName().equalsIgnoreCase(attrib.getValue())) {
                    final List content = targetsDetectedElem.getContent();
                    for (Object det : content) {
                        if (det instanceof Element) {
                            final Element targetElem = (Element) det;
                            if (targetElem.getName().equals("windFieldInfo")) {
                                final Attribute lat = targetElem.getAttribute("lat");
                                if (lat == null)
                                    continue;
                                final Attribute lon = targetElem.getAttribute("lon");
                                if (lon == null)
                                    continue;
                                final Attribute speed = targetElem.getAttribute("speed");
                                if (speed == null)
                                    continue;
                                final Attribute dx = targetElem.getAttribute("dx");
                                if (dx == null)
                                    continue;
                                final Attribute dy = targetElem.getAttribute("dy");
                                if (dy == null)
                                    continue;
                                final Attribute ratio = targetElem.getAttribute("ratio");
                                if (ratio == null)
                                    continue;

                                targetList.add(new WindFieldEstimationOp.WindFieldRecord(
                                        Double.parseDouble(lat.getValue()), Double.parseDouble(lon.getValue()),
                                        Double.parseDouble(speed.getValue()), Double.parseDouble(dx.getValue()),
                                        Double.parseDouble(dy.getValue()),
                                        Double.parseDouble(ratio.getValue())));
                            }
                        }
                    }
                }
            }
        }
    }
}

From source file:org.esa.nest.dat.toolviews.Projects.ProductSet.java

License:Open Source License

boolean Load(final File file) {

    if (!file.exists())
        return false;
    Document doc;/*www .  j  a  v a2s  . c  o m*/
    try {
        doc = XMLSupport.LoadXML(file.getAbsolutePath());
    } catch (IOException e) {
        VisatApp.getApp().showErrorDialog(e.getMessage());
        return false;
    }

    fileList = new ArrayList<File>(10);
    Element root = doc.getRootElement();

    final List children = root.getContent();
    for (Object aChild : children) {
        if (aChild instanceof Element) {
            final Element child = (Element) aChild;
            if (child.getName().equals("product")) {
                final Attribute attrib = child.getAttribute("path");
                fileList.add(new File(attrib.getValue()));
            }
        }
    }
    return true;
}

From source file:org.esa.nest.dat.toolviews.Projects.Project.java

License:Open Source License

public void LoadProject(final File file) {

    initProject(file);/*w ww. j a v  a  2s .c  om*/

    Document doc;
    try {
        doc = XMLSupport.LoadXML(file.getAbsolutePath());
    } catch (IOException e) {
        VisatApp.getApp().showErrorDialog(e.getMessage());
        return;
    }

    final Vector<ProjectSubFolder> folderList = new Vector<ProjectSubFolder>(30);
    final Vector<ProjectFile> prodList = new Vector<ProjectFile>(50);

    final Element root = doc.getRootElement();

    final List children = root.getContent();
    for (Object aChild : children) {
        if (aChild instanceof Element) {
            final Element child = (Element) aChild;
            if (child.getName().equals("subFolder")) {
                final Attribute attrib = child.getAttribute("name");
                final ProjectSubFolder subFolder = projectSubFolders.addSubFolder(attrib.getValue());
                subFolder.fromXML(child, folderList, prodList);
            }
        }
    }

    loadProducts(folderList, prodList);

    notifyEvent(false);
    showProjectsView();
}

From source file:org.esa.nest.dat.toolviews.Projects.ProjectSubFolder.java

License:Open Source License

public void fromXML(Element elem, Vector<ProjectSubFolder> folderList, Vector<ProjectFile> prodList) {
    final List children = elem.getContent();
    for (Object aChild : children) {
        if (aChild instanceof Element) {
            final Element child = (Element) aChild;
            if (child.getName().equals("subFolder")) {
                final Attribute attrib = child.getAttribute("name");
                final ProjectSubFolder subFolder = addSubFolder(attrib.getValue());
                final Attribute attribUser = child.getAttribute("user");
                if (attribUser != null && attrib.getValue().equals("true"))
                    createdByUser = true;
                subFolder.fromXML(child, folderList, prodList);
            } else if (child.getName().equals("product")) {
                final Attribute pathAttrib = child.getAttribute("path");
                final Attribute nameAttrib = child.getAttribute("name");

                final File file = new File(pathAttrib.getValue());
                if (file.exists()) {
                    folderList.add(this);
                    final ProjectFile newFile = new ProjectFile(file, nameAttrib.getValue());
                    boolean added = prodList.add(newFile);
                    if (added) {
                        newFile.setFolderType(this.folderType);
                    }/*from   w  ww.  ja v  a 2 s  .  co  m*/
                }
            }
        }
    }
}