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 2017/05/14 17:04:34 UTC
svn commit: r1795112 - in
/webservices/axiom/trunk/aspects/core-aspects/src/main:
java/org/apache/axiom/core/stream/serializer/CharInfo.java
java/org/apache/axiom/core/stream/serializer/Serializer.java resources/
Author: veithen
Date: Sun May 14 17:04:34 2017
New Revision: 1795112
URL: http://svn.apache.org/viewvc?rev=1795112&view=rev
Log:
Simplify the serialization logic and remove the CharInfo class.
Removed:
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/CharInfo.java
webservices/axiom/trunk/aspects/core-aspects/src/main/resources/
Modified:
webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
Modified: webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java?rev=1795112&r1=1795111&r2=1795112&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java (original)
+++ webservices/axiom/trunk/aspects/core-aspects/src/main/java/org/apache/axiom/core/stream/serializer/Serializer.java Sun May 14 17:04:34 2017
@@ -42,12 +42,6 @@ public final class Serializer extends Se
private final OutputStream outputStream;
/**
- * Map that tells which characters should have special treatment, and it
- * provides character to entity name lookup.
- */
- protected CharInfo m_charInfo = CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE);
-
- /**
* Add space before '/>' for XHTML.
*/
protected boolean m_spaceBeforeClose = false;
@@ -415,32 +409,23 @@ public final class Serializer extends Se
String replacement = null;
boolean generateCharacterReference = false;
- if (context == Context.MIXED_CONTENT && m_charInfo.shouldMapTextChar(ch)
- || context == Context.ATTRIBUTE_VALUE && m_charInfo.shouldMapAttrChar(ch)) {
- // The character is supposed to be replaced by a String
- // e.g. '&' --> "&"
- // e.g. '<' --> "<"
- replacement = m_charInfo.getOutputStringForChar(ch);
- }
- else {
- if (ch <= 0x1F) {
- // Range 0x00 through 0x1F inclusive
- //
- // This covers the non-whitespace control characters
- // in the range 0x1 to 0x1F inclusive.
- // It also covers the whitespace control characters in the same way:
- // 0x9 TAB
- // 0xA NEW LINE
- // 0xD CARRIAGE RETURN
- //
- // We also cover 0x0 ... It isn't valid
- // but we will output "�"
-
- // The default will handle this just fine, but this
- // is a little performance boost to handle the more
- // common TAB, NEW-LINE, CARRIAGE-RETURN
- switch (ch) {
-
+ if (ch <= 0x1F) {
+ // Range 0x00 through 0x1F inclusive
+ //
+ // This covers the non-whitespace control characters
+ // in the range 0x1 to 0x1F inclusive.
+ // It also covers the whitespace control characters in the same way:
+ // 0x9 TAB
+ // 0xA NEW LINE
+ // 0xD CARRIAGE RETURN
+ //
+ // We also cover 0x0 ... It isn't valid
+ // but we will output "�"
+
+ // The default will handle this just fine, but this
+ // is a little performance boost to handle the more
+ // common TAB, NEW-LINE, CARRIAGE-RETURN
+ switch (ch) {
case 0x09:
if (context == Context.ATTRIBUTE_VALUE) {
replacement = "	";
@@ -458,25 +443,31 @@ public final class Serializer extends Se
default:
generateCharacterReference = true;
break;
-
- }
- }
- else if (ch < 0x7F) {
- // Range 0x20 through 0x7E inclusive
- // Normal ASCII chars, do nothing, just add it to
- // the clean characters
-
}
- else if (ch <= 0x9F){
- // Range 0x7F through 0x9F inclusive
- // More control characters, including NEL (0x85)
- generateCharacterReference = true;
- }
- else if (ch == 0x2028) {
- // LINE SEPARATOR
- replacement = "
";
+ }
+ else if (ch < 0x7F) {
+ switch (ch) {
+ case '<':
+ replacement = "<";
+ break;
+ case '&':
+ replacement = "&";
+ break;
+ case '"':
+ if (context == Context.ATTRIBUTE_VALUE) {
+ replacement = """;
+ }
}
}
+ else if (ch <= 0x9F){
+ // Range 0x7F through 0x9F inclusive
+ // More control characters, including NEL (0x85)
+ generateCharacterReference = true;
+ }
+ else if (ch == 0x2028) {
+ // LINE SEPARATOR
+ replacement = "
";
+ }
if (replacement != null || generateCharacterReference) {
int startClean;
startClean = lastDirtyCharProcessed + 1;