You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/05/14 20:59:16 UTC
svn commit: r1743860 - in
/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer:
EncodingInfo.java Encodings.java ToStream.java
Author: veithen
Date: Sat May 14 20:59:16 2016
New Revision: 1743860
URL: http://svn.apache.org/viewvc?rev=1743860&view=rev
Log:
Remove unused code.
Modified:
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/EncodingInfo.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Encodings.java
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/EncodingInfo.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/EncodingInfo.java?rev=1743860&r1=1743859&r2=1743860&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/EncodingInfo.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/EncodingInfo.java Sat May 14 20:59:16 2016
@@ -61,21 +61,6 @@ public final class EncodingInfo extends
{
/**
- * Not all characters in an encoding are in on contiguous group,
- * however there is a lowest contiguous group starting at '\u0001'
- * and working up to m_highCharInContiguousGroup.
- * <p>
- * This is the char for which chars at or below this value are
- * definately in the encoding, although for chars
- * above this point they might be in the encoding.
- * This exists for performance, especially for ASCII characters
- * because for ASCII all chars in the range '\u0001' to '\u007F'
- * are in the encoding.
- *
- */
- private final char m_highCharInContiguousGroup;
-
- /**
* The ISO encoding name.
*/
final String name;
@@ -86,55 +71,6 @@ public final class EncodingInfo extends
final String javaName;
/**
- * A helper object that we can ask if a
- * single char, or a surrogate UTF-16 pair
- * of chars that form a single character,
- * is in this encoding.
- */
- private InEncoding m_encoding;
-
- /**
- * This is not a public API. It returns true if the
- * char in question is in the encoding.
- * @param ch the char in question.
- * <p>
- * This method is not a public API.
- * @xsl.usage internal
- */
- public boolean isInEncoding(char ch) {
- if (m_encoding == null) {
- m_encoding = new EncodingImpl();
-
- // One could put alternate logic in here to
- // instantiate another object that implements the
- // InEncoding interface. For example if the JRE is 1.4 or up
- // we could have an object that uses JRE 1.4 methods
- }
- return m_encoding.isInEncoding(ch);
- }
-
- /**
- * This is not a public API. It returns true if the
- * character formed by the high/low pair is in the encoding.
- * @param high a char that the a high char of a high/low surrogate pair.
- * @param low a char that is the low char of a high/low surrogate pair.
- * <p>
- * This method is not a public API.
- * @xsl.usage internal
- */
- public boolean isInEncoding(char high, char low) {
- if (m_encoding == null) {
- m_encoding = new EncodingImpl();
-
- // One could put alternate logic in here to
- // instantiate another object that implements the
- // InEncoding interface. For example if the JRE is 1.4 or up
- // we could have an object that uses JRE 1.4 methods
- }
- return m_encoding.isInEncoding(high, low);
- }
-
- /**
* Create an EncodingInfo object based on the ISO name and Java name.
* If both parameters are null any character will be considered to
* be in the encoding. This is useful for when the serializer is in
@@ -151,412 +87,6 @@ public final class EncodingInfo extends
this.name = name;
this.javaName = javaName;
- this.m_highCharInContiguousGroup = highChar;
- }
-
-
-
- /**
- * A simple interface to isolate the implementation.
- * We could also use some new JRE 1.4 methods in another implementation
- * provided we use reflection with them.
- * <p>
- * This interface is not a public API,
- * and should only be used internally within the serializer.
- * @xsl.usage internal
- */
- private interface InEncoding {
- /**
- * Returns true if the char is in the encoding
- */
- public boolean isInEncoding(char ch);
- /**
- * Returns true if the high/low surrogate pair forms
- * a character that is in the encoding.
- */
- public boolean isInEncoding(char high, char low);
- }
-
- /**
- * This class implements the
- */
- private class EncodingImpl implements InEncoding {
-
-
-
- public boolean isInEncoding(char ch1) {
- final boolean ret;
- int codePoint = Encodings.toCodePoint(ch1);
- if (codePoint < m_explFirst) {
- // The unicode value is before the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_before object to delegate to, make one.
- if (m_before == null)
- m_before =
- new EncodingImpl(
- m_encoding,
- m_first,
- m_explFirst - 1,
- codePoint);
- ret = m_before.isInEncoding(ch1);
- } else if (m_explLast < codePoint) {
- // The unicode value is after the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_after object to delegate to, make one.
- if (m_after == null)
- m_after =
- new EncodingImpl(
- m_encoding,
- m_explLast + 1,
- m_last,
- codePoint);
- ret = m_after.isInEncoding(ch1);
- } else {
- // The unicode value is in the range we explitly handle
- final int idx = codePoint - m_explFirst;
-
- // If we already know the answer, just return it.
- if (m_alreadyKnown[idx])
- ret = m_isInEncoding[idx];
- else {
- // We don't know the answer, so find out,
- // which may be expensive, then cache the answer
- ret = inEncoding(ch1, m_encoding);
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = ret;
- }
- }
- return ret;
- }
-
- public boolean isInEncoding(char high, char low) {
- final boolean ret;
- int codePoint = Encodings.toCodePoint(high,low);
- if (codePoint < m_explFirst) {
- // The unicode value is before the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_before object to delegate to, make one.
- if (m_before == null)
- m_before =
- new EncodingImpl(
- m_encoding,
- m_first,
- m_explFirst - 1,
- codePoint);
- ret = m_before.isInEncoding(high,low);
- } else if (m_explLast < codePoint) {
- // The unicode value is after the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_after object to delegate to, make one.
- if (m_after == null)
- m_after =
- new EncodingImpl(
- m_encoding,
- m_explLast + 1,
- m_last,
- codePoint);
- ret = m_after.isInEncoding(high,low);
- } else {
- // The unicode value is in the range we explitly handle
- final int idx = codePoint - m_explFirst;
-
- // If we already know the answer, just return it.
- if (m_alreadyKnown[idx])
- ret = m_isInEncoding[idx];
- else {
- // We don't know the answer, so find out,
- // which may be expensive, then cache the answer
- ret = inEncoding(high, low, m_encoding);
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = ret;
- }
- }
- return ret;
- }
-
- /**
- * The encoding.
- */
- final private String m_encoding;
- /**
- * m_first through m_last is the range of unicode
- * values that this object will return an answer on.
- * It may delegate to a similar object with a different
- * range
- */
- final private int m_first;
-
- /**
- * m_explFirst through m_explLast is the range of unicode
- * value that this object handles explicitly and does not
- * delegate to a similar object.
- */
- final private int m_explFirst;
- final private int m_explLast;
- final private int m_last;
-
- /**
- * The object, of the same type as this one,
- * that handles unicode values in a range before
- * the range explictly handled by this object, and
- * to which this object may delegate.
- */
- private InEncoding m_before;
- /**
- * The object, of the same type as this one,
- * that handles unicode values in a range after
- * the range explictly handled by this object, and
- * to which this object may delegate.
- */
- private InEncoding m_after;
-
- /**
- * The number of unicode values explicitly handled
- * by a single EncodingInfo object. This value is
- * tuneable, but is set to 128 because that covers the
- * entire low range of ASCII type chars within a single
- * object.
- */
- private static final int RANGE = 128;
-
- /**
- * A flag to record if we already know the answer
- * for the given unicode value.
- */
- final private boolean m_alreadyKnown[] = new boolean[RANGE];
- /**
- * A table holding the answer on whether the given unicode
- * value is in the encoding.
- */
- final private boolean m_isInEncoding[] = new boolean[RANGE];
-
- private EncodingImpl() {
- // This object will answer whether any unicode value
- // is in the encoding, it handles values 0 through Integer.MAX_VALUE
- this(javaName, 0, Integer.MAX_VALUE, (char) 0);
- }
-
- private EncodingImpl(String encoding, int first, int last, int codePoint) {
- // Set the range of unicode values that this object manages
- // either explicitly or implicitly.
- m_first = first;
- m_last = last;
-
- // Set the range of unicode values that this object
- // explicitly manages
- m_explFirst = codePoint;
- m_explLast = codePoint + (RANGE-1);
-
- m_encoding = encoding;
-
- if (javaName != null)
- {
- // Some optimization.
- if (0 <= m_explFirst && m_explFirst <= 127) {
- // This particular EncodingImpl explicitly handles
- // characters in the low range.
- if ("UTF8".equals(javaName)
- || "UTF-16".equals(javaName)
- || "ASCII".equals(javaName)
- || "US-ASCII".equals(javaName)
- || "Unicode".equals(javaName)
- || "UNICODE".equals(javaName)
- || javaName.startsWith("ISO8859")) {
-
- // Not only does this EncodingImpl object explicitly
- // handle chracters in the low range, it is
- // also one that we know something about, without
- // needing to call inEncoding(char ch, String encoding)
- // for this low range
- //
- // By initializing the table ahead of time
- // for these low values, we prevent the expensive
- // inEncoding(char ch, String encoding)
- // from being called, at least for these common
- // encodings.
- for (int unicode = 1; unicode < 127; unicode++) {
- final int idx = unicode - m_explFirst;
- if (0 <= idx && idx < RANGE) {
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = true;
- }
- }
- }
- }
-
- /* A little bit more than optimization.
- *
- * We will say that any character is in the encoding if
- * we don't have an encoding.
- * This is meaningful when the serializer is being used
- * in temporary output state, where we are not writing to
- * the final output tree. It is when writing to the
- * final output tree that we need to worry about the output
- * encoding
- */
- if (javaName == null) {
- for (int idx = 0; idx < m_alreadyKnown.length; idx++) {
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = true;
- }
- }
- }
- }
- }
-
- /**
- * This is heart of the code that determines if a given character
- * is in the given encoding. This method is probably expensive,
- * and the answer should be cached.
- * <p>
- * This method is not a public API,
- * and should only be used internally within the serializer.
- * @param ch the char in question, that is not a high char of
- * a high/low surrogate pair.
- * @param encoding the Java name of the enocding.
- *
- * @xsl.usage internal
- *
- */
- private static boolean inEncoding(char ch, String encoding) {
- boolean isInEncoding;
- try {
- char cArray[] = new char[1];
- cArray[0] = ch;
- // Construct a String from the char
- String s = new String(cArray);
- // Encode the String into a sequence of bytes
- // using the given, named charset.
- byte[] bArray = s.getBytes(encoding);
- isInEncoding = inEncoding(ch, bArray);
-
- } catch (Exception e) {
- isInEncoding = false;
-
- // If for some reason the encoding is null, e.g.
- // for a temporary result tree, we should just
- // say that every character is in the encoding.
- if (encoding == null)
- isInEncoding = true;
- }
- return isInEncoding;
- }
-
- /**
- * This is heart of the code that determines if a given high/low
- * surrogate pair forms a character that is in the given encoding.
- * This method is probably expensive, and the answer should be cached.
- * <p>
- * This method is not a public API,
- * and should only be used internally within the serializer.
- * @param high the high char of
- * a high/low surrogate pair.
- * @param low the low char of a high/low surrogate pair.
- * @param encoding the Java name of the encoding.
- *
- * @xsl.usage internal
- *
- */
- private static boolean inEncoding(char high, char low, String encoding) {
- boolean isInEncoding;
- try {
- char cArray[] = new char[2];
- cArray[0] = high;
- cArray[1] = low;
- // Construct a String from the char
- String s = new String(cArray);
- // Encode the String into a sequence of bytes
- // using the given, named charset.
- byte[] bArray = s.getBytes(encoding);
- isInEncoding = inEncoding(high,bArray);
- } catch (Exception e) {
- isInEncoding = false;
- }
-
- return isInEncoding;
- }
-
- /**
- * This method is the core of determining if character
- * is in the encoding. The method is not foolproof, because
- * s.getBytes(encoding) has specified behavior only if the
- * characters are in the specified encoding. However this
- * method tries it's best.
- * @param ch the char that was converted using getBytes, or
- * the first char of a high/low pair that was converted.
- * @param data the bytes written out by the call to s.getBytes(encoding);
- * @return true if the character is in the encoding.
- */
- private static boolean inEncoding(char ch, byte[] data) {
- final boolean isInEncoding;
- // If the string written out as data is not in the encoding,
- // the output is not specified according to the documentation
- // on the String.getBytes(encoding) method,
- // but we do our best here.
- if (data==null || data.length == 0) {
- isInEncoding = false;
- }
- else {
- if (data[0] == 0)
- isInEncoding = false;
- else if (data[0] == '?' && ch != '?')
- isInEncoding = false;
- /*
- * else if (isJapanese) {
- * // isJapanese is really
- * // ( "EUC-JP".equals(javaName)
- * // || "EUC_JP".equals(javaName)
- * // || "SJIS".equals(javaName) )
- *
- * // Work around some bugs in JRE for Japanese
- * if(data[0] == 0x21)
- * isInEncoding = false;
- * else if (ch == 0xA5)
- * isInEncoding = false;
- * else
- * isInEncoding = true;
- * }
- */
-
- else {
- // We don't know for sure, but it looks like it is in the encoding
- isInEncoding = true;
- }
- }
- return isInEncoding;
- }
-
- /**
- * This method exists for performance reasons.
- * <p>
- * Except for '\u0000', if a char is less than or equal to the value
- * returned by this method then it in the encoding.
- * <p>
- * The characters in an encoding are not contiguous, however
- * there is a lowest group of chars starting at '\u0001' upto and
- * including the char returned by this method that are all in the encoding.
- * So the char returned by this method essentially defines the lowest
- * contiguous group.
- * <p>
- * chars above the value returned might be in the encoding, but
- * chars at or below the value returned are definately in the encoding.
- * <p>
- * In any case however, the isInEncoding(char) method can be used
- * regardless of the value of the char returned by this method.
- * <p>
- * If the value returned is '\u0000' it means that every character must be tested
- * with an isInEncoding method {@link #isInEncoding(char)} or {@link #isInEncoding(char, char)}
- * for surrogate pairs.
- * <p>
- * This method is not a public API.
- * @xsl.usage internal
- */
- public final char getHighChar() {
- return m_highCharInContiguousGroup;
}
}
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Encodings.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Encodings.java?rev=1743860&r1=1743859&r2=1743860&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Encodings.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Encodings.java Sat May 14 20:59:16 2016
@@ -458,37 +458,6 @@ public final class Encodings extends Obj
return codePoint;
}
- /**
- * Characters with values at or below the high code point are
- * in the encoding. Code point values above this one may or may
- * not be in the encoding, but lower ones certainly are.
- * <p>
- * This is for performance.
- *
- * @param encoding The encoding
- * @return The code point for which characters at or below this code point
- * are in the encoding. Characters with higher code point may or may not be
- * in the encoding. A value of zero is returned if the high code point is unknown.
- * <p>
- * This method is not a public API.
- * @xsl.usage internal
- */
- static public char getHighChar(String encoding)
- {
- final char highCodePoint;
- EncodingInfo ei;
-
- String normalizedEncoding = toUpperCaseFast(encoding);
- ei = (EncodingInfo) _encodingTableKeyJava.get(normalizedEncoding);
- if (ei == null)
- ei = (EncodingInfo) _encodingTableKeyMime.get(normalizedEncoding);
- if (ei != null)
- highCodePoint = ei.getHighChar();
- else
- highCodePoint = 0;
- return highCodePoint;
- }
-
private static final Hashtable _encodingTableKeyJava = new Hashtable();
private static final Hashtable _encodingTableKeyMime = new Hashtable();
private static final EncodingInfo[] _encodings = loadEncodingInfo();
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java?rev=1743860&r1=1743859&r2=1743860&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/ToStream.java Sat May 14 20:59:16 2016
@@ -614,160 +614,6 @@ abstract public class ToStream extends S
}
/**
- * Tell if this character can be written without escaping.
- */
- protected boolean escapingNotNeeded(char ch)
- {
- final boolean ret;
- if (ch < 127)
- {
- // This is the old/fast code here, but is this
- // correct for all encodings?
- if (ch >= CharInfo.S_SPACE || (CharInfo.S_LINEFEED == ch ||
- CharInfo.S_CARRIAGERETURN == ch || CharInfo.S_HORIZONAL_TAB == ch))
- ret= true;
- else
- ret = false;
- }
- else {
- ret = m_encodingInfo.isInEncoding(ch);
- }
- return ret;
- }
-
- /**
- * Once a surrogate has been detected, write out the pair of
- * characters if it is in the encoding, or if there is no
- * encoding, otherwise write out an entity reference
- * of the value of the unicode code point of the character
- * represented by the high/low surrogate pair.
- * <p>
- * An exception is thrown if there is no low surrogate in the pair,
- * because the array ends unexpectely, or if the low char is there
- * but its value is such that it is not a low surrogate.
- *
- * @param c the first (high) part of the surrogate, which
- * must be confirmed before calling this method.
- * @param ch Character array.
- * @param i position Where the surrogate was detected.
- * @param end The end index of the significant characters.
- * @return 0 if the pair of characters was written out as-is,
- * the unicode code point of the character represented by
- * the surrogate pair if an entity reference with that value
- * was written out.
- *
- * @throws IOException
- * @throws StreamException if invalid UTF-16 surrogate detected.
- */
- protected int writeUTF16Surrogate(char c, char ch[], int i, int end)
- throws IOException
- {
- int codePoint = 0;
- if (i + 1 >= end)
- {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] { Integer.toHexString((int) c)}));
- }
-
- final char high = c;
- final char low = ch[i+1];
- if (!Encodings.isLowUTF16Surrogate(low)) {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] {
- Integer.toHexString((int) c)
- + " "
- + Integer.toHexString(low)}));
- }
-
- final XmlWriter writer = m_writer;
-
- // If we make it to here we have a valid high, low surrogate pair
- if (m_encodingInfo.isInEncoding(c,low)) {
- // If the character formed by the surrogate pair
- // is in the encoding, so just write it out
- writer.write(ch,i,2);
- }
- else {
- // Don't know what to do with this char, it is
- // not in the encoding and not a high char in
- // a surrogate pair, so write out as an entity ref
- final String encoding = getEncoding();
- if (encoding != null) {
- /* The output encoding is known,
- * so somthing is wrong.
- */
- codePoint = Encodings.toCodePoint(high, low);
- // not in the encoding, so write out a character reference
- writer.writeCharacterReference(codePoint);
- } else {
- /* The output encoding is not known,
- * so just write it out as-is.
- */
- writer.write(ch, i, 2);
- }
- }
- // non-zero only if character reference was written out.
- return codePoint;
- }
-
- /**
- * Handle one of the default entities, return false if it
- * is not a default entity.
- *
- * @param ch character to be escaped.
- * @param i index into character array.
- * @param chars non-null reference to character array.
- * @param len length of chars.
- * @param fromTextNode true if the characters being processed
- * are from a text node, false if they are from an attribute value
- * @param escLF true if the linefeed should be escaped.
- *
- * @return i+1 if the character was written, else i.
- *
- * @throws java.io.IOException
- */
- int accumDefaultEntity(
- XmlWriter writer,
- char ch,
- int i,
- char[] chars,
- int len,
- boolean fromTextNode,
- boolean escLF)
- throws IOException
- {
-
- if (!escLF && CharInfo.S_LINEFEED == ch)
- {
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- else
- {
- // if this is text node character and a special one of those,
- // or if this is a character from attribute value and a special one of those
- if ((fromTextNode && m_charInfo.shouldMapTextChar(ch)) || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch)))
- {
- String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
-
- if (null != outputStringForChar)
- {
- writer.write(outputStringForChar);
- }
- else
- return i;
- }
- else
- return i;
- }
-
- return i + 1;
-
- }
- /**
* Receive notification of character data.
*
* <p>The Parser will call this method to report each chunk of
@@ -1075,107 +921,6 @@ abstract public class ToStream extends S
}
/**
- * Escape and writer.write a character.
- *
- * @param ch character to be escaped.
- * @param i index into character array.
- * @param chars non-null reference to character array.
- * @param len length of chars.
- * @param fromTextNode true if the characters being processed are
- * from a text node, false if the characters being processed are from
- * an attribute value.
- * @param escLF true if the linefeed should be escaped.
- *
- * @return i+1 if a character was written, i+2 if two characters
- * were written out, else return i.
- *
- * @throws StreamException
- */
- private int accumDefaultEscape(
- XmlWriter writer,
- char ch,
- int i,
- char[] chars,
- int len,
- boolean fromTextNode,
- boolean escLF)
- throws IOException
- {
-
- int pos = accumDefaultEntity(writer, ch, i, chars, len, fromTextNode, escLF);
-
- if (i == pos)
- {
- if (Encodings.isHighUTF16Surrogate(ch))
- {
-
- // Should be the UTF-16 low surrogate of the hig/low pair.
- char next;
- // Unicode code point formed from the high/low pair.
- int codePoint = 0;
-
- if (i + 1 >= len)
- {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] { Integer.toHexString(ch)}));
- //"Invalid UTF-16 surrogate detected: "
-
- //+Integer.toHexString(ch)+ " ?");
- }
- else
- {
- next = chars[++i];
-
- if (!(Encodings.isLowUTF16Surrogate(next)))
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey
- .ER_INVALID_UTF16_SURROGATE,
- new Object[] {
- Integer.toHexString(ch)
- + " "
- + Integer.toHexString(next)}));
- //"Invalid UTF-16 surrogate detected: "
-
- //+Integer.toHexString(ch)+" "+Integer.toHexString(next));
- codePoint = Encodings.toCodePoint(ch,next);
- }
-
- writer.writeCharacterReference(codePoint);
- pos += 2; // count the two characters that went into writing out this entity
- }
- else
- {
- /* This if check is added to support control characters in XML 1.1.
- * If a character is a Control Character within C0 and C1 range, it is desirable
- * to write it out as Numeric Character Reference(NCR) regardless of XML Version
- * being used for output document.
- */
- if (isCharacterInC0orC1Range(ch) || isNELorLSEPCharacter(ch))
- {
- writer.writeCharacterReference(ch);
- }
- else if ((!escapingNotNeeded(ch) ||
- ( (fromTextNode && m_charInfo.shouldMapTextChar(ch))
- || (!fromTextNode && m_charInfo.shouldMapAttrChar(ch))))
- && m_elemContext.m_currentElemDepth > 0)
- {
- writer.writeCharacterReference(ch);
- }
- else
- {
- writer.write(ch);
- }
- pos++; // count the single character that was processed
- }
-
- }
- return pos;
- }
-
- /**
* Receive notification of the beginning of an element, although this is a
* SAX method additional namespace or attribute information can occur before
* or after this call, that is associated with this element.
@@ -1325,7 +1070,7 @@ abstract public class ToStream extends S
// The character is supposed to be replaced by a String
// e.g. '&' --> "&"
// e.g. '<' --> "<"
- accumDefaultEscape(writer, ch, i, stringChars, len, false, true);
+ writer.write(m_charInfo.getOutputStringForChar(ch));
}
else {
if (0x0 <= ch && ch <= 0x1F) {