Example usage for org.dom4j Attribute getValue

List of usage examples for org.dom4j Attribute getValue

Introduction

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

Prototype

String getValue();

Source Link

Document

Returns the value of the attribute.

Usage

From source file:org.jbpm.gd.jpdl.editor.JpdlContentProvider.java

License:Open Source License

private void processServerPort(DeploymentInfo deploymentInfo, Attribute attribute, IPreferenceStore prefs) {
    if (attribute == null) {
        deploymentInfo.setServerPort(prefs.getString(SERVER_PORT));
    } else {//from  w  w w.  ja va  2 s . c  o  m
        deploymentInfo.setServerPort(attribute.getValue());
    }
}

From source file:org.jbpm.gd.jpdl.editor.JpdlContentProvider.java

License:Open Source License

private void processServerDeployer(DeploymentInfo deploymentInfo, Attribute attribute, IPreferenceStore prefs) {
    if (attribute == null) {
        deploymentInfo.setServerDeployer(prefs.getString(SERVER_DEPLOYER));
    } else {//from   w w  w. j ava2 s .  c om
        deploymentInfo.setServerDeployer(attribute.getValue());
    }
}

From source file:org.jbpm.gd.jpdl.editor.JpdlContentProvider.java

License:Open Source License

protected void processGraphicalInfoFile(DeploymentInfo deploymentInfo, Element deploymentElement,
        IFileEditorInput editorInput) {/*from  w  ww .  jav a2 s .c  o  m*/
    if (deploymentElement == null)
        return;
    Attribute attribute = deploymentElement.attribute("graphicalInfoFile");
    if (attribute == null) {
        attribute = deploymentElement.attribute("gpdFile");
    }
    IFile graphicalInfoFile = null;
    if (attribute != null && attribute.getValue() != null) {
        IResource resource = editorInput.getFile().getWorkspace().getRoot()
                .findMember(new Path(attribute.getValue()));
        if (resource instanceof IFile) {
            graphicalInfoFile = (IFile) resource;
        }
    }
    deploymentInfo.setGraphicalInfoFile(graphicalInfoFile);
}

From source file:org.jbpm.gd.jpdl.editor.JpdlContentProvider.java

License:Open Source License

protected void processImageFile(DeploymentInfo deploymentInfo, Element deploymentElement,
        IFileEditorInput editorInput) {/*ww  w .jav  a2  s .  c  o  m*/
    if (deploymentElement == null)
        return;
    Attribute attribute = deploymentElement.attribute("imageFile");
    IFile imageFile = null;
    if (attribute != null && attribute.getValue() != null) {
        IResource resource = editorInput.getFile().getWorkspace().getRoot()
                .findMember(new Path(attribute.getValue()));
        if (resource instanceof IFile) {
            imageFile = (IFile) resource;
        }
    }
    deploymentInfo.setImageFile(imageFile);
}

From source file:org.jbpm.gd.jpdl.wizard.NewProcessDefinitionWizard.java

License:Open Source License

private String getNameSpace(File file) {
    try {/*from w w w  .ja  v a 2 s .  com*/
        Document document = new SAXReader().read(file);
        Attribute attribute = document.getRootElement().attribute("namespace");
        if (attribute != null) {
            return attribute.getValue();
        } else {
            return "";
        }
    } catch (DocumentException e) {
        Logger.logError(e);
        return "";
    } catch (MalformedURLException e) {
        Logger.logError(e);
        return "";
    }
}

From source file:org.jcommon.com.util.config.ConfigLoader.java

License:Apache License

@SuppressWarnings("unchecked")
private static String getTextFromElement(Element e) {
    Element element = e;/*from   w  w w  .  j a  va 2  s  .  co m*/
    if (element != null) {
        List<Attribute> l = element.attributes();
        if (l != null && l.size() != 0) {
            String[] keys = new String[l.size()];
            String[] values = new String[l.size()];
            for (int i = 0; i < l.size(); i++) {
                Attribute a = l.get(i);
                keys[i] = a.getName();
                values[i] = a.getValue();
            }
            return JsonUtils.toJson(keys, values, false);
        }
        return element.getTextTrim();
    }
    return null;
}

From source file:org.jessma.logcutter.global.AppConfig.java

License:Apache License

@SuppressWarnings("unchecked")
private static void parseDelFiles(List<Element> dfs) {
    for (Element e : dfs) {
        long delFilesExpire = DEF_DEL_FILES_EXPIRE;

        // <delete-files.expire>
        Attribute exp = e.attribute("expire");
        if (exp != null) {
            delFilesExpire = str2Long(exp.getValue(), -1);
            if (delFilesExpire <= 0)
                delFilesExpire = DEF_DEL_FILES_EXPIRE;
        }//from  w ww  .  jav a  2  s.c  om

        // <file>
        List<Element> fs = e.elements("file");
        for (Element f : fs) {
            DelFilePath fp = new DelFilePath(delFilesExpire);

            parseFilePath(f, fp);
            delFiles.add(fp);
        }
    }
}

From source file:org.jessma.logcutter.global.AppConfig.java

License:Apache License

@SuppressWarnings("unchecked")
private static void parseCutFiles(List<Element> cfs) {
    for (Element e : cfs) {
        long cutFilesThreshold = DEF_CUT_FILES_THRESHOLD;
        long cutFilesReserve = DEF_CUT_FILES_RESERVE;

        // <cut-files.threshold>
        Attribute threshold = e.attribute("threshold");
        if (threshold != null) {
            cutFilesThreshold = str2Long(threshold.getValue(), -1);
            if (cutFilesThreshold <= 0)
                cutFilesThreshold = DEF_CUT_FILES_THRESHOLD;
        }//from   w w  w  . j  a  v a  2 s  . c o  m

        // <cut-files.reserve>
        Attribute reserve = e.attribute("reserve");
        if (reserve != null) {
            cutFilesReserve = str2Long(reserve.getValue(), -1);
            if (cutFilesReserve < 0)
                cutFilesReserve = DEF_CUT_FILES_RESERVE;
        }

        if (cutFilesThreshold <= cutFilesReserve)
            throw new RuntimeException("'cut-files.threshold' must greater then 'cut-files.reserve'");

        // <file>
        List<Element> fs = e.elements("file");
        for (Element f : fs) {
            CutFilePath fp = new CutFilePath(cutFilesThreshold, cutFilesReserve);

            parseFilePath(f, fp);
            cutFiles.add(fp);
        }
    }
}

From source file:org.jessma.logcutter.global.AppConfig.java

License:Apache License

@SuppressWarnings("unchecked")
private static void parseArcFiles(List<Element> afs) {
    for (Element e : afs) {
        long arcFilesExpire = DEF_ARC_FILES_EXPIRE;
        String arcPath = null;/*from   w ww .j  av a 2s. com*/

        // <archive-files.expire>
        Attribute exp = e.attribute("expire");
        if (exp != null) {
            arcFilesExpire = str2Long(exp.getValue(), -1);
            if (arcFilesExpire <= 0)
                arcFilesExpire = DEF_ARC_FILES_EXPIRE;
        }

        // <archive-files.archive-path>
        Attribute ap = e.attribute("archive-path");
        if (ap != null) {
            arcPath = ap.getValue();
            if (isStrEmpty(arcPath))
                throw new RuntimeException("'archive-files.archive-path' attribute must not empty");

            if (!arcPath.endsWith(File.separator))
                arcPath = arcPath + File.separator;
        } else
            throw new RuntimeException("'archive-files.archive-path' attribute must be set");

        // <file>
        List<Element> fs = e.elements("file");
        for (Element f : fs) {
            ArcFilePath fp = new ArcFilePath(arcFilesExpire, arcPath);

            parseFilePath(f, fp);
            arcFiles.add(fp);
        }
    }
}

From source file:org.jessma.logcutter.global.AppConfig.java

License:Apache License

private static void parseFilePath(Element file, FilePath fp) {
    Attribute p = file.attribute("path");

    if (p == null)
        throw new RuntimeException("'file' element must have 'path' attribute");

    String path = p.getValue();
    if (isStrEmpty(path))
        throw new RuntimeException("'file.path' attribute must not empty");

    if (!path.endsWith(File.separator))
        path = path + File.separator;

    String name = file.getTextTrim();
    if (isStrEmpty(name))
        throw new RuntimeException("'file' element must not empty");

    fp.setPath(path);//  w  ww. j a  va  2  s  .c o m
    fp.setName(name);
}