Package org.apache.james.jdkim.mailets
Class CRLFOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.james.jdkim.mailets.CRLFOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A Filter for use with SMTP or other protocols in which lines must end with
CRLF. Converts every "isolated" occourency of \r or \n with \r\n
RFC 2821 #2.3.7 mandates that line termination is CRLF, and that CR and LF
must not be transmitted except in that pairing. If we get a naked LF, convert
to CRLF.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final intprotected static final intprotected static final intprotected booleanprotected intCounter for number of last (0A or 0D).Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsure that the stream is CRLF terminated.voidwrite(byte[] buffer, int offset, int length) voidwrite(int b) Writes a byte to the stream Fixes any naked CR or LF to the RFC 2821 mandated CFLF pairing.protected voidwriteChunk(byte[] buffer, int offset, int length) Provides an extension point for ExtraDotOutputStream to be able to add dots at the beginning of new lines.Methods inherited from class java.io.FilterOutputStream
close, flush, writeMethods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
statusLast
protected int statusLastCounter for number of last (0A or 0D). -
LAST_WAS_OTHER
protected static final int LAST_WAS_OTHER- See Also:
-
LAST_WAS_CR
protected static final int LAST_WAS_CR- See Also:
-
LAST_WAS_LF
protected static final int LAST_WAS_LF- See Also:
-
startOfLine
protected boolean startOfLine
-
-
Constructor Details
-
CRLFOutputStream
Constructor that wraps an OutputStream.- Parameters:
out- the OutputStream to be wrapped
-
-
Method Details
-
write
Writes a byte to the stream Fixes any naked CR or LF to the RFC 2821 mandated CFLF pairing.- Overrides:
writein classFilterOutputStream- Parameters:
b- the byte to write- Throws:
IOException- if an error occurs writing the byte
-
writeChunk
Provides an extension point for ExtraDotOutputStream to be able to add dots at the beginning of new lines.- Parameters:
buffer- byte bufferoffset- int offsetlength- and length- Throws:
IOException- See Also:
-
write
- Overrides:
writein classFilterOutputStream- Parameters:
buffer- byte bufferoffset- int offsetlength- and length- Throws:
IOException- See Also:
-
checkCRLFTerminator
Ensure that the stream is CRLF terminated.- Throws:
IOException- if an error occurs writing the byte
-