fixed #SWS-96: set WhitespacePreserve flag in CastorMarshaller
This commit is contained in:
@@ -6,6 +6,7 @@ Changes in version 1.0-RC1
|
||||
-------------------------
|
||||
Package org.springframework.oxm.castor
|
||||
* fixed #SWS-88: Allow CastorMarshaller to accept more than one mapping file
|
||||
* fixed #SWS-96: set WhitespacePreserve flag in CastorMarshaller
|
||||
|
||||
Package org.springframework.oxm.jibx
|
||||
* fixed #SWS-97: OXM Marshal encoding definition
|
||||
|
||||
@@ -76,26 +76,35 @@ import org.xml.sax.ext.LexicalHandler;
|
||||
*/
|
||||
public class CastorMarshaller extends AbstractMarshaller implements InitializingBean {
|
||||
|
||||
/**
|
||||
* The default encoding used for stream access.
|
||||
*/
|
||||
/** The default encoding used for stream access. */
|
||||
public static final String DEFAULT_ENCODING = "UTF-8";
|
||||
|
||||
private Resource[] mappingLocations;
|
||||
|
||||
private String encoding;
|
||||
private String encoding = DEFAULT_ENCODING;
|
||||
|
||||
private Class targetClass;
|
||||
|
||||
private XMLClassDescriptorResolver classDescriptorResolver;
|
||||
|
||||
private boolean validating = false;
|
||||
|
||||
private boolean whitespacePreserve = false;
|
||||
|
||||
/**
|
||||
* Returns the encoding to be used for stream access. If this property is not set, the default encoding is used.
|
||||
*
|
||||
* @see #DEFAULT_ENCODING
|
||||
* Set if the Castor <code>Unmarshaller</code> should validate the incoming document. Default is
|
||||
* <code>false</code>.
|
||||
*/
|
||||
private String getEncoding() {
|
||||
return encoding != null ? encoding : DEFAULT_ENCODING;
|
||||
public void setValidating(boolean validating) {
|
||||
this.validating = validating;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the Castor <code>Unmarshaller</code> should preserve "ignorable" whitespace. Default is
|
||||
* <code>false</code>.
|
||||
*/
|
||||
public void setWhitespacePreserve(boolean whitespacePreserve) {
|
||||
this.whitespacePreserve = whitespacePreserve;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,16 +126,12 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||
this.targetClass = targetClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locations of the Castor XML Mapping files.
|
||||
*/
|
||||
/** Sets the locations of the Castor XML Mapping files. */
|
||||
public void setMappingLocation(Resource mappingLocation) {
|
||||
mappingLocations = new Resource[]{mappingLocation};
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the locations of the Castor XML Mapping files.
|
||||
*/
|
||||
/** Sets the locations of the Castor XML Mapping files. */
|
||||
public void setMappingLocations(Resource[] mappingLocations) {
|
||||
this.mappingLocations = mappingLocations;
|
||||
}
|
||||
@@ -213,6 +218,8 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||
unmarshaller = new Unmarshaller();
|
||||
}
|
||||
unmarshaller.setResolver(classDescriptorResolver);
|
||||
unmarshaller.setValidation(validating);
|
||||
unmarshaller.setWhitespacePreserve(whitespacePreserve);
|
||||
return unmarshaller;
|
||||
}
|
||||
|
||||
@@ -243,7 +250,7 @@ public class CastorMarshaller extends AbstractMarshaller implements Initializing
|
||||
|
||||
protected void marshalOutputStream(Object graph, OutputStream outputStream)
|
||||
throws XmlMappingException, IOException {
|
||||
OutputStreamWriter writer = new OutputStreamWriter(outputStream, getEncoding());
|
||||
OutputStreamWriter writer = new OutputStreamWriter(outputStream, encoding);
|
||||
marshalWriter(graph, writer);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user