Example usage for org.dom4j Node getStringValue

List of usage examples for org.dom4j Node getStringValue

Introduction

In this page you can find the example usage for org.dom4j Node getStringValue.

Prototype

String getStringValue();

Source Link

Document

Returns the XPath string-value of this node.

Usage

From source file:gg.imports.GrisbiFile050.java

License:Open Source License

/**
 * Gets expected number of categories//w  w  w  .j a v a  2  s .co m
 * @return Expected number of categories
 * @throws ParsingException Expected number of categories not found
 * @throws NumberFormatException The expected number of categories is not numeric
 */
private int getExpectedNumberOfCategories() throws ParsingException, NumberFormatException {
    log.entering(this.getClass().getName(), "getExpectedNumberOfCategories");
    Node expectedNumberOfCategoriesNode = grisbiFileDocument
            .selectSingleNode("/Grisbi/Categories/Generalites/Nb_categories");
    if (expectedNumberOfCategoriesNode == null) {
        throw new ParsingException("The expected number of categories has not been found in the Grisbi file '"
                + pathToGrisbiFile + "'");
    }
    String expectedNumberOfCategoriesValue = expectedNumberOfCategoriesNode.getStringValue();
    assert (expectedNumberOfCategoriesValue != null);
    int expectedNumberOfCategories = Integer.parseInt(expectedNumberOfCategoriesValue);

    log.exiting(this.getClass().getName(), "getExpectedNumberOfCategories", expectedNumberOfCategories);
    return expectedNumberOfCategories;
}

From source file:gg.imports.GrisbiFile050.java

License:Open Source License

/**
 * Gets expected number of currencies//from  w  w  w  .  ja  va 2s  .c o m
 * @return Expected number of currencies
 * @throws ParsingException Expected number of currencies not found
 * @throws NumberFormatException The expected number of currencies is not numeric
 */
private int getExpectedNumberOfCurrencies() throws ParsingException, NumberFormatException {
    log.entering(this.getClass().getName(), "getExpectedNumberOfCurrencies");
    Node expectedNumberOfCurrenciesNode = grisbiFileDocument
            .selectSingleNode("/Grisbi/Devises/Generalites/Nb_devises");
    if (expectedNumberOfCurrenciesNode == null) {
        throw new ParsingException("The expected number of currencies has not been found in the Grisbi file '"
                + pathToGrisbiFile + "'");
    }
    String expectedNumberOfCurrenciesValue = expectedNumberOfCurrenciesNode.getStringValue();
    assert (expectedNumberOfCurrenciesValue != null);
    int expectedNumberOfCurrencies = Integer.parseInt(expectedNumberOfCurrenciesValue);

    log.exiting(this.getClass().getName(), "getExpectedNumberOfCurrencies", expectedNumberOfCurrencies);
    return expectedNumberOfCurrencies;
}

From source file:gg.imports.GrisbiFile050.java

License:Open Source License

/**
 * Gets expected number of transactions (for all accounts)
 * @return Expected number of transactions
 * @throws ParsingException Expected number of transactions not found
 * @throws NumberFormatException The expected number of transactions is not numeric
 *///from  w w w. j  a va 2  s . c o m
private int getExpectedNumberOfTransactions() throws ParsingException, NumberFormatException {
    log.entering(this.getClass().getName(), "getExpectedNumberOfTransactions");
    int expectedNumberOfTransactions = 0;

    List listOfAccounts = grisbiFileDocument.selectNodes("/Grisbi/Comptes/Compte");
    for (Object accountObject : listOfAccounts) {
        Node accountNode = (Node) accountObject;
        assert (accountNode != null);

        // Get the name of the current account
        Node accountNameNode = accountNode.selectSingleNode("Details/Nom");
        assert (accountNameNode != null);
        String accountName = accountNameNode.getStringValue();
        assert (accountName != null);

        // Get the expected number of transactions of the account
        Node expectedNumberOfTransactionsNode = accountNode.selectSingleNode("Details/Nb_operations");
        if (expectedNumberOfTransactionsNode == null) {
            throw new ParsingException(
                    "The expected number of transactions has not been found for the account '" + accountName
                            + "' in the Grisbi file '" + pathToGrisbiFile + "'");
        }
        String expectedNumberOfTransactionsValue = expectedNumberOfTransactionsNode.getStringValue();
        assert (expectedNumberOfTransactionsValue != null);
        int expectedNumberOfTransactionsForCurrentAccount = Integer.parseInt(expectedNumberOfTransactionsValue);

        expectedNumberOfTransactions += expectedNumberOfTransactionsForCurrentAccount;
    }

    log.exiting(this.getClass().getName(), "getExpectedNumberOfTransactions", expectedNumberOfTransactions);
    return expectedNumberOfTransactions;
}

