LDAP Classes
Implements Java LDAP

com.novell.ldap.util
Class DSMLWriter

java.lang.Object
  extended bycom.novell.ldap.util.DSMLWriter
All Implemented Interfaces:
LDAPWriter

public class DSMLWriter
extends java.lang.Object
implements LDAPWriter

Writes LDAPMessages into a Writer or outputStream as DSML batch requests and batch responses.

See Also:
DSMLReader, DOMWriter, LDAPMessage

Constructor Summary
DSMLWriter(java.io.OutputStream stream)
          Initializes this writer with the specified outputstream to write DSML into.
DSMLWriter(java.lang.String file)
          Initializes this writer by opening the specified file to write DSML into.
DSMLWriter(java.io.Writer writer)
          Initializes this writer with the specified writer to write DSML into.
 
Method Summary
 void finish()
          Writes closing tags for searchResponse, batchRequests, and batchResponse depending on the current state.
 java.lang.String getVersion()
          Gets the version of the LDIF data associated with the input stream
 boolean isRequest()
          Returns true if request data ist associated with the input stream, or false if content data.
 boolean isUseSOAP()
           
 void setIndent(int spaces)
          Sets the number of spaces for indentation of XML tags.
 void setResumeOnError(boolean resumeOnError)
           
 void setUseSOAP(boolean useSOAP)
           
 void useIndent(boolean useIndent)
          Turns on or off 'pretty-printing' of XML with newlines and indentation to make output more readable.
 void writeComments(java.lang.String lines)
          Writes the specified strings as XML comments.
 void writeEntry(LDAPEntry entry)
          Write an LDAP entry into LDIF file as LDAPContent data.
 void writeEntry(LDAPEntry entry, LDAPControl[] controls)
          Write an LDAP entry into LDIF file as LDAPContent data.
 void writeEntry(LDAPEntry entry, LDAPControl[] controls, java.lang.String requestID)
          Write an LDAP entry into LDIF file as LDAPContent data.
 void writeError(java.lang.Exception e)
          Any Exception can be written in DSML with this method, via the tag.
 void writeMessage(LDAPMessage messageToWrite)
          Writes an LDAPMessage as DSML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DSMLWriter

public DSMLWriter(java.lang.String file)
           throws java.io.FileNotFoundException
Initializes this writer by opening the specified file to write DSML into.

Parameters:
file - File to write DSML
Throws:
java.io.FileNotFoundException - occurs when the specified file could not be opened or is not found.

DSMLWriter

public DSMLWriter(java.io.OutputStream stream)
Initializes this writer with the specified outputstream to write DSML into. Note that the output characters will be UTF-8 encoded.

Parameters:
stream - Output stream to write DSML

DSMLWriter

public DSMLWriter(java.io.Writer writer)
Initializes this writer with the specified writer to write DSML into.

Parameters:
writer - Writer to write DSML
Method Detail

setResumeOnError

public void setResumeOnError(boolean resumeOnError)

writeError

public void writeError(java.lang.Exception e)
                throws java.io.IOException
Any Exception can be written in DSML with this method, via the tag. In general LDAPExceptions should be written to the errorResponse tag and other exception in a SOAP Fault.

Specified by:
writeError in interface LDAPWriter
Parameters:
e - LDAPException to be written in DSML.
Throws:
java.io.IOException

finish

public void finish()
            throws java.io.IOException
Writes closing tags for searchResponse, batchRequests, and batchResponse depending on the current state.

Specified by:
finish in interface LDAPWriter
Throws:
java.io.IOException

writeComments

public void writeComments(java.lang.String lines)
                   throws java.io.IOException
Writes the specified strings as XML comments.

Specified by:
writeComments in interface LDAPWriter
Parameters:
lines - Comments to be written
Throws:
java.io.IOException

writeMessage

public void writeMessage(LDAPMessage messageToWrite)
                  throws java.io.IOException,
                         LDAPLocalException
Writes an LDAPMessage as DSML.

Specified by:
writeMessage in interface LDAPWriter
Parameters:
messageToWrite - Message to be written as DSML
Throws:
LDAPLocalException - Occurs when a message is written out of sequence, i.e. a response is written into a batchRequest.
java.io.IOException - if an I/O error occurs.

writeEntry

public void writeEntry(LDAPEntry entry)
                throws java.io.IOException,
                       LDAPLocalException
Write an LDAP entry into LDIF file as LDAPContent data. An LDAPEntry is written as a SearchResultEntry record.

You are not allowed to mix request data and content data

Specified by:
writeEntry in interface LDAPWriter
Parameters:
entry - LDAPEntry object
Throws:
java.io.IOException - if an I/O error occurs.
LDAPLocalException
See Also:
LDAPEntry

writeEntry

public void writeEntry(LDAPEntry entry,
                       LDAPControl[] controls)
                throws java.io.IOException,
                       LDAPLocalException
Write an LDAP entry into LDIF file as LDAPContent data. An LDAPEntry is written as a SearchResultEntry record.

You are not allowed to mix request data and content data

Specified by:
writeEntry in interface LDAPWriter
Parameters:
entry - LDAPEntry object
controls - Controls that were returned with this entry
Throws:
java.io.IOException - if an I/O error occurs.
LDAPLocalException
See Also:
LDAPEntry

writeEntry

public void writeEntry(LDAPEntry entry,
                       LDAPControl[] controls,
                       java.lang.String requestID)
                throws java.io.IOException,
                       LDAPLocalException
Write an LDAP entry into LDIF file as LDAPContent data. An LDAPEntry is written as a SearchResultEntry record.

You are not allowed to mix request data and content data

Parameters:
entry - LDAPEntry object
controls - Controls that were returned with this entry
requestID - the String that associates this response with the request
Throws:
java.io.IOException - if an I/O error occurs.
LDAPLocalException
See Also:
LDAPEntry

getVersion

public java.lang.String getVersion()
Gets the version of the LDIF data associated with the input stream

Specified by:
getVersion in interface LDAPWriter
Returns:
the version number

isRequest

public boolean isRequest()
Returns true if request data ist associated with the input stream, or false if content data.

Specified by:
isRequest in interface LDAPWriter
Returns:
true if input stream contains request data.

useIndent

public void useIndent(boolean useIndent)
Turns on or off 'pretty-printing' of XML with newlines and indentation to make output more readable.

For efficiency, useIndent is set to false by default. The size of an indentation can be set using the method setIndent.

Parameters:
useIndent - Indicates whether indentation and newlines should be written to make the output DSML more readable.
See Also:
setIndent(int)

setIndent

public void setIndent(int spaces)
Sets the number of spaces for indentation of XML tags.

This setting is ignored by default unless indentation is turned on via the useIndent method.

Parameters:
spaces - Number of spaces used in each indentation.
See Also:
useIndent(boolean)

isUseSOAP

public boolean isUseSOAP()
Returns:
Returns the useSOAP.

setUseSOAP

public void setUseSOAP(boolean useSOAP)
Parameters:
useSOAP - The useSOAP to set.

LDAP Classes
Implements Java LDAP

Copyright © 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000