wt.projmgmt.msproject
Class Exporter

java.lang.Object
  extended bywt.projmgmt.msproject.Exporter
Direct Known Subclasses:
ImportRequestExporter, MPPXMLExporter

public abstract class Exporter
extends Object

This class exports objects in XML.


Field Summary
private static String AMP
           
private static String APOS
           
private static String GT
           
private  String indent
          ---------------------------------------------
private  ImportExportInfo info
           
private static String LT
           
private  long nextUID
           
private static String QUOT
           
private static String RESOURCE
           
private  Map uidCache
          ---------------------------------------------
private  PrintWriter writer
           
 
Constructor Summary
Exporter(OutputStream ostream, ImportExportInfo info)
          Create an exporter that writes to the specified OutputStream using the character encoding specified in this exporter's ImportExportInfo.
 
Method Summary
 void close()
          Flush and close the OutputStream that this exporter is writing to.
protected  void comment(String str)
          Write a comment.
protected  void decreaseIndent()
           
private  String encodeSpecialCharacters(String str)
          Encode the following special characters using character entities: less than sign (<) greater than sign (>) ampersand (&) quotation mark (") apostrophe (')
protected  void endElement(String tag)
          Output the end tag for an element with the specified name.
abstract  void export(WfContainer c)
          Export the specified ProjectPlan or SummaryActivity in XML format.
 void exportBoolean(boolean boo, String tag)
          Export a boolean.
 void exportClass(Persistable p, String tag)
          Export the Class of the specified Persistable.
 void exportCurrency(Currency currency, String tag)
          Export a currency value.
 void exportDateTime(Date date, String tag)
          Export a date & time.
 void exportDateTime(Timestamp stamp, String tag)
          Export a date & time.
 void exportDuration(Date start, Date finish, String tag)
          Export a duration.
 void exportDuration(long millis, String tag)
          Export a duration.
 void exportDuration(TimeToElapse duration, String tag)
          Export a duration.
 void exportEnumeratedType(EnumeratedType enum, String tag)
          Export a EnumeratedType.
 void exportInt(int i, String tag)
          Export an int.
 void exportNonNegInt(int i, String tag)
          Export a non-negative int.
 void exportOwner(Ownable o, String tag)
          Export the Owner of the specified Ownable.
 void exportPercent(int i, String tag)
          Export an int as a percent represented as a fraction.
 void exportPrincipal(WTPrincipalReference pRef, String tag)
          Export the Principal.
 void exportPrincipal(WTPrincipal p, String tag)
          Export the Principal.
 void exportRate(CurrencyRate rate, String tag)
          Export a currency rate value.
 void exportString(String str, String tag)
          Export a String.
 void exportUID(Persistable p, String tag)
          Export the UID of the specified Persistable.
 void exportWork(Work work, String tag)
          Export a work value.
protected  ImportExportInfo getInfo()
          Get the ImportExportInfo that is used to control this import process.
protected  void increaseIndent()
           
protected  void startElement(String tag)
          Output the start tag for an element with the specified name.
protected  void startElement(String tag, String schemaName, String schemaLoc)
          Output the start tag for the document's root element.
protected  void writeElement(String tag, boolean data)
          Output an element.
protected  void writeElement(String tag, double data)
          Output an element.
protected  void writeElement(String tag, EnumeratedType data)
          Output an element.
protected  void writeElement(String tag, float data)
          Output an element.
protected  void writeElement(String tag, int data)
          Output an element.
protected  void writeElement(String tag, long data)
          Output an element.
protected  void writeElement(String tag, String data)
          Output an element.
protected  void writeElementData(String data)
          Output the text data for an element.
 void writeHeader()
          Write the XML header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LT

private static final String LT
See Also:
Constant Field Values

GT

private static final String GT
See Also:
Constant Field Values

AMP

private static final String AMP
See Also:
Constant Field Values

QUOT

private static final String QUOT
See Also:
Constant Field Values

APOS

private static final String APOS
See Also:
Constant Field Values

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

writer

private final PrintWriter writer

info

private ImportExportInfo info

uidCache

private final Map uidCache
---------------------------------------------


nextUID

private long nextUID

indent

private String indent
---------------------------------------------

Constructor Detail

Exporter

public Exporter(OutputStream ostream,
                ImportExportInfo info)
         throws UnsupportedEncodingException
Create an exporter that writes to the specified OutputStream using the character encoding specified in this exporter's ImportExportInfo.

Parameters:
ostream - the stream to write to
Method Detail

getInfo

protected final ImportExportInfo getInfo()
Get the ImportExportInfo that is used to control this import process.

Returns:
the import-export info object

export

public abstract void export(WfContainer c)
                     throws WTException,
                            IOException
Export the specified ProjectPlan or SummaryActivity in XML format.

The XML is written to the OutputStream that was passed in when this exporter was created.

Parameters:
c - the ProjectPlan or SummaryActivity to export
Throws:
WTException
IOException

close

public final void close()
Flush and close the OutputStream that this exporter is writing to.


exportUID

public void exportUID(Persistable p,
                      String tag)
Export the UID of the specified Persistable.

Parameters:
p - the persistable to export
tag - the name of the tag that holds the UID

exportClass

public void exportClass(Persistable p,
                        String tag)
Export the Class of the specified Persistable.

Parameters:
p - the persistable to export
tag - the name of the tag that holds the class name

exportOwner

public void exportOwner(Ownable o,
                        String tag)
                 throws WTException
Export the Owner of the specified Ownable.

Parameters:
o - the ownable object to export
tag - the name of the tag that holds the owner
Throws:
WTException

exportPrincipal

public void exportPrincipal(WTPrincipal p,
                            String tag)
                     throws WTException
Export the Principal.

Parameters:
p - the principal to export
tag - the name of the tag that holds the principal
Throws:
WTException

exportPrincipal

public void exportPrincipal(WTPrincipalReference pRef,
                            String tag)
Export the Principal.

Parameters:
pRef - the principal to export
tag - the name of the tag that holds the principal

exportCurrency

public void exportCurrency(Currency currency,
                           String tag)
Export a currency value.

Parameters:
currency - the currency to export
tag - the name of the tag that holds the amount

exportRate

public void exportRate(CurrencyRate rate,
                       String tag)
Export a currency rate value.

Parameters:
rate - the currency rate to export
tag - the name of the tag that holds the rate

exportWork

public void exportWork(Work work,
                       String tag)
Export a work value.

Parameters:
work - the work to export
tag - the name of the tag that holds the work

exportDateTime

public void exportDateTime(Date date,
                           String tag)
Export a date & time. The exported date & time is represented in the time zone that is specified in this exporter's ImportExportInfo.

Parameters:
date - the date & time to export
tag - the name of the tag that holds the date

exportDateTime

public void exportDateTime(Timestamp stamp,
                           String tag)
Export a date & time. The exported date & time is represented in the time zone that is specified in this exporter's ImportExportInfo.

Parameters:
stamp - the date & time to export
tag - the name of the tag that holds the date

exportDuration

public void exportDuration(TimeToElapse duration,
                           String tag)
Export a duration.

Parameters:
duration - the duration to export
tag - the name of the tag that holds the duration

exportDuration

public void exportDuration(Date start,
                           Date finish,
                           String tag)
Export a duration. The duration that is exported is the amount of time that exists between the specified start date and the specified finish date.

Parameters:
start - the start of the interval
finish - the end of the interval
tag - the name of the tag that holds the duration

exportDuration

public void exportDuration(long millis,
                           String tag)
Export a duration.

Parameters:
millis - the duration to export expressed in milliseconds
tag - the name of the tag that holds the duration

exportEnumeratedType

public void exportEnumeratedType(EnumeratedType enum,
                                 String tag)
Export a EnumeratedType.

Parameters:
enum - the enumerated type object to export
tag - the name of the tag that holds the enum

exportBoolean

public void exportBoolean(boolean boo,
                          String tag)
Export a boolean.

Parameters:
boo - the boolean to export
tag - the name of the tag that holds the boolean

exportInt

public final void exportInt(int i,
                            String tag)
Export an int.

Parameters:
i - the int to export
tag - the name of the tag that holds the int

exportNonNegInt

public final void exportNonNegInt(int i,
                                  String tag)
Export a non-negative int. If the integer is less than zero it is not exported.

Parameters:
i - the int to export
tag - the name of the tag that holds the int

exportPercent

public void exportPercent(int i,
                          String tag)
Export an int as a percent represented as a fraction. If the int is less than zero it is not exported.

This exports (i/100.0F) as long as (i >= 0).

Parameters:
i - the percent to export
tag - the name of the tag that holds the int

exportString

public void exportString(String str,
                         String tag)
Export a String.

Parameters:
str - the string to export
tag - the name of the tag that holds the text

writeHeader

public final void writeHeader()
Write the XML header.


comment

protected final void comment(String str)
Write a comment.


writeElement

protected final void writeElement(String tag,
                                  String data)
Output an element. This outputs the start tag, element data and the end tag. Any special characters that appear in the data are encoded using character entities.

Parameters:
tag - the name of the element
data - the element's text data

writeElement

protected final void writeElement(String tag,
                                  long data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's numeric data

writeElement

protected final void writeElement(String tag,
                                  int data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's numeric data

writeElement

protected final void writeElement(String tag,
                                  double data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's numeric data

writeElement

protected final void writeElement(String tag,
                                  float data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's numeric data

writeElement

protected final void writeElement(String tag,
                                  boolean data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's boolean data

writeElement

protected final void writeElement(String tag,
                                  EnumeratedType data)
Output an element. This outputs the start tag, element data and the end tag.

Parameters:
tag - the name of the element
data - the element's enum type data

writeElementData

protected final void writeElementData(String data)
Output the text data for an element. Any special characters that appear in the data are encoded using character entities.

Parameters:
data - the element's text data

startElement

protected final void startElement(String tag,
                                  String schemaName,
                                  String schemaLoc)
Output the start tag for the document's root element.

Parameters:
tag - the document's root element name
schemaName - the name of the document's schema or null
schemaLoc - the schema's location or null

startElement

protected final void startElement(String tag)
Output the start tag for an element with the specified name.

Parameters:
tag - the name of the element

endElement

protected final void endElement(String tag)
Output the end tag for an element with the specified name.

Parameters:
tag - the name of the element

increaseIndent

protected final void increaseIndent()

decreaseIndent

protected final void decreaseIndent()

encodeSpecialCharacters

private final String encodeSpecialCharacters(String str)
Encode the following special characters using character entities: