Example usage for org.dom4j Element getText

List of usage examples for org.dom4j Element getText

Introduction

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

Prototype

String getText();

Source Link

Document

Returns the text value of this element without recursing through child elements.

Usage

From source file:com.hyron.poscafe.util.ConfigurationWithWildcard.java

License:Open Source License

private void addProperties(Element parent) {
    Properties props = new Properties();
    Iterator itr = parent.elementIterator("property");
    while (itr.hasNext()) {
        Element node = (Element) itr.next();
        String name = node.attributeValue("name");
        String value = node.getText().trim();
        log.debug(name + "=" + value);
        props.setProperty(name, value);// w w w  .java2s .  c o m
        if (!name.startsWith("hibernate")) {
            props.setProperty("hibernate." + name, value);
        }
    }
    addProperties(props);
    Environment.verifyProperties(getProperties());
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public Vector getDataItemExpressions() {
    Vector fullNameColumnsList = new Vector();
    List columnList = (List) oDocument.selectNodes("/report/queries/query/selection/dataItem/expression");

    for (int i = 0; i < columnList.size(); i++) {
        Element eColumn = (Element) columnList.get(i);
        String sColumn = eColumn.getText();
        fullNameColumnsList.add(sColumn);
    }//from   w  ww .  j a  va 2 s.c o m
    return fullNameColumnsList;
}

From source file:com.ibm.cognos.API.java

License:Open Source License

public Vector getColumnTitles() {
    Vector columnTitles = new Vector();

    // Check for column titles based on dataItemLabel
    List columnTitleList = (List) oDocument
            .selectNodes("/report/layouts/layout/reportPages/page/pageBody/contents/"
                    + "list/listColumns/listColumn/listColumnTitle/"
                    + "contents/textItem/dataSource/dataItemLabel");
    for (int i = 0; i < columnTitleList.size(); i++) {
        Element e = (Element) columnTitleList.get(i);
        String sColumnTitle = null;
        sColumnTitle = e.attributeValue(new QName("refDataItem"));
        columnTitles.add(sColumnTitle);//from  w  w  w  .  j  a  va 2s.c  o  m
    }

    // Check for columnTitles base on staticValue
    List columnStaticTitleList = (List) oDocument
            .selectNodes("/report/layouts/layout/reportPages/page/pageBody/contents/"
                    + "list/listColumns/listColumn/listColumnTitle/"
                    + "contents/textItem/dataSource/staticValue");
    for (int i = 0; i < columnStaticTitleList.size(); i++) {
        Element e = (Element) columnStaticTitleList.get(i);
        String sColumnTitle = null;
        sColumnTitle = e.getText();
        columnTitles.add(sColumnTitle);
    }
    return columnTitles;
}

From source file:com.iflytek.edu.cloud.frame.support.jdbc.CustomSQL.java

License:Apache License

protected void read(InputStream is) {

    if (is == null)
        return;//from   w  w  w  .  ja v  a  2 s .  c  om

    Document document;
    try {
        document = saxReader.read(is);
    } catch (DocumentException e) {
        throw new RuntimeException(e.getMessage(), e);
    }

    Element rootElement = document.getRootElement();

    for (Object sqlObj : rootElement.elements("sql")) {
        Element sqlElement = (Element) sqlObj;
        String id = sqlElement.attributeValue("id");
        String tempateType = sqlElement.attributeValue("tempateType");

        if ("simple".equals(tempateType) || "httl".equals(tempateType)) {
            String content = transform(sqlElement.getText());

            SQLBean bean = new SQLBean();
            bean.setTempateType(tempateType);
            bean.setContent(content);

            try {
                Template template = engine.parseTemplate(content);
                bean.setTemplate(template);
                _sqlPool.put(id, bean);
            } catch (ParseException e) {
                throw new RuntimeException(e.getMessage(), e);
            }
        } else {
            logger.warn("{}  tempateType  {} ??simplehttl", id,
                    tempateType);
        }
    }
}

From source file:com.iih5.smartorm.kit.SqlXmlKit.java

License:Apache License

private void init(File dataDir) {
    try {//from   w  w  w . j a  v a 2 s. c  om
        List<File> files = new ArrayList<File>();
        listDirectory(dataDir, files);
        for (File file : files) {
            if (file.getName().contains(".xml")) {
                SAXReader reader = new SAXReader();
                Document document = reader.read(file);
                Element xmlRoot = document.getRootElement();
                for (Object e : xmlRoot.elements("class")) {
                    Map<String, String> methods = new HashMap<String, String>();
                    Element clasz = (Element) e;
                    for (Object ebj : clasz.elements("sql")) {
                        Element sql = (Element) ebj;
                        methods.put(sql.attribute("method").getValue(), sql.getText());
                    }
                    resourcesMap.put(clasz.attributeValue("name"), methods);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.ischool.weixin.tool.MessageUtil.java

License:Open Source License

public static Map<String, String> parseXml(HttpServletRequest request) throws Exception {
    // ?HashMap//from  w w w  .  j  a v  a2  s  . c  o  m
    Map<String, String> map = new HashMap<String, String>();

    // request??
    InputStream inputStream = request.getInputStream();
    // ??
    SAXReader reader = new SAXReader();
    Document document = reader.read(inputStream);
    // xml
    Element root = document.getRootElement();
    // ?
    @SuppressWarnings("unchecked")
    List<Element> elementList = root.elements();

    // ???
    for (Element e : elementList) {
        map.put(e.getName(), e.getText());
    }
    // ?
    inputStream.close();
    inputStream = null;

    return map;
}

From source file:com.itfsw.mybatis.generator.plugins.utils.enhanced.TemplateCommentGenerator.java

License:Apache License

/**
 * //from   www. j  a  va 2 s .co m
 * @param templatePath ?
 * @param useForDefault Comment??
 */
public TemplateCommentGenerator(String templatePath, boolean useForDefault) {
    try {
        Document doc = null;
        if (useForDefault) {
            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath);
            doc = new SAXReader().read(inputStream);
            inputStream.close();
        } else {
            File file = new File(templatePath);
            if (file.exists()) {
                doc = new SAXReader().read(file);
            } else {
                logger.error("?:" + templatePath);
            }
        }

        // ??comment 
        if (doc != null) {
            for (EnumNode node : EnumNode.values()) {
                Element element = doc.getRootElement().elementByID(node.value());
                if (element != null) {
                    Configuration cfg = new Configuration(Configuration.VERSION_2_3_26);
                    // ?
                    Template template = new Template(node.value(), element.getText(), cfg);
                    templates.put(node, template);
                }
            }
        }
    } catch (Exception e) {
        logger.error("?XML??", e);
    }
}

From source file:com.jaspersoft.jasperserver.export.modules.auth.AuthorityImporter.java

License:Open Source License

protected void processRole(Element roleElement) {
    String roleName = roleElement.getText();
    String file = getRoleFile(roleName);
    RoleBean roleBean = (RoleBean) deserialize(configuration.getRolesDirName(), file,
            configuration.getSerializer());
    if (alreadyExists(roleBean)) {
        commandOut.warn("Role " + roleBean.getRoleName() + " already exists, skipping.");
    } else {/*  w  w  w  .ja  va2  s . c  om*/
        Role role = createRole(roleBean);
        saveRole(role);

        commandOut.info("Created role " + role.getRoleName());
    }
}

From source file:com.jaspersoft.jasperserver.export.modules.auth.AuthorityImporter.java

License:Open Source License

protected void processUser(Element userElement) {
    String username = userElement.getText();
    String file = getUserFile(username);
    UserBean userBean = (UserBean) deserialize(configuration.getUsersDirName(), file,
            configuration.getSerializer());

    if (!alreadyExists(userBean)) {
        User user = createUser(userBean);
        saveUser(user);//from   w ww  .ja  v a2 s .  co m
        saveUserAttributes(user, userBean.getAttributes());

        commandOut.info("Created user " + userBean.getUsername());
    } else if (update || (updateCoreUsers && isCoreUser(userBean))) {
        User user = createUser(userBean);
        updateUser(userBean.getUsername(), user);
        saveUserAttributes(user, userBean.getAttributes());

        commandOut.info("Updated user " + userBean.getUsername());

    } else {
        commandOut.warn("User " + userBean.getUsername() + " already exists, skipping.");
    }
}

From source file:com.jaspersoft.jasperserver.export.modules.logging.access.AccessEventsImporter.java

License:Open Source License

public List<String> process() {
    long count = 0;
    long reallyImported = 0;

    if (!hasParameter(includeAccessEvents)) {
        commandOut.info("Skip access events importing");
        return null;
    }/*from ww  w  .  j  a v a 2  s .c o  m*/
    for (Iterator it = indexElement.elementIterator(accessModuleConfiguration.getAccessEventIndexElement()); it
            .hasNext();) {
        Element accessEventElement = (Element) it.next();
        String countString = accessEventElement.getText();
        count = Long.valueOf(countString);
    }

    if (count > 0) {
        for (long i = 1; i <= count; i++) {
            boolean isSaved = process(String.valueOf(i));
            if (isSaved) {
                reallyImported++;
            }

            if (reallyImported % logAccessEventsInterval == 0) {
                commandOut.info("Next " + logAccessEventsInterval + " accessEvents has been imported");
            }

        }

        commandOut.info(reallyImported + " accessEvents has been imported successfully");
    }
    return null;
}