From source file:gg.imports.GrisbiFile050.java

License:Open Source License

/**
 * Imports the accounts into the database<BR/>
 * The method <CODE>importCurrencies()</CODE> has to be called before
 * @throws ParsingException If there is a problem finding the needed nodes
 * @throws NumberFormatException If a string is read when a number is expected
 * @throws DateFormatException If the format of the date of the first transaction is invalid
 *//*from  w  w w  .j  a  v a  2  s  . c o  m*/
private void importAccounts() throws ParsingException, NumberFormatException, DateFormatException {
    log.entering(this.getClass().getName(), "importAccounts");
    long startImportingAccountsTime = System.currentTimeMillis();

    // Get all the currencies already saved in the database (the method importCurrencies() has to be called before)
    Map<Long, Currency> currencies = Datamodel.getCurrenciesWithId();

    // Import the accounts in the embedded database
    long numberOfImportedAccounts = 0;
    List listOfAccounts = grisbiFileDocument.selectNodes("/Grisbi/Comptes/Compte");
    Iterator accountsIterator = listOfAccounts.iterator();
    while (accountsIterator.hasNext() && !isImportCancelled()) {

        // Get the account node
        Node accountNode = (Node) accountsIterator.next();

        // Get the "Active" property of the account: is the account closed?
        Node accountActiveNode = accountNode.selectSingleNode("Details/Compte_cloture");
        assert (accountActiveNode != null);
        String accountActiveValue = accountActiveNode.getStringValue();
        assert (accountActiveValue != null);
        boolean accountActive = (accountActiveValue.compareTo("1") != 0);

        // Get the ID of the account
        Node accountIdNode = accountNode.selectSingleNode("Details/No_de_compte");
        assert (accountIdNode != null);
        String accountIdValue = accountIdNode.getStringValue();
        assert (accountIdValue != null);
        long accountId = Long.parseLong(accountIdValue);
        assert (accountId >= 0);

        // Get the name of the account
        Node accountNameNode = accountNode.selectSingleNode("Details/Nom");
        assert (accountNameNode != null);
        String accountName = accountNameNode.getStringValue();
        assert (accountName != null);

        // Get the currency of the account
        Node currencyIdNode = accountNode.selectSingleNode("Details/Devise");
        assert (currencyIdNode != null);
        String currencyIdValue = currencyIdNode.getStringValue();
        assert (currencyIdValue != null);
        long currencyId = Long.parseLong(currencyIdValue);
        assert (currencyId > 0);

        // Get the corresponding Currency object
        Currency accountCurrency = currencies.get(currencyId); // An account has always a currency in Grisbi
        assert (accountCurrency != null);

        // Activate the currency if needed
        if (accountActive && !accountCurrency.getActive()) {
            accountCurrency.setActive(true);
        }

        // Get the initial amount of the account
        Node accountInitialAmountNode = accountNode.selectSingleNode("Details/Solde_initial");
        assert (accountInitialAmountNode != null);
        String accountInitialAmountValue = accountInitialAmountNode.getStringValue();
        assert (accountInitialAmountValue != null);
        BigDecimal accountInitialAmount = new BigDecimal(accountInitialAmountValue.replace(',', '.'));
        accountInitialAmount = accountInitialAmount.setScale(2, RoundingMode.HALF_EVEN);

        // Get the current balance of the account
        Node accountBalanceNode = accountNode.selectSingleNode("Details/Solde_courant");
        assert (accountBalanceNode != null);
        String accountBalanceValue = accountBalanceNode.getStringValue();
        assert (accountBalanceValue != null);
        BigDecimal accountBalance = new BigDecimal(accountBalanceValue.replace(',', '.'));
        accountBalance = accountBalance.setScale(2, RoundingMode.HALF_EVEN);

        // Create a new account and save the account in the embedded database
        Account account = new Account(accountId, accountName, accountCurrency, accountInitialAmount,
                accountBalance, accountActive);
        Datamodel.saveAccount(account);

        // Update the currency's balance and the currency's initial amount
        if (accountActive) {
            accountCurrency.setBalance(accountCurrency.getBalance().add(accountBalance));
            accountCurrency.setInitialAmount(accountCurrency.getInitialAmount().add(accountInitialAmount));
        }

        numberOfImportedAccounts++;
    }

    // Update the currencies (active flag, balance, initial amount)
    for (Currency currency : currencies.values()) {
        Datamodel.saveCurrency(currency);
    }

    long endImportingAccountsTime = System.currentTimeMillis();
    log.info(numberOfImportedAccounts + " accounts have been successfully imported in "
            + (endImportingAccountsTime - startImportingAccountsTime) + " ms");
    log.exiting(this.getClass().getName(), "importAccounts");
}

