com.sun.org.apache.xml.internal.utils.XMLString Java Examples
The following examples show how to use
com.sun.org.apache.xml.internal.utils.XMLString.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FunctionDef1Arg.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Execute the first argument expression that is expected to return a * string. If the argument is null, then get the string value from the * current context node. * * @param xctxt Runtime XPath context. * * @return The string value of the first argument, or the string value of the * current context node if the first argument is null. * * @throws javax.xml.transform.TransformerException if an error occurs while * executing the argument expression. */ protected XMLString getArg0AsString(XPathContext xctxt) throws javax.xml.transform.TransformerException { if(null == m_arg0) { int currentNode = xctxt.getCurrentNode(); if(DTM.NULL == currentNode) return XString.EMPTYSTRING; else { DTM dtm = xctxt.getDTM(currentNode); return dtm.getStringValue(currentNode); } } else return m_arg0.execute(xctxt).xstr(); }
Example #2
Source File: XStringForFSB.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is a <code>String</code> object that represents * the same sequence of characters as this object. * * @param obj2 the object to compare this <code>String</code> * against. * * @return <code>true</code> if the <code>String </code>are equal; * <code>false</code> otherwise. * @see java.lang.String#compareTo(java.lang.String) * @see java.lang.String#equalsIgnoreCase(java.lang.String) */ public boolean equals(Object obj2) { if (null == obj2) return false; if(obj2 instanceof XNumber) return obj2.equals(this); // In order to handle the 'all' semantics of // nodeset comparisons, we always call the // nodeset function. else if (obj2 instanceof XNodeSet) return obj2.equals(this); else if (obj2 instanceof XStringForFSB) return equals((XMLString) obj2); else return equals(obj2.toString()); }
Example #3
Source File: XStringForFSB.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is a <code>String</code> object that represents * the same sequence of characters as this object. * * @param obj2 the object to compare this <code>String</code> * against. * * @return <code>true</code> if the <code>String </code>are equal; * <code>false</code> otherwise. * @see java.lang.String#compareTo(java.lang.String) * @see java.lang.String#equalsIgnoreCase(java.lang.String) */ public boolean equals(Object obj2) { if (null == obj2) return false; if(obj2 instanceof XNumber) return obj2.equals(this); // In order to handle the 'all' semantics of // nodeset comparisons, we always call the // nodeset function. else if (obj2 instanceof XNodeSet) return obj2.equals(this); else if (obj2 instanceof XStringForFSB) return equals((XMLString) obj2); else return equals(obj2.toString()); }
Example #4
Source File: FuncSum.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { DTMIterator nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode()); double sum = 0.0; int pos; while (DTM.NULL != (pos = nodes.nextNode())) { DTM dtm = nodes.getDTM(pos); XMLString s = dtm.getStringValue(pos); if (null != s) sum += s.toDouble(); } nodes.detach(); return new XNumber(sum); }
Example #5
Source File: FunctionDef1Arg.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Execute the first argument expression that is expected to return a * string. If the argument is null, then get the string value from the * current context node. * * @param xctxt Runtime XPath context. * * @return The string value of the first argument, or the string value of the * current context node if the first argument is null. * * @throws javax.xml.transform.TransformerException if an error occurs while * executing the argument expression. */ protected XMLString getArg0AsString(XPathContext xctxt) throws javax.xml.transform.TransformerException { if(null == m_arg0) { int currentNode = xctxt.getCurrentNode(); if(DTM.NULL == currentNode) return XString.EMPTYSTRING; else { DTM dtm = xctxt.getDTM(currentNode); return dtm.getStringValue(currentNode); } } else return m_arg0.execute(xctxt).xstr(); }
Example #6
Source File: XStringForFSB.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Returns a new string that is a substring of this string. The * substring begins at the specified <code>beginIndex</code> and * extends to the character at index <code>endIndex - 1</code>. * Thus the length of the substring is <code>endIndex-beginIndex</code>. * * @param beginIndex the beginning index, inclusive. * @param endIndex the ending index, exclusive. * @return the specified substring. * @exception IndexOutOfBoundsException if the * <code>beginIndex</code> is negative, or * <code>endIndex</code> is larger than the length of * this <code>String</code> object, or * <code>beginIndex</code> is larger than * <code>endIndex</code>. */ public XMLString substring(int beginIndex, int endIndex) { int len = endIndex - beginIndex; if (len > m_length) len = m_length; if (len <= 0) return XString.EMPTYSTRING; else { int start = m_start + beginIndex; return new XStringForFSB(fsb(), start, len); } }
Example #7
Source File: FunctionDef1Arg.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Execute the first argument expression that is expected to return a * string. If the argument is null, then get the string value from the * current context node. * * @param xctxt Runtime XPath context. * * @return The string value of the first argument, or the string value of the * current context node if the first argument is null. * * @throws javax.xml.transform.TransformerException if an error occurs while * executing the argument expression. */ protected XMLString getArg0AsString(XPathContext xctxt) throws javax.xml.transform.TransformerException { if(null == m_arg0) { int currentNode = xctxt.getCurrentNode(); if(DTM.NULL == currentNode) return XString.EMPTYSTRING; else { DTM dtm = xctxt.getDTM(currentNode); return dtm.getStringValue(currentNode); } } else return m_arg0.execute(xctxt).xstr(); }
Example #8
Source File: XStringForFSB.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is a <code>String</code> object that represents * the same sequence of characters as this object. * * @param obj2 the object to compare this <code>String</code> * against. * * @return <code>true</code> if the <code>String </code>are equal; * <code>false</code> otherwise. * @see java.lang.String#compareTo(java.lang.String) * @see java.lang.String#equalsIgnoreCase(java.lang.String) */ public boolean equals(Object obj2) { if (null == obj2) return false; if(obj2 instanceof XNumber) return obj2.equals(this); // In order to handle the 'all' semantics of // nodeset comparisons, we always call the // nodeset function. else if (obj2 instanceof XNodeSet) return obj2.equals(this); else if (obj2 instanceof XStringForFSB) return equals((XMLString) obj2); else return equals(obj2.toString()); }
Example #9
Source File: FuncSum.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { DTMIterator nodes = m_arg0.asIterator(xctxt, xctxt.getCurrentNode()); double sum = 0.0; int pos; while (DTM.NULL != (pos = nodes.nextNode())) { DTM dtm = nodes.getDTM(pos); XMLString s = dtm.getStringValue(pos); if (null != s) sum += s.toDouble(); } nodes.detach(); return new XNumber(sum); }
Example #10
Source File: DOM2DTM.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * Directly call the * characters method on the passed ContentHandler for the * string-value of the given node (see http://www.w3.org/TR/xpath#data-model * for the definition of a node's string-value). Multiple calls to the * ContentHandler's characters methods may well occur for a single call to * this method. * * @param nodeHandle The node ID. * @param ch A non-null reference to a ContentHandler. * * @throws org.xml.sax.SAXException */ public void dispatchCharactersEvents( int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException { if(normalize) { XMLString str = getStringValue(nodeHandle); str = str.fixWhiteSpace(true, true, false); str.dispatchCharactersEvents(ch); } else { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); dispatchNodeData(node, ch, 0); // Text coalition -- a DTM text node may represent multiple // DOM nodes. if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { while( null != (node=logicalNextDOMTextNode(node)) ) { dispatchNodeData(node, ch, 0); } } } }
Example #11
Source File: XRTreeFrag.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Cast result object to a number. * * @return The result tree fragment as a number or NaN */ public double num() throws javax.xml.transform.TransformerException { XMLString s = xstr(); return s.toDouble(); }
Example #12
Source File: XPathContext.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Get the value of a node as a string. * @param n Node to be converted to a string. May be null. * @return value of n as a string, or an empty string if n is null. */ public String toString(org.w3c.dom.Node n) { // %REVIEW% You can't get much uglier than this... int nodeHandle = getDTMHandleFromNode(n); DTM dtm = getDTM(nodeHandle); XMLString strVal = dtm.getStringValue(nodeHandle); return strVal.toString(); }
Example #13
Source File: XStringForFSB.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is a <code>String</code> object that represents * the same sequence of characters as this object. * * @param obj2 the object to compare this <code>String</code> * against. * * @return <code>true</code> if the <code>String </code>are equal; * <code>false</code> otherwise. * @see java.lang.String#compareTo(java.lang.String) * @see java.lang.String#equalsIgnoreCase(java.lang.String) */ public boolean equals(XMLString obj2) { if (this == obj2) { return true; } int n = m_length; if (n == obj2.length()) { FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { if (fsb.charAt(i) != obj2.charAt(j)) { return false; } i++; j++; } return true; } return false; }
Example #14
Source File: FuncSubstringAfter.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XMLString s1 = m_arg0.execute(xctxt).xstr(); XMLString s2 = m_arg1.execute(xctxt).xstr(); int index = s1.indexOf(s2); return (-1 == index) ? XString.EMPTYSTRING : (XString)s1.substring(index + s2.length()); }
Example #15
Source File: XString.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Convert a string to a double -- Allowed input is in fixed * notation ddd.fff. * * @return A double value representation of the string, or return Double.NaN * if the string can not be converted. */ public double toDouble() { /* XMLCharacterRecognizer.isWhiteSpace(char c) methods treats the following * characters as white space characters. * ht - horizontal tab, nl - newline , cr - carriage return and sp - space * trim() methods by default also takes care of these white space characters * So trim() method is used to remove leading and trailing white spaces. */ XMLString s = trim(); double result = Double.NaN; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c != '-' && c != '.' && ( c < 0X30 || c > 0x39)) { // The character is not a '-' or a '.' or a digit // then return NaN because something is wrong. return result; } } try { result = Double.parseDouble(s.toString()); } catch (NumberFormatException e){} return result; }
Example #16
Source File: XRTreeFrag.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Cast result object to a number. * * @return The result tree fragment as a number or NaN */ public double num() throws javax.xml.transform.TransformerException { XMLString s = xstr(); return s.toDouble(); }
Example #17
Source File: XStringForFSB.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Compares two strings lexicographically, ignoring case considerations. * This method returns an integer whose sign is that of * <code>this.toUpperCase().toLowerCase().compareTo( * str.toUpperCase().toLowerCase())</code>. * <p> * Note that this method does <em>not</em> take locale into account, * and will result in an unsatisfactory ordering for certain locales. * The java.text package provides <em>collators</em> to allow * locale-sensitive ordering. * * @param xstr the <code>String</code> to be compared. * * @return a negative integer, zero, or a positive integer as the * the specified String is greater than, equal to, or less * than this String, ignoring case considerations. * @see java.text.Collator#compare(String, String) * @since 1.2 */ public int compareToIgnoreCase(XMLString xstr) { int len1 = m_length; int len2 = xstr.length(); int n = Math.min(len1, len2); FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { char c1 = Character.toLowerCase(fsb.charAt(i)); char c2 = Character.toLowerCase(xstr.charAt(j)); if (c1 != c2) { return c1 - c2; } i++; j++; } return len1 - len2; }
Example #18
Source File: XStringForFSB.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Compares this string to the specified object. * The result is <code>true</code> if and only if the argument is not * <code>null</code> and is a <code>String</code> object that represents * the same sequence of characters as this object. * * @param obj2 the object to compare this <code>String</code> * against. * * @return <code>true</code> if the <code>String </code>are equal; * <code>false</code> otherwise. * @see java.lang.String#compareTo(java.lang.String) * @see java.lang.String#equalsIgnoreCase(java.lang.String) */ public boolean equals(XMLString obj2) { if (this == obj2) { return true; } int n = m_length; if (n == obj2.length()) { FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { if (fsb.charAt(i) != obj2.charAt(j)) { return false; } i++; j++; } return true; } return false; }
Example #19
Source File: XStringForFSB.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Tests if this string starts with the specified prefix beginning * a specified index. * * @param prefix the prefix. * @param toffset where to begin looking in the string. * @return <code>true</code> if the character sequence represented by the * argument is a prefix of the substring of this object starting * at index <code>toffset</code>; <code>false</code> otherwise. * The result is <code>false</code> if <code>toffset</code> is * negative or greater than the length of this * <code>String</code> object; otherwise the result is the same * as the result of the expression * <pre> * this.subString(toffset).startsWith(prefix) * </pre> * @exception java.lang.NullPointerException if <code>prefix</code> is * <code>null</code>. */ public boolean startsWith(XMLString prefix, int toffset) { FastStringBuffer fsb = fsb(); int to = m_start + toffset; int tlim = m_start + m_length; int po = 0; int pc = prefix.length(); // Note: toffset might be near -1>>>1. if ((toffset < 0) || (toffset > m_length - pc)) { return false; } while (--pc >= 0) { if (fsb.charAt(to) != prefix.charAt(po)) { return false; } to++; po++; } return true; }
Example #20
Source File: XString.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Tests if this string starts with the specified prefix beginning * a specified index. * * @param prefix the prefix. * @param toffset where to begin looking in the string. * @return <code>true</code> if the character sequence represented by the * argument is a prefix of the substring of this object starting * at index <code>toffset</code>; <code>false</code> otherwise. * The result is <code>false</code> if <code>toffset</code> is * negative or greater than the length of this * <code>String</code> object; otherwise the result is the same * as the result of the expression * <pre> * this.subString(toffset).startsWith(prefix) * </pre> * @exception java.lang.NullPointerException if <code>prefix</code> is * <code>null</code>. */ public boolean startsWith(XMLString prefix, int toffset) { int to = toffset; int tlim = this.length(); int po = 0; int pc = prefix.length(); // Note: toffset might be near -1>>>1. if ((toffset < 0) || (toffset > tlim - pc)) { return false; } while (--pc >= 0) { if (this.charAt(to) != prefix.charAt(po)) { return false; } to++; po++; } return true; }
Example #21
Source File: XStringForFSB.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Compares two strings lexicographically. * * @param xstr the <code>String</code> to be compared. * * @return the value <code>0</code> if the argument string is equal to * this string; a value less than <code>0</code> if this string * is lexicographically less than the string argument; and a * value greater than <code>0</code> if this string is * lexicographically greater than the string argument. * @exception java.lang.NullPointerException if <code>anotherString</code> * is <code>null</code>. */ public int compareTo(XMLString xstr) { int len1 = m_length; int len2 = xstr.length(); int n = Math.min(len1, len2); FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { char c1 = fsb.charAt(i); char c2 = xstr.charAt(j); if (c1 != c2) { return c1 - c2; } i++; j++; } return len1 - len2; }
Example #22
Source File: FuncSubstringAfter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Execute the function. The function must return * a valid object. * @param xctxt The current execution context. * @return A valid XObject. * * @throws javax.xml.transform.TransformerException */ public XObject execute(XPathContext xctxt) throws javax.xml.transform.TransformerException { XMLString s1 = m_arg0.execute(xctxt).xstr(); XMLString s2 = m_arg1.execute(xctxt).xstr(); int index = s1.indexOf(s2); return (-1 == index) ? XString.EMPTYSTRING : (XString)s1.substring(index + s2.length()); }
Example #23
Source File: XStringForFSB.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Compares two strings lexicographically. * * @param xstr the <code>String</code> to be compared. * * @return the value <code>0</code> if the argument string is equal to * this string; a value less than <code>0</code> if this string * is lexicographically less than the string argument; and a * value greater than <code>0</code> if this string is * lexicographically greater than the string argument. * @exception java.lang.NullPointerException if <code>anotherString</code> * is <code>null</code>. */ public int compareTo(XMLString xstr) { int len1 = m_length; int len2 = xstr.length(); int n = Math.min(len1, len2); FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { char c1 = fsb.charAt(i); char c2 = xstr.charAt(j); if (c1 != c2) { return c1 - c2; } i++; j++; } return len1 - len2; }
Example #24
Source File: AdaptiveResultTreeImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public XMLString getStringValue(int nodeHandle) { if (_dom != null) { return _dom.getStringValue(nodeHandle); } else { return super.getStringValue(nodeHandle); } }
Example #25
Source File: XStringForFSB.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Compares two strings lexicographically, ignoring case considerations. * This method returns an integer whose sign is that of * <code>this.toUpperCase().toLowerCase().compareTo( * str.toUpperCase().toLowerCase())</code>. * <p> * Note that this method does <em>not</em> take locale into account, * and will result in an unsatisfactory ordering for certain locales. * The java.text package provides <em>collators</em> to allow * locale-sensitive ordering. * * @param xstr the <code>String</code> to be compared. * * @return a negative integer, zero, or a positive integer as the * the specified String is greater than, equal to, or less * than this String, ignoring case considerations. * @see java.text.Collator#compare(String, String) * @since 1.2 */ public int compareToIgnoreCase(XMLString xstr) { int len1 = m_length; int len2 = xstr.length(); int n = Math.min(len1, len2); FastStringBuffer fsb = fsb(); int i = m_start; int j = 0; while (n-- != 0) { char c1 = Character.toLowerCase(fsb.charAt(i)); char c2 = Character.toLowerCase(xstr.charAt(j)); if (c1 != c2) { return c1 - c2; } i++; j++; } return len1 - len2; }
Example #26
Source File: DOM2DTM.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Directly call the * characters method on the passed ContentHandler for the * string-value of the given node (see http://www.w3.org/TR/xpath#data-model * for the definition of a node's string-value). Multiple calls to the * ContentHandler's characters methods may well occur for a single call to * this method. * * @param nodeHandle The node ID. * @param ch A non-null reference to a ContentHandler. * * @throws org.xml.sax.SAXException */ public void dispatchCharactersEvents( int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException { if(normalize) { XMLString str = getStringValue(nodeHandle); str = str.fixWhiteSpace(true, true, false); str.dispatchCharactersEvents(ch); } else { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); dispatchNodeData(node, ch, 0); // Text coalition -- a DTM text node may represent multiple // DOM nodes. if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { while( null != (node=logicalNextDOMTextNode(node)) ) { dispatchNodeData(node, ch, 0); } } } }
Example #27
Source File: XStringForFSB.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Tests if this string starts with the specified prefix beginning * a specified index. * * @param prefix the prefix. * @param toffset where to begin looking in the string. * @return <code>true</code> if the character sequence represented by the * argument is a prefix of the substring of this object starting * at index <code>toffset</code>; <code>false</code> otherwise. * The result is <code>false</code> if <code>toffset</code> is * negative or greater than the length of this * <code>String</code> object; otherwise the result is the same * as the result of the expression * <pre> * this.subString(toffset).startsWith(prefix) * </pre> * @exception java.lang.NullPointerException if <code>prefix</code> is * <code>null</code>. */ public boolean startsWith(XMLString prefix, int toffset) { FastStringBuffer fsb = fsb(); int to = m_start + toffset; int tlim = m_start + m_length; int po = 0; int pc = prefix.length(); // Note: toffset might be near -1>>>1. if ((toffset < 0) || (toffset > m_length - pc)) { return false; } while (--pc >= 0) { if (fsb.charAt(to) != prefix.charAt(po)) { return false; } to++; po++; } return true; }
Example #28
Source File: XNodeSet.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Get the string conversion from a single node. * * @param n Node to convert * * @return the string conversion from a single node. */ public XMLString getStringFromNode(int n) { // %OPT% // I guess we'll have to get a static instance of the DTM manager... if(DTM.NULL != n) { return m_dtmMgr.getDTM(n).getStringValue(n); } else { return com.sun.org.apache.xpath.internal.objects.XString.EMPTYSTRING; } }
Example #29
Source File: DOM2DTM.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Directly call the * characters method on the passed ContentHandler for the * string-value of the given node (see http://www.w3.org/TR/xpath#data-model * for the definition of a node's string-value). Multiple calls to the * ContentHandler's characters methods may well occur for a single call to * this method. * * @param nodeHandle The node ID. * @param ch A non-null reference to a ContentHandler. * * @throws org.xml.sax.SAXException */ public void dispatchCharactersEvents( int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException { if(normalize) { XMLString str = getStringValue(nodeHandle); str = str.fixWhiteSpace(true, true, false); str.dispatchCharactersEvents(ch); } else { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); dispatchNodeData(node, ch, 0); // Text coalition -- a DTM text node may represent multiple // DOM nodes. if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { while( null != (node=logicalNextDOMTextNode(node)) ) { dispatchNodeData(node, ch, 0); } } } }
Example #30
Source File: DOM2DTM.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Directly call the * characters method on the passed ContentHandler for the * string-value of the given node (see http://www.w3.org/TR/xpath#data-model * for the definition of a node's string-value). Multiple calls to the * ContentHandler's characters methods may well occur for a single call to * this method. * * @param nodeHandle The node ID. * @param ch A non-null reference to a ContentHandler. * * @throws org.xml.sax.SAXException */ public void dispatchCharactersEvents( int nodeHandle, org.xml.sax.ContentHandler ch, boolean normalize) throws org.xml.sax.SAXException { if(normalize) { XMLString str = getStringValue(nodeHandle); str = str.fixWhiteSpace(true, true, false); str.dispatchCharactersEvents(ch); } else { int type = getNodeType(nodeHandle); Node node = getNode(nodeHandle); dispatchNodeData(node, ch, 0); // Text coalition -- a DTM text node may represent multiple // DOM nodes. if(TEXT_NODE == type || CDATA_SECTION_NODE == type) { while( null != (node=logicalNextDOMTextNode(node)) ) { dispatchNodeData(node, ch, 0); } } } }