|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectDirectImHeader
A data structure containing information about a Direct IM message or typing notification. Note that this is only a header and does not contain the message (and attached images or other media) itself.
| Field Summary | |
static java.lang.String |
DCVERSION_DEFAULT
The Direct IM protocol version string used by WinAIM. |
static long |
FLAG_AUTORESPONSE
A flag indicating that a message is an "auto-response." |
static long |
FLAG_TYPED
A flag indicating, when combined with FLAG_TYPINGPACKET, that
the user has typed a message, but has momentarily stopped typing. |
static long |
FLAG_TYPING
A flag indicating, when combined with FLAG_TYPINGPACKET, that
the user is typing a message. |
static long |
FLAG_TYPINGPACKET
A flag indicating that a packet is a typing-notification packet. |
| Constructor Summary | |
DirectImHeader()
Creates a new direct IM header with all values set to -1
or null, depending on type. |
|
DirectImHeader(DirectImHeader header)
Creates a new direct IM header object with the same properties as the given header object. |
|
| Method Summary | |
static DirectImHeader |
createMessageHeader(ImEncodedString message)
Creates a new direct IM header appropriate for sending the given message. |
static DirectImHeader |
createMessageHeader(ImEncodedString message,
boolean autoresponse)
Creates a new direct IM header appropriate for sending the given message. |
static DirectImHeader |
createTypedHeader()
Creates a new Direct IM header that indicates that the user has typed a message, but has momentarily stopped typing. |
static DirectImHeader |
createTypingErasedHeader()
Creates a new Direct IM header that indicates that the user has erased the message he or she had previously typed. |
static DirectImHeader |
createTypingHeader()
Creates a new Direct IM header that indicates that the user is typing a message. |
long |
getDataLength()
Returns the length of the message body data to follow this header. |
java.lang.String |
getDcVersion()
Returns the direct IM protocol version string sent in this header. |
ImEncodingParams |
getEncoding()
Returns an object describing the encoding being used for the message body to follow this header. |
long |
getFlags()
Returns a set of bit flags for this header. |
int |
getHeaderSize()
Returns the size of this header, in bytes, if read from an incoming stream. |
long |
getMessageId()
Returns the message ID for this header. |
java.lang.String |
getScreenname()
Returns the screenname sent in this header. |
static DirectImHeader |
readDirectIMHeader(java.io.InputStream in)
Creates a new Direct IM header from the data in the given stream. |
void |
setDataLength(long dataLength)
Sets the length of the message data to follow this header. |
void |
setDcVersion(java.lang.String dcVersion)
Sets the direct connection version string to send in this header. |
void |
setDefaults()
Sets some default values for this header. |
void |
setEncoding(ImEncodingParams encoding)
Sets the encoding method used to encode the message body to follow this header. |
void |
setFlags(long flags)
Sets the bit flags to send in this header. |
void |
setMessageId(long messageId)
Sets the message ID for this header. |
void |
setScreenname(java.lang.String sn)
Sets the screenname to send in this header. |
java.lang.String |
toString()
|
void |
write(java.io.OutputStream out)
Writes this header to the given stream. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final java.lang.String DCVERSION_DEFAULT
public static final long FLAG_TYPINGPACKET
FLAG_TYPING, the user is currently
typing a message.FLAG_TYPED, the user has typed a
message, but has momentarily stopped typing.FLAG_TYPING or
FLAG_TYPED, the user has erased any message he had previously
been typing.
public static final long FLAG_TYPING
FLAG_TYPINGPACKET, that
the user is typing a message.
public static final long FLAG_TYPED
FLAG_TYPINGPACKET, that
the user has typed a message, but has momentarily stopped typing.
public static final long FLAG_AUTORESPONSE
| Constructor Detail |
public DirectImHeader()
-1
or null, depending on type.
setDefaults()public DirectImHeader(DirectImHeader header)
header - a direct IM header object to copy| Method Detail |
public static DirectImHeader createTypingHeader()
FLAG_TYPINGPACKET | FLAG_TYPING.
public static DirectImHeader createTypedHeader()
FLAG_TYPINGPACKET | FLAG_TYPED.
public static DirectImHeader createTypingErasedHeader()
FLAG_TYPINGPACKET.
public static DirectImHeader createMessageHeader(ImEncodedString message)
message - a message for which a Direct IM header should be returned
public static DirectImHeader createMessageHeader(ImEncodedString message,
boolean autoresponse)
message - a message for which a Direct IM header should be returnedautoresponse - whether or not the given message is an
"auto-response"
public static DirectImHeader readDirectIMHeader(java.io.InputStream in)
throws java.io.IOException
null if no valid
header can be read.
in - the stream from which to read a direct IM header
null if none could be read
java.io.IOException - if an I/O error occurspublic final java.lang.String getDcVersion()
DCVERSION_DEFAULT.
public final long getMessageId()
public final long getDataLength()
public final ImEncodingParams getEncoding()
public final long getFlags()
FLAG_* flags. To test for a particular flag, one
might use code resembling the following:
if ((directImHeader.getFlags() & DirectImHeader.FLAG_AUTORESPONSE) != 0) {
System.out.println("Message is an auto-response!");
}
public final java.lang.String getScreenname()
public final int getHeaderSize()
-1 if this header was
not read from an incoming stream.
-1 if this
header was not read from an incoming streampublic final void setDcVersion(java.lang.String dcVersion)
dcVersion - the direct connection version string to send in this
headerpublic final void setMessageId(long messageId)
messageId - the message ID to send in this headerpublic final void setDataLength(long dataLength)
dataLength - the data length value to send in this headerpublic final void setEncoding(ImEncodingParams encoding)
null, a charset and
charsubset of 0 and 0 will be sent with this
command, suitable for sending a typing notification or other non-message
header.
encoding - the encoding method used to encode the message body to
follow this header, or null for nonepublic final void setFlags(long flags)
FLAG_* constants.
flags - a set of flags to send in this headerpublic final void setScreenname(java.lang.String sn)
sn - a screenname to send in this headerpublic final void setDefaults()
header.setDcVersion(DirectImHeader.DCVERSION_DEFAULT);
header.setDataLength(0);
header.setEncoding(null);
header.setFlags(0);
header.setScreenname("");
Note that a call to write(java.io.OutputStream) will never throw an
IllegalArgumentException if it has not been modified since
a call to this method.
public void write(java.io.OutputStream out)
throws java.io.IOException,
java.lang.IllegalArgumentException
| Field | Must be... |
|---|---|
dcVersion | non-null |
dataLength | nonnegative (0 or
greater) |
encoding | non-null |
flags | nonnegative (0 or
greater) |
screenname | non-null |
write in interface LiveWritableout - the stream to which to write
java.io.IOException - if an I/O error occurs
java.lang.IllegalArgumentException - if a field is invalidpublic java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||