From source file:gg.imports.GrisbiFile050.java

License:Open Source License

/**
 * Imports the transactions into the embedded database<BR/>
 * The methods <CODE>importCurrencies()</CODE>, <CODE>importPayees()</CODE>,
 * <CODE>importAccounts()</CODE>, and <CODE>importCategories()</CODE> have to be called before
 * @param p Progress handle for the progress bar
 * @throws ParsingException If there is a problem finding the needed nodes
 * @throws NumberFormatException If a string is read when a number is expected
 * @throws DateFormatException If the date format of a transaction is invalid
 *//*  w w w  . j  a va  2 s . co  m*/
private void importTransactions(ProgressHandle p)
        throws ParsingException, NumberFormatException, DateFormatException {
    log.entering(this.getClass().getName(), "importTransactions");
    long startImportingTotalTransactionsTime = System.currentTimeMillis();

    Map<Long, Account> accounts = Datamodel.getAccountsWithId();
    Map<Long, Payee> payees = Datamodel.getPayeesWithId();
    Map<GrisbiCategory, Category> categories = Datamodel.getCategoriesWithGrisbiCategory();
    Map<Long, Currency> currencies = Datamodel.getCurrenciesWithId();

    // Import the transactions from each account into the embedded database
    long totalNumberOfImportedTransactions = 0;
    List listOfAccounts = grisbiFileDocument.selectNodes("/Grisbi/Comptes/Compte");
    Iterator accountsIterator = listOfAccounts.iterator();
    while (accountsIterator.hasNext() && !isImportCancelled()) { // Go through the accounts
        long startImportingTransactionsTime = System.currentTimeMillis();

        // Get the account's node
        Node accountNode = (Node) accountsIterator.next();
        assert (accountNode != null);

        // Get the ID of the account
        Node accountIdNode = accountNode.selectSingleNode("Details/No_de_compte");
        assert (accountIdNode != null);
        String accountIdValue = accountIdNode.getStringValue();
        assert (accountIdValue != null);
        long accountId = Long.parseLong(accountIdValue);
        assert (accountId >= 0);

        // Get the name of the current account
        Node accountNameNode = accountNode.selectSingleNode("Details/Nom");
        assert (accountNameNode != null);
        String accountName = accountNameNode.getStringValue();
        assert (accountName != null);

        // Display on the progress bar the account from which transactions are imported
        p.progress("Importing transactions from " + accountName);

        // Get the corresponding Account object
        Account account = accounts.get(accountId);
        assert (account != null);

        // Get the expected number of transactions of the account
        Node expectedNumberOfTransactionsNode = accountNode.selectSingleNode("Details/Nb_operations");
        if (expectedNumberOfTransactionsNode == null) {
            throw new ParsingException(
                    "The expected number of transactions has not been found for the account '" + accountName
                            + "' in the Grisbi file '" + pathToGrisbiFile + "'");
        }
        String expectedNumberOfTransactionsValue = expectedNumberOfTransactionsNode.getStringValue();
        assert (expectedNumberOfTransactionsValue != null);
        int expectedNumberOfTransactions = Integer.parseInt(expectedNumberOfTransactionsValue);

        // Import the transactions of the account into the embedded database
        int numberOfImportedTransactions = 0;
        Map<Long, Transaction> transactions = new HashMap<Long, Transaction>(); // Map containing all the saved transactions - the key of the map is the transaction's ID
        List listOfTransactions = accountNode.selectNodes("Detail_des_operations/Operation");
        Iterator transactionsIterator = listOfTransactions.iterator();
        while (transactionsIterator.hasNext() && !isImportCancelled()) { // Go through the list of transactions of the account

            // Get the transaction node
            Node transactionNode = (Node) transactionsIterator.next();

            // Get the ID of the transaction
            assert (transactionNode != null);
            String transactionIdValue = transactionNode.valueOf("@No");
            assert (transactionIdValue != null);
            long transactionId = Long.parseLong(transactionIdValue);
            assert (transactionId > 0);

            // Get the date of the transaction
            String transactionDateValue = transactionNode.valueOf("@D");
            assert (transactionDateValue != null && transactionDateValue.compareTo("") != 0);
            // Get the date from the string
            LocalDate transactionDate = Period.getDate(transactionDateValue); // Throws a DateFormatException if the format of 'transactionDateValue' is not valid
            assert (transactionDate != null);

            // Get the exchange rate
            String exchangeRateValue = transactionNode.valueOf("@Tc");
            assert (exchangeRateValue != null);
            BigDecimal exchangeRate = new BigDecimal(exchangeRateValue.replace(',', '.')); // exchangeRate = 0 if there is no echange rate

            // Get the fees
            String feesValue = transactionNode.valueOf("@Fc");
            assert (feesValue != null);
            BigDecimal fees = new BigDecimal(feesValue.replace(',', '.'));

            // Get the amount of the transaction
            String transactionAmountValue = transactionNode.valueOf("@M");
            assert (transactionAmountValue != null);
            BigDecimal transactionAmount = new BigDecimal(transactionAmountValue.replace(',', '.'));

            // Get the currency of the transaction
            String transactionCurrencyIdValue = transactionNode.valueOf("@De");
            assert (transactionCurrencyIdValue != null);
            long transactionCurrencyId = Long.parseLong(transactionCurrencyIdValue); // Get the ID of the currency
            Currency transactionCurrency = currencies.get(transactionCurrencyId);
            assert (transactionCurrency != null);
            Currency accountCurrency = currencies.get(account.getCurrency().getId());
            assert (accountCurrency != null);

            // Update the amount of the transaction if the currency of the transaction is different from the currency of the account
            // (Method found in the Grisbi source file: devises.c/calcule_montant_devise_renvoi)
            if (transactionCurrency.getId().compareTo(accountCurrency.getId()) != 0) {
                if (accountCurrency.getEuroConversion()) {
                    if (transactionCurrency.getName().compareToIgnoreCase("euro") == 0) {
                        transactionAmount = transactionAmount.multiply(accountCurrency.getExchangeRate());
                    }
                } else if (accountCurrency.getEuroConversion()
                        && transactionCurrency.getName().compareToIgnoreCase("euro") != 0) {
                    transactionAmount = transactionAmount.divide(transactionCurrency.getExchangeRate(),
                            RoundingMode.HALF_EVEN);
                } else {
                    if (exchangeRate.compareTo(BigDecimal.ZERO) != 0) {
                        String transactionRdcValue = transactionNode.valueOf("@Rdc");
                        assert (transactionRdcValue != null);
                        long transactionRdc = Long.parseLong(transactionRdcValue);

                        if (transactionRdc == 1) {
                            transactionAmount = (transactionAmount.divide(exchangeRate, RoundingMode.HALF_EVEN))
                                    .subtract(fees);
                        } else {
                            transactionAmount = (transactionAmount.multiply(exchangeRate)).subtract(fees);
                        }
                    } else if (transactionCurrency.getExchangeRate().compareTo(BigDecimal.ZERO) != 0) {
                        if (transactionCurrency.getMultiply()) {
                            transactionAmount = (transactionAmount
                                    .multiply(transactionCurrency.getExchangeRate())).subtract(fees);
                        } else {
                            transactionAmount = (transactionAmount.divide(transactionCurrency.getExchangeRate(),
                                    RoundingMode.HALF_EVEN)).subtract(fees);
                        }
                    } else {
                        transactionAmount = new BigDecimal(0);
                    }
                }
            }
            transactionAmount = transactionAmount.setScale(2, RoundingMode.HALF_EVEN);

            // If the current transaction is a transfer:
            String twinTransaction = transactionNode.valueOf("@Ro"); // Twin transaction
            assert (twinTransaction != null);
            String accountOfTransfer = transactionNode.valueOf("@Rc"); // Account where the amount has been transfered (account of the twin transaction)
            assert (accountOfTransfer != null);

            // Is the current transaction a breakdown of transactions?
            String breakdownOfTransaction = transactionNode.valueOf("@Ov"); // breakdownOfTransaction = 1 if the current trasnsaction is a breakdown of transactions
            assert (breakdownOfTransaction != null);

            // Get the category and the sub-category of the transaction
            String transactionGrisbiCategoryIdValue = transactionNode.valueOf("@C"); // Get the category ID ('0' means that the category is not defined)
            assert (transactionGrisbiCategoryIdValue != null);
            long transactionGrisbiCategoryId = Long.parseLong(transactionGrisbiCategoryIdValue);
            assert (transactionGrisbiCategoryId >= 0);

            String transactionGrisbiSubCategoryIdValue = transactionNode.valueOf("@Sc"); // Get the sub-category ID ('0' means that the sub-category is not defined)
            assert (transactionGrisbiSubCategoryIdValue != null);
            long transactionGrisbiSubCategoryId = Long.parseLong(transactionGrisbiSubCategoryIdValue);
            assert (transactionGrisbiSubCategoryId >= 0);

            // Check if the category is "Transfer" or "Breakdown of transactions"
            Category transactionCategory = null;
            GrisbiCategory transactionGrisbiCategory = new GrisbiCategory(0, 0);
            if (transactionGrisbiCategoryId == 0
                    && (twinTransaction.compareTo("0") != 0 || accountOfTransfer.compareTo("0") != 0)) {
                // The current transaction is a transfer
                transactionCategory = Category.TRANSFER;
            } else if (transactionGrisbiCategoryId == 0 && breakdownOfTransaction.compareTo("1") == 0) {
                // The current transaction is a breakdown of transactions
                transactionCategory = Category.BREAKDOWN_OF_TRANSACTIONS;
            } else if (transactionGrisbiSubCategoryId != 0) {
                transactionGrisbiCategory.setCategoryId(transactionGrisbiCategoryId);
                transactionGrisbiCategory.setSubCategoryId(transactionGrisbiSubCategoryId);
                transactionCategory = categories.get(transactionGrisbiCategory);
                assert (transactionCategory != null);
            } else if (transactionGrisbiCategoryId != 0) {
                // Else, if a category is defined, get the category
                transactionGrisbiCategory.setCategoryId(transactionGrisbiCategoryId);
                transactionGrisbiCategory.setSubCategoryId(Category.NO_SUB_CATEGORY_ID);
                transactionCategory = categories.get(transactionGrisbiCategory);
                assert (transactionCategory != null);
            } else {
                // Else, no category is defined
                transactionCategory = Category.NO_CATEGORY;
            }
            assert (transactionCategory != null);

            // Get the comment of the transaction
            String transactionComment = transactionNode.valueOf("@N");
            assert (transactionComment != null);

            // Get the payee of the transaction
            String transactionPayeeIdValue = transactionNode.valueOf("@T"); // 'transactionPayeeIdValue' contains '0' if no payee is defined
            assert (transactionPayeeIdValue != null);
            long transactionPayeeId = Long.parseLong(transactionPayeeIdValue);
            assert (transactionPayeeId >= 0);
            Payee transactionPayee = null;
            if (transactionPayeeId != 0) { // Get the payee if it has been defined
                transactionPayee = payees.get(transactionPayeeId);
                assert (transactionPayee != null);
            } else { // No payee has been defined
                transactionPayee = Payee.NO_PAYEE;
            }

            // Get the parent transaction
            String transactionParentIdValue = transactionNode.valueOf("@Va"); // '0' means that the transaction is a top-transaction ; not '0' means that the transaction is a sub-transaction
            assert (transactionParentIdValue != null);
            long transactionParentId = Long.parseLong(transactionParentIdValue);
            assert (transactionParentId >= 0);
            Transaction transactionParent = null;
            if (transactionParentId != 0) {
                // Get the parent transaction
                transactionParent = transactions.get(transactionParentId); // 'transactionParentId' is the ID of the parent transaction (in Grisbi files, parent transactions are always BEFORE sub-transactions)
                assert (transactionParent != null);
            } else {
                // The current transaction has no parent transaction
                // The current transaction is a top transaction
                transactionParent = null;
            }

            // Create a new transaction and save the transaction in the embedded database
            Transaction transaction = new Transaction(transactionDate, account, transactionAmount,
                    transactionCategory, transactionComment, transactionPayee, transactionParent);
            Datamodel.saveTransaction(transaction);
            transactions.put(transactionId, transaction); // Save the transaction in the map, so that parent transactions can be found

            numberOfImportedTransactions++;
            p.progress(workUnit++);
        }

        // Make sure that the number of imported transactions and sub-transactions is the expected number
        if (!isImportCancelled() && numberOfImportedTransactions != expectedNumberOfTransactions) {
            throw new ParsingException("For the account '" + accountName
                    + "', the number of imported transactions (" + numberOfImportedTransactions
                    + ") is not equal to the expected number of transactions (" + expectedNumberOfTransactions
                    + ") in the Grisbi file '" + pathToGrisbiFile + "'");
        }

        long endImportingTransactionsTime = System.currentTimeMillis();
        log.info(numberOfImportedTransactions + " transactions have been successfully imported in the account '"
                + accountName + "' in " + (endImportingTransactionsTime - startImportingTransactionsTime)
                + " ms");
        totalNumberOfImportedTransactions += numberOfImportedTransactions;
    }

    long endImportingTotalTransactionsTime = System.currentTimeMillis();
    log.info(totalNumberOfImportedTransactions + " transactions have been successfully imported in "
            + (endImportingTotalTransactionsTime - startImportingTotalTransactionsTime) + " ms");
    log.exiting(this.getClass().getName(), "importTransactions");
}

