All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----org.xmlmiddleware.xmlutils.XMLWriter | +----org.xmlmiddleware.xmldbms.maps.utils.MapSerializer
If you want to use a specific encoding, the Writer must be an OutputStreamWriter or a subclass of an OutputStreamWriter. For example, you might use the following code to write a map file with the Shift_JIS encoding:
// Construct the FileOutputStream. OutputStream out = new FileOutputStream("sales.map");
// Construct the OutputStreamWriter with the Shift_JIS encoding. This may // throw an UnsupportedEncodingException. Writer writer = new OutputStreamWriter(out, "Shift_JIS");
// Construct the MapSerializer. MapSerializer serializer = new MapSerializer(writer);
// Serialize the map. serializer.serialize(map);
// Close the file. writer.close();
If you want to use the default encoding, you can just use a FileWriter. However, no encoding declaration will be written in the XML declaration. For example:
// Construct a new FileWriter. Writer writer = new FileWriter("sales.map");
// Construct the MapSerializer. MapSerializer serializer = new MapSerializer(writer);
// Serialize the map. serializer.serialize(map);
// Close the file. writer.close();
WARNING: MapSerializer cannot generate DateFormat, TimeFormat, DateTimeFormat, and NumberFormat elements. This is because the underlying formatting objects do not contain enough information to construct these elements. MapSerializer can generate SimpleDateFormat, DecimalFormat, and FormatClass elements, but cannot generate Locale children of SimpleDateFormat and DecimalFormat elements, again due to lack of information. However, it can generate localized patterns.
public MapSerializer()
public MapSerializer(Writer writer)
public void setWriter(Writer writer)
public void usePrefixes(String prefixes[], String uris[])
public void serialize(XMLDBMSMap map) throws IOException, XMLMiddlewareException
No system or public ID is written in the DOCTYPE statement.
public void serialize(XMLDBMSMap map, String systemID, String publicID) throws IOException, XMLMiddlewareException
All Packages Class Hierarchy This Package Previous Next Index