Example usage for org.jdom2 Element getText

List of usage examples for org.jdom2 Element getText

Introduction

In this page you can find the example usage for org.jdom2 Element getText.

Prototype

public String getText() 

Source Link

Document

Returns the textual content directly held under this element as a string.

Usage

From source file:de.relaunch64.popelganda.database.CustomScripts.java

License:Open Source License

/**
 * Returns the content of the script with the name {@code name}.
 * /*  w  ww  .ja  v  a2 s . c om*/
 * @param name the name of the script which content should be fetched
 * @return the content of the script with the name {@code name}.
 */
public String getScript(String name) {
    // check if element exists
    int pos = findScript(name);
    // script already exists, so update
    if (pos != -1) {
        // retrieve element
        Element el = retrieveElement(pos);
        // check for valid value
        if (el != null) {
            return el.getText();
        }
    }
    return null;
}

From source file:de.relaunch64.popelganda.database.CustomScripts.java

License:Open Source License

/**
 * Removes the script at the index {@code index}. Use {@link #findScript(java.lang.String) findScript()}
 * to find the index of a script by name.
 *  /*from  w ww  .  j  av  a 2  s. c o  m*/
 * @param index the index of the script that should be removed
 * @return {@code true} if removal was successful
 */
public boolean removeScript(int index) {
    List<Element> children = scriptFile.getRootElement().getChildren();
    try {
        Element el = children.remove(index);
        if (el != null) {
            // reset document
            scriptFile = new Document(new Element(ROOT_NAME));
            // iterate and add remaining elements
            for (Element e : children)
                addScript(e.getAttributeValue(ATTR_NAME), e.getText());
            return true;
        }
    } catch (UnsupportedOperationException | IndexOutOfBoundsException | IllegalAddException ex) {
        return false;
    }
    return false;
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

/**
 * Retrieves the recent document at the position {@code nr}. Returns {@code null} if recent document
 * does not exist or is empty/*from w  ww  .  j  a  v  a 2  s  .c o  m*/
 * @param nr the number of the requested recent document. use a value from 1 to {@link #recentDocCount recentDocCount}.
 * @return the recent document (the file path) as string, or {@code null} if no such element or path exists.
 */
public File getRecentDoc(int nr) {
    // checl for valid parameter
    if (nr < 0)
        return null;
    // retrieve element
    Element el = root.getChild(SETTING_RECENT_DOC + String.valueOf(nr));
    // if we have any valid document
    if (el != null) {
        // check whether its value is empty
        String retval = el.getText();
        // and if not, return in
        if (!retval.isEmpty()) {
            return new File(retval);
        }
    }
    // else return null
    return null;
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public File getLastUsedPath() {
    Element el = root.getChild(SETTING_LAST_USED_PATH);
    // changed to Yoda condition
    return new File((null == el) ? "" : el.getText());
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public String getAntiAlias() {
    Element el = root.getChild(SETTING_ANTIALIAS);
    if (el != null)
        return el.getText();
    return AntiAlias.SUBPIXEL;
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public boolean getScaleFont() {
    Element el = root.getChild(SETTING_SCALE_FONT);
    if (el != null)
        return el.getText().equals("1");
    return true;//w  ww .ja v  a 2 s .  com
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public boolean getSidebarIsHidden() {
    Element el = root.getChild(SETTING_SIDEBAR_ISHIDDEN);
    if (el != null)
        return el.getText().equals("1");
    return true;/*from   ww  w  .j a v a2  s .  co  m*/
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public boolean getUseNoTabs() {
    Element el = root.getChild(SETTING_USE_NOTABS);
    if (el != null)
        return el.getText().equals("1");
    return false;
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public boolean getFindByType() {
    Element el = root.getChild(SETTING_FINDBYTYPE);
    if (el != null)
        return el.getText().equals("1");
    return false;
}

From source file:de.relaunch64.popelganda.database.Settings.java

License:Open Source License

public boolean getWaitForProcess() {
    Element el = root.getChild(SETTING_WAITFORPROCESS);
    if (el != null)
        return el.getText().equals("1");
    return false;
}