From source file:hello.W2j.java

License:Apache License

private void getNextTrueSibling() {
    Node selectSingleNode = nextAutoTileElement.selectSingleNode("a/@href");
    String stringValue = selectSingleNode.getStringValue();
    if (stringValue.equals(domain))
        nextAutoTileElement = (DOMElement) nextAutoTileElement.getNextSibling();
}

From source file:hk.hku.cecid.piazza.commons.util.PropertyTree.java

License:Open Source License

/**
 * Gets a property with the specified xpath.
 * If the xpath refers to more than one properpty, the first one will be returned.
 * /* www.  j av  a 2  s  .c  o  m*/
 * @param xpath the property xpath.
 * @return the property with the specified xpath.
 * @see hk.hku.cecid.piazza.commons.util.PropertySheet#getProperty(java.lang.String)
 */
public String getProperty(String xpath) {
    Node node = getPropertyNode(xpath);
    return node == null ? null : StringUtilities.propertyValue(node.getStringValue());
}

From source file:hk.hku.cecid.piazza.commons.util.PropertyTree.java

License:Open Source License

/**
 * Gets a property with the specified xpath.
 * If the xpath refers to more than one properpty, the first one will be returned.
 * //w ww  . ja v a2  s.c o  m
 * @param xpath the property xpath.
 * @param def the default value.
 * @return the property with the specified xpath.
 * @see hk.hku.cecid.piazza.commons.util.PropertySheet#getProperty(java.lang.String,
 *      java.lang.String)
 */
