|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.kano.joscar.OscarTools
Provides a set of tools for performing OSCAR-specific functions.
Nested Class Summary | |
static class |
OscarTools.HttpHeaderInfo
A structure containing HTTP header information along with the binary data sent in the HTTP stream. |
Method Summary | |
static java.lang.String |
getInfoString(ByteBlock infoData,
java.lang.String infoType)
Returns a string given its binary representation and one of AIM's text/x-aolrtf; charset=us-ascii content-type strings. |
static java.lang.String |
getRoomNameFromCookie(java.lang.String cookie)
Returns the name of the chat room described by the given "cookie" or "chat room URL." |
static java.lang.String |
getString(ByteBlock data,
java.lang.String charset)
Creates a String from the given block of data and the given
charset. |
static java.lang.String |
getValidCharset(java.lang.String charset)
Returns the given charset if it is supported by the JVM; if it is not supported, attempts to fix it and returns the "fixed" version. |
static java.lang.String |
normalize(java.lang.String str)
Returns a "normalized" version of the given string by removing all spaces and converting to lowercase. |
static java.util.Map |
parseContentTypeString(java.lang.String str)
Converts a string like text/x-aolrtf;
charset=us-ascii to a Map with two keys:
text/x-aolrtf (value null ) and
charset (value us-ascii ). |
static OscarTools.HttpHeaderInfo |
parseHttpHeader(ByteBlock data)
Extracts HTTP header information and the block of data being sent in the HTTP stream from a block of binary data. |
static StringBlock |
readScreenname(ByteBlock data)
Reads a screenname which is preceded by a single byte describing the screenname's length from the given block of data. |
static java.lang.String |
stripHtml(java.lang.String str)
Uses a poorly conceived method to remove HTML from a string. |
static void |
writeScreenname(java.io.OutputStream out,
java.lang.String sn)
Writes the given screenname to the given stream, preceded by a single byte containing the screenname's length in bytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static StringBlock readScreenname(ByteBlock data)
null
if no such valid object can be read.
data
- the block containing a single-byte length followed by a
screen name in US-ASCII format
public static void writeScreenname(java.io.OutputStream out, java.lang.String sn) throws java.io.IOException
out
- the stream to write tosn
- the screenname to write to the given stream
java.io.IOException
- if an I/O error occurspublic static java.util.Map parseContentTypeString(java.lang.String str)
text/x-aolrtf;
charset=us-ascii
to a Map
with two keys:
text/x-aolrtf
(value null
) and
charset
(value us-ascii
).
str
- the content type string
public static java.lang.String getInfoString(ByteBlock infoData, java.lang.String infoType)
text/x-aolrtf; charset=us-ascii
content-type strings.
infoData
- the binary representation of the stringinfoType
- an AIM content-type string
public static java.lang.String getValidCharset(java.lang.String charset)
charset
is null
,
"US-ASCII"
will be returned.
charset
- the charset name to "fix"
public static java.lang.String getString(ByteBlock data, java.lang.String charset)
String
from the given block of data and the given
charset. Note that this will never return null
, even
if the given charset
is null
. This method will
do its best to produce a String
from the given data using
getValidCharset
.
data
- a block of data containing a stringcharset
- the name of a charset to use to extract a string from the
given data, or null
for US-ASCII
String
decoded from the given block of datapublic static java.lang.String normalize(java.lang.String str)
str
- the string to normalize
public static java.lang.String stripHtml(java.lang.String str)
str
- the string from which to strip HTML tags
public static OscarTools.HttpHeaderInfo parseHttpHeader(ByteBlock data)
\r
, \n
,
and \r\n
.
Content-Type: text/x-aolrtf Content-Encoding: binary <HTML>I am a banana</HTML>
ByteBlock input = ...; OscarTools.HttpHeaderInfo hinfo = OscarTools.parseHttpHeader(input); System.out.println("Content type of input is " + hinfo.get("content-type")); System.out.println("Content encoding of input is " + hinfo.get("Content-Encoding")); System.out.println("message text is " + ByteBlock.createString(hinfo.getData(), "US-ASCII");
data
- the block of data containing an HTTP header followed by data
public static final java.lang.String getRoomNameFromCookie(java.lang.String cookie)
MiniRoomInfo.getCookie()
for details.
For example, with the input "!aol://2719:11-4-room%20name"
,
this method will return "room name"
.
cookie
- a chat room "cookie"
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |