diff --git a/src/fr/devinsy/xidyn/presenters/DomPresenterCore.java b/src/fr/devinsy/xidyn/presenters/DomPresenterCore.java index 5ed6c7c..a239b73 100644 --- a/src/fr/devinsy/xidyn/presenters/DomPresenterCore.java +++ b/src/fr/devinsy/xidyn/presenters/DomPresenterCore.java @@ -171,56 +171,6 @@ public class DomPresenterCore return result; } - /** - * Get the text for an element. Converts new lines to spaces. - * - * @param node - * the node - * @return the element text - */ - private static String getElementText(final Node node) - { - String result; - - NodeList children = node.getChildNodes(); - if ((children == null) || (children.getLength() == 0)) - { - result = ""; - } - else - { - boolean ended = false; - result = ""; // Grrrr, Java ... - int childCounter = 0; - int childCount = children.getLength(); - while (!ended) - { - if (childCounter >= childCount) - { - ended = true; - result = ""; - } - else - { - Node child = children.item(childCounter); - if (child.getNodeType() == Node.TEXT_NODE) - { - // STU (+=, newLines...) - result = newLinesToSpaces(child.getNodeValue()); - ended = true; - } - else - { - childCounter += 1; - } - } - } - } - - // - return result; - } - /** * Merge attributes. * @@ -274,30 +224,6 @@ public class DomPresenterCore return result; } - /** - * Converts New Line characters to spaces. This is used when for example the - * text in a div tag goes over several lines. - * - * @param text - * String - * @return String - */ - private static String newLinesToSpaces(final String text) - { - StringBuffer result = new StringBuffer(text); - - for (int i = 0; i < result.length(); i++) - { - if (result.charAt(i) == '\n') - { - result.setCharAt(i, ' '); - } - } - - // - return (result.toString()); - } - /** * Process. * diff --git a/src/fr/devinsy/xidyn/utils/XidynUtils.java b/src/fr/devinsy/xidyn/utils/XidynUtils.java index 49f325d..f4f00c8 100644 --- a/src/fr/devinsy/xidyn/utils/XidynUtils.java +++ b/src/fr/devinsy/xidyn/utils/XidynUtils.java @@ -518,6 +518,56 @@ public class XidynUtils return result; } + /** + * Get the text for an element. Converts new lines to spaces. + * + * @param node + * the node + * @return the element text + */ + public static String getElementText(final Node node) + { + String result; + + NodeList children = node.getChildNodes(); + if ((children == null) || (children.getLength() == 0)) + { + result = ""; + } + else + { + boolean ended = false; + result = ""; // Grrrr, Java ... + int childCounter = 0; + int childCount = children.getLength(); + while (!ended) + { + if (childCounter >= childCount) + { + ended = true; + result = ""; + } + else + { + Node child = children.item(childCounter); + if (child.getNodeType() == Node.TEXT_NODE) + { + // STU (+=, newLines...) + result = newLinesToSpaces(child.getNodeValue()); + ended = true; + } + else + { + childCounter += 1; + } + } + } + } + + // + return result; + } + /** * Load. * @@ -661,6 +711,30 @@ public class XidynUtils return result; } + /** + * Converts New Line characters to spaces. This is used when for example the + * text in a div tag goes over several lines. + * + * @param text + * String + * @return String + */ + public static String newLinesToSpaces(final String text) + { + StringBuffer result = new StringBuffer(text); + + for (int letterIndex = 0; letterIndex < result.length(); letterIndex++) + { + if (result.charAt(letterIndex) == '\n') + { + result.setCharAt(letterIndex, ' '); + } + } + + // + return (result.toString()); + } + /** * Read. *