All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class org.xmlmiddleware.xmldbms.maps.utils.MapSerializer

java.lang.Object
   |
   +----org.xmlmiddleware.xmlutils.XMLWriter
           |
           +----org.xmlmiddleware.xmldbms.maps.utils.MapSerializer

public class MapSerializer
extends XMLWriter
Serializes an XMLDBMSMap object to a character stream.

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.

Version:
2.0
Author:
Ronald Bourret, 1998-9, 2001

Constructor Index

 o MapSerializer()
Construct a new MapSerializer.
 o MapSerializer(Writer)
Construct a new MapSerializer and set the Writer.

Method Index

 o serialize(XMLDBMSMap)
Serialize an XMLDBMSMap using the XML-DBMS mapping language.
 o serialize(XMLDBMSMap, String, String)
Serialize an XMLDBMSMap using the XML-DBMS mapping language.
 o setWriter(Writer)
Set the Writer.
 o usePrefixes(String[], String[])
Use the specified prefixes.

Constructors

 o MapSerializer
 public MapSerializer()
Construct a new MapSerializer.

 o MapSerializer
 public MapSerializer(Writer writer)
Construct a new MapSerializer and set the Writer.

Parameters:
writer - The writer. The writer must implement the write(String,int,int) and write(int) methods.

Methods

 o setWriter
 public void setWriter(Writer writer)
Set the Writer.

Parameters:
writer - The writer. The writer must implement the write(String,int,int) and write(int) methods.
Overrides:
setWriter in class XMLWriter
 o usePrefixes
 public void usePrefixes(String prefixes[],
                         String uris[])
Use the specified prefixes.

Parameters:
prefixes - An array of namespace prefixes. If this is null, then serialize() uses the prefixes in the XMLDBMSMap.
uris - An array of namespace URIs corresponding to the prefixes in the prefixes argument.
 o serialize
 public void serialize(XMLDBMSMap map) throws IOException, XMLMiddlewareException
Serialize an XMLDBMSMap using the XML-DBMS mapping language.

No system or public ID is written in the DOCTYPE statement.

Parameters:
map - The XMLDBMSMap.
Throws: IOException
Thrown if an I/O exception occurs.
Throws: XMLMiddlewareException
Thrown if a prefix was not found for a URI or a map error occurs.
 o serialize
 public void serialize(XMLDBMSMap map,
                       String systemID,
                       String publicID) throws IOException, XMLMiddlewareException
Serialize an XMLDBMSMap using the XML-DBMS mapping language.

Parameters:
map - The XMLDBMSMap.
systemID - System ID of the DTD. If this is null, "xmldbms2.dtd" is used.
publicID - Public ID of the DTD. May be null.
Throws: IOException
Thrown if an I/O exception occurs.
Throws: XMLMiddlewareException
Thrown if a prefix was not found for a URI or a map error occurs.

All Packages  Class Hierarchy  This Package  Previous  Next  Index