edu.harvard.hul.ois.mets.helper
Class MetsWriter

java.lang.Object
  extended byedu.harvard.hul.ois.mets.helper.MetsWriter

public class MetsWriter
extends java.lang.Object

Writer to serialize an in-memory representation of a METS document to a file.


Constructor Summary
MetsWriter(java.io.OutputStream out)
          Instantiate a MetsWriter object with an open output stream.
MetsWriter(java.io.OutputStream out, java.lang.String encoding)
          Instantiate a MetsWriter object for an open output stream with an encoding.
 
Method Summary
 void attribute(java.lang.String qName, java.lang.String value)
          Write an attribute to the output stream.
 void attribute(java.lang.String qName, java.lang.String value, boolean noEscape)
          Write an attribute to the output stream.
 void attributeName(java.lang.String qName)
          Write an attribute name to the output stream.
 void attributeValue(java.lang.String value)
          Write an attribute value to the output stream.
 void attributeValue(java.lang.String value, boolean noEscape)
          Write an attribute value to the output stream.
 void binary(byte[] b)
          Writes b.length bytes from byte array to the output stream.
 void binary(byte[] b, int off, int len)
          Writes b.length bytes from byte array to the output stream.
 void cdata(java.lang.String value)
          Write CDATA to the output stream.
 void char_ref(int value)
          Write character reference to the output stream.
 void char_ref(int value, boolean hex)
          Write character reference to the output stream.
 void comment(java.lang.String value)
          Write comment to the output stream.
 void declaration()
          Write an XML declaration to the output stream.
 void end(java.lang.String qName)
          Write an end tag to the output stream.
 void entity_ref(java.lang.String value)
          Write entity reference to the output stream.
 void flush()
          Flush the output stream.
 boolean getNoEscape()
          Return the value of the global "no escape" flag.
 void pi(java.lang.String target, java.lang.String value)
          Write processing instruction to the output stream.
 void setNoEscape(boolean noEscape)
          Set the value of the global "no escape" flag.
 void start(java.lang.String qName)
          Write a start tag to the output stream.
 void text(java.lang.String value)
          Write text to the output stream.
 void text(java.lang.String value, boolean noEscape)
          Write text to the output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetsWriter

public MetsWriter(java.io.OutputStream out)
           throws MetsException
Instantiate a MetsWriter object with an open output stream.

Parameters:
out - Open output stream
Throws:
MetsException - I/O exception

MetsWriter

public MetsWriter(java.io.OutputStream out,
                  java.lang.String encoding)
           throws MetsException
Instantiate a MetsWriter object for an open output stream with an encoding.

Parameters:
out - Open output stream
encoding - Character encoding
Throws:
MetsException - I/O exception
Method Detail

getNoEscape

public boolean getNoEscape()
Return the value of the global "no escape" flag.


setNoEscape

public void setNoEscape(boolean noEscape)
Set the value of the global "no escape" flag.

Parameters:
noEscape - "No escape" flag

attribute

public void attribute(java.lang.String qName,
                      java.lang.String value)
               throws MetsException
Write an attribute to the output stream.

Parameters:
qName - Attribute QName
value - Attribute value
Throws:
MetsException - I/O exception

attribute

public void attribute(java.lang.String qName,
                      java.lang.String value,
                      boolean noEscape)
               throws MetsException
Write an attribute to the output stream.

Parameters:
qName - Attribute QName
value - Attribute value
noEscape - If true, no XML escaping is performed on the text
Throws:
MetsException - I/O exception

attributeName

public void attributeName(java.lang.String qName)
                   throws MetsException
Write an attribute name to the output stream.

Parameters:
qName - Attribute QName
Throws:
MetsException - I/O exception

attributeValue

public void attributeValue(java.lang.String value)
                    throws MetsException
Write an attribute value to the output stream.

Parameters:
value - Attribute value
Throws:
MetsException - I/O exception

attributeValue

public void attributeValue(java.lang.String value,
                           boolean noEscape)
                    throws MetsException
Write an attribute value to the output stream.

Parameters:
value - Attribute value
noEscape - If true, no XML escaping is performed on the attribute
Throws:
MetsException - I/O exception

binary

public void binary(byte[] b)
            throws MetsException
Writes b.length bytes from byte array to the output stream.

Parameters:
b - byte array data
Throws:
MetsException - I/O exception

binary

public void binary(byte[] b,
                   int off,
                   int len)
            throws MetsException
Writes b.length bytes from byte array to the output stream.

Parameters:
b - byte array data
off - the start offset in the array
len - the number of bytes to write
Throws:
MetsException - I/O exception

cdata

public void cdata(java.lang.String value)
           throws MetsException
Write CDATA to the output stream.

Parameters:
value - CDATA value
Throws:
MetsException - I/O exception

char_ref

public void char_ref(int value)
              throws MetsException
Write character reference to the output stream.

Parameters:
value - Reference value
Throws:
MetsException - I/O exception

char_ref

public void char_ref(int value,
                     boolean hex)
              throws MetsException
Write character reference to the output stream.

Parameters:
value - Reference value
hex - True if a hexadecimal value
Throws:
MetsException - I/O exception

comment

public void comment(java.lang.String value)
             throws MetsException
Write comment to the output stream.

Parameters:
value - Comment value
Throws:
MetsException - I/O exception

declaration

public void declaration()
                 throws MetsException
Write an XML declaration to the output stream.

Throws:
MetsException - I/O exception

end

public void end(java.lang.String qName)
         throws MetsException
Write an end tag to the output stream.

Parameters:
qName - Element QName
Throws:
MetsException - I/O exception

entity_ref

public void entity_ref(java.lang.String value)
                throws MetsException
Write entity reference to the output stream.

Parameters:
value - Reference value
Throws:
MetsException - I/O exception

flush

public void flush()
           throws MetsException
Flush the output stream.

Throws:
MetsException - I/O exception

pi

public void pi(java.lang.String target,
               java.lang.String value)
        throws MetsException
Write processing instruction to the output stream.

Parameters:
target - PI target
value - PI value
Throws:
MetsException - I/O exception

start

public void start(java.lang.String qName)
           throws MetsException
Write a start tag to the output stream.

Parameters:
qName - Element QName
Throws:
MetsException - I/O exception

text

public void text(java.lang.String value)
          throws MetsException
Write text to the output stream.

Parameters:
value - Text value
Throws:
MetsException - I/O exception

text

public void text(java.lang.String value,
                 boolean noEscape)
          throws MetsException
Write text to the output stream.

Parameters:
value - Text value
noEscape - If true, no XML escaping is performed on the text
Throws:
MetsException - I/O exception