rdonkin 2004/03/24 14:50:02
Modified: betwixt/src/java/org/apache/commons/betwixt/io
BeanWriter.java
Log:
Added support for flexible encoding strategies for mixed content to BeanWriter
Revision Changes Path
1.22 +30 -2
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
Index: BeanWriter.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- BeanWriter.java 28 Feb 2004 13:38:33 -0000 1.21
+++ BeanWriter.java 24 Mar 2004 22:50:02 -0000 1.22
@@ -29,6 +29,7 @@
import org.xml.sax.Attributes;
import org.apache.commons.betwixt.XMLUtils;
+import org.apache.commons.betwixt.strategy.MixedContentEncodingStrategy;
/** <p><code>BeanWriter</code> outputs beans as XML to an io stream.</p>
*
@@ -100,6 +101,9 @@
private boolean closedStartTag = true;
/** Current level of indentation (starts at 1 with the first element) */
private int indentLevel;
+ /** USed to determine how body content should be encoded before being output*/
+ private MixedContentEncodingStrategy mixedContentEncodingStrategy
+ = MixedContentEncodingStrategy.DEFAULT;
/**
* <p> Constructor uses <code>System.out</code> for output.</p>
@@ -262,6 +266,28 @@
this.log = log;
}
+ /**
+ * Gets the encoding strategy for mixed content.
+ * This is used to process body content
+ * before it is written to the textual output.
+ * @return the <code>MixedContentEncodingStrategy</code>, not null
+ */
+ public MixedContentEncodingStrategy getMixedContentEncodingStrategy() {
+ return mixedContentEncodingStrategy;
+ }
+
+ /**
+ * Sets the encoding strategy for mixed content.
+ * This is used to process body content
+ * before it is written to the textual output.
+ * @param strategy the <code>MixedContentEncodingStrategy</code>
+ * used to process body content, not null
+ */
+ public void setMixedContentEncodingStrategy(MixedContentEncodingStrategy
strategy) {
+ mixedContentEncodingStrategy = strategy;
+ }
+
+
// New API
//------------------------------------------------------------------------------
@@ -364,7 +390,7 @@
writer.write( '>' );
closedStartTag = true;
}
- writer.write( XMLUtils.escapeBodyValue(text) );
+ writer.write( mixedContentEncodingStrategy.encode(text,
currentDescriptor) );
currentElementIsEmpty = false;
currentElementHasBodyText = true;
}
@@ -556,4 +582,6 @@
writer.write( XMLUtils.escapeAttributeValue(value) );
writer.write( '\"' );
}
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]