public String getProperty(String xpath, String def) {
    Node node = getPropertyNode(xpath);
    return node == null ? def : StringUtilities.propertyValue(node.getStringValue());
}

From source file:hk.hku.cecid.piazza.commons.util.PropertyTree.java

License:Open Source License

/**
 * Creates a Properties object which stores the properties retrieved by the specified xpath.
 * //www. j av  a2 s . c o  m
 * @param xpath the properties xpath.
 * @return a Properties object which stores the retrieved properties.
 * @see hk.hku.cecid.piazza.commons.util.PropertySheet#createProperties(java.lang.String)
 */
public Properties createProperties(String xpath) {
    Properties newProps = new Properties();
    List nodes = getPropertyNodes(xpath);

    for (int i = 0; i < nodes.size(); i++) {
        Node node = (Node) nodes.get(i);

        String key = node.getName();
        int prefixIndex = key.indexOf(':');
        if (prefixIndex != -1) {
            key = key.substring(prefixIndex + 1);
        }

        String tmpkey = ((Element) node).attributeValue("name");
        String tmpvalue = ((Element) node).attributeValue("value");
        String tmptype = ((Element) node).attributeValue("type");
        String value = node.getStringValue();
        if (tmpkey != null) {
            key = tmpkey.trim();
        }
        if (tmpvalue != null) {
            value = tmpvalue;
        }
        if (tmptype != null) {
            String type = tmptype.trim();
            if (!"".equals(type)) {
                key = type + ":" + key;
            }
        }

        if (value != null) {
            newProps.setProperty(key, value);
        }
    }
    return newProps;
}

From source file:io.mashin.oep.hpdl.XMLReadUtils.java

License:Open Source License

public static String valueOf(Node node) {
    String value = "";
    if (node != null) {
        value = node.getStringValue();
    }/*from   ww w  .j a  v a 2s.c  o m*/
    return value == null ? "" : value;
}