org.activemath.presentation.formats
Class Format

java.lang.Object
  extended by java.io.OutputStream
      extended by org.activemath.presentation.formats.Format
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
Format_HTML, Format_LaTeX, Format_MathML, Format_Omdoc, Format_Text, Format_XHTML, FormatPipe, FormatThroughTempFile

public abstract class Format
extends OutputStream

Output stream with some member functions that provide metadata.
It's the root class for all the format classes.


Field Summary
protected static Logger log
           
protected  OutputStream out
           
 
Constructor Summary
Format()
           
Format(OutputStream output)
           
 
Method Summary
 void close()
           
 void flush()
           
static String getAssemblyFormat(String format)
           
static String getFormatPipeline(String format)
           
abstract  String getMimeType()
          Gives the mime type for the output format.
static String getMimeType(String format)
           
abstract  String getRequiredInputFormat()
          Tells the caller in what format it must give input to get the format provided by the class.
static Format newFormatStreamFor(String formatNameSequence, OutputStream sequenceOutput)
          Create a new Format subclass instance for the given format name.
 void write(byte[] b)
           
 void write(byte[] b, int offset, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static Logger log

out

protected OutputStream out
Constructor Detail

Format

public Format()

Format

public Format(OutputStream output)
Method Detail

getAssemblyFormat

public static String getAssemblyFormat(String format)

getFormatPipeline

public static String getFormatPipeline(String format)

getMimeType

public static String getMimeType(String format)

getRequiredInputFormat

public abstract String getRequiredInputFormat()
Tells the caller in what format it must give input to get the format provided by the class. Depends on what formats have been implemented in org.activemath.presentation.Page.

Returns:
Format required on input.

getMimeType

public abstract String getMimeType()
Gives the mime type for the output format.

Returns:
MIME type as string.
See Also:
IANA MIME types, RFC 1700, Thread in RedHat's XDG list, 2002-04-20, freedesktop.org Shared MIME-Info specification

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int offset,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

newFormatStreamFor

public static final Format newFormatStreamFor(String formatNameSequence,
                                              OutputStream sequenceOutput)
                                       throws FormatException
Create a new Format subclass instance for the given format name.
The Format subclasses are assumed to have only one constructor, with one parameter of type OutputStream.

Parameters:
formatNameSequence - Names of the formats to apply in sequence.
Format names are separated by dots (".").
For example, "PDF.GZIP" will produce PDF, and then output it through GZIP.
sequenceOutput - Stream to receive output.
Returns:
A new instance of a format stream, or null on error.
Throws:
FormatException - DOCUMENT ME!