|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object MessageElement MutableMessageElement
A mutable object model element which can be output as a Yahoo IM or chat encoded message. This object is akin to a DOM element, acting as a container in the case of style types like bold, colours and fades; and a leaf in the case of texts.
Root
|
+--Bold
| |
| +--Text ("Hello ")
|
+--Text ("world!")
The above four node'd tree, for example, would represent "Hello world!"
This class implements the interface java.util.List
and
contains all its list manipulation methods. Use these to add and
remove MutableMessageElement
nodes to form a tree.
Please do not include classes other than MutableMessageElement
(or a subclass) as nodes when building a tree. Future implementations
may employ Java 1.5's generics to enforce this restriction.
Note: Yahoo appears to be in the process of changing over its escape based encoding scheme to something a little like XML tags. So far examples of the new scheme have only been seen on chatrooms. At some point this class should be modified to allow the switching between 'old' and 'new' encoding styles...
Name | Old | New |
Bold | [esc]1m | <b> |
Italic | [esc]2m | <i> |
Colour (enum) | [esc]3?m | <'colour name'> |
Colour (abs) | [esc]3#RRGGBBm | <#RRGGBB> |
Font | <font ... > | |
Fade | <fade ... > | |
Alt | <alt ... > |
Note: Yahoo's colour escape codes do not work as containers - that is to say they do not have a close 'code' which undoes their effect. For as long as Yahoo uses escape codes rather than proper SGML-style containers (<abc>...</abc>) this code offers overloaded methods to 'fake' containers via a stack of colours, so that 'pseudo' end codes can be added by simply repeating the colour code above the 'closing' element in the stack.
Field Summary |
Fields inherited from class MessageElement |
ALT, BOLD, COLOUR_ABS, COLOUR_INDEX, COLOUR_NAME, FADE, FONT, ITALIC, NULL, ROOT, TEXT, UNDERLINE |
Fields inherited from interface Emoticons |
ALIEN, ANGEL, ANGER, APPLAUSE, BEAT_UP, BLUSH, BRING_IT_ON, BROKEN_HEART, BUG, CHATTERBOX, CHICKEN, CLOWN, COFFEE, CONFUSED, COOL, COW, COWBOY, CRYING, DANCING, DEVILISH, DOH, DROOLING, EMOTICONS, EYEBROW, EYELASHES, FLAG, FRUSTRATED, GO_ON, GOOD_LUCK, GRIN, HUGS, HYPNOTIZED, IDEA, KISS, LAUGHING, LIAR_LIAR, LOSER, LOVE_STRUCK, MONEY_EYES, MONKEY, NAIL_BITING, NERD, NOT_TALKING, NOT_WORTHY, PARTY, PEACE, PHBBBBT, PIG, PRAYING, PUMPKIN, ROFL, ROLLING_EYES, ROSE, SAD, SHAME_ON_YOU, SHHH, SHOCK, SICK, SIGH, SILLY, SKULL, SLEEP, SMILE, SMUG, STAR, STRAIGHT_FACE, TALK_TO_HAND, TEE_HEE, THINKING, TIRED, TONGUE, WAITING, WHEW, WHISTLING, WINK, WORRIED |
Constructor Summary | |
MutableMessageElement()
|
Method Summary | |
static MutableMessageElement |
createAbsoluteColour(Color c)
Creates a new MutableMessageElement defined as a colour element. |
static MutableMessageElement |
createAlt(Color[] c)
Creates a new MutableMessageElement defined as a alt element. |
static MutableMessageElement |
createBold()
Creates a new MutableMessageElement defined as a bold element. |
static MutableMessageElement |
createFade(Color[] c)
Creates a new MutableMessageElement defined as a fade element. |
static MutableMessageElement |
createFont(Font f)
Creates a new MutableMessageElement defined as a font element. |
static MutableMessageElement |
createIndexedColour(int idx)
Creates a new MutableMessageElement defined as a colour element. |
static MutableMessageElement |
createItalic()
Creates a new MutableMessageElement defined as a italic element. |
static MutableMessageElement |
createNamedColour(String n)
Creates a new MutableMessageElement defined as a colour element. |
static MutableMessageElement |
createRoot()
Creates a new MutableMessageElement defined as a root element. |
static MutableMessageElement |
createText(String text)
Creates a new MutableMessageElement defined as a text element. |
static MutableMessageElement |
createUnderline()
Creates a new MutableMessageElement defined as a underline element. |
Color |
getAbsoluteColour()
Returns the content from an absolute colour element. |
Font |
getFont()
Returns the content from a font element. |
int |
getIndexedColour()
Returns the content from an index colour element. |
String |
getNamedColour()
Returns the content from a named colour element. |
String |
getText()
Returns the content from a text element. |
Color[] |
getTransition()
Returns the content from a fade or alt element. |
int |
getType()
Returns the type of this element. |
void |
setAbsoluteColour(Color c)
Sets content in an absolute colour element. |
void |
setFont(Font f)
Sets content in a font element. |
void |
setIndexedColour(int i)
Sets content in an indexed colour element. |
void |
setNamedColour(String n)
Sets content in a named colour element. |
void |
setText(String t)
Sets content in a text element. |
void |
setTransition(Color[] c)
Sets content in a fade or alt element. |
String |
toYahooChat()
Translates this message structure (from this node down) into a Yahoo chat message. |
String |
toYahooChat(boolean fc)
Translates this message structure (from this node down) into a Yahoo chat message. |
String |
toYahooIM()
Translates this message structure (from this node down) into a Yahoo instant message. |
String |
toYahooIM(boolean fc)
Translates this message structure (from this node down) into a Yahoo instant message. |
Methods inherited from class MessageElement |
appendToDocument, toHTML, toString, toText |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface List |
add, add, addAll, addAll, clear, contains, containsAll, equals, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, retainAll, set, size, subList, toArray, toArray |
Constructor Detail |
public MutableMessageElement()
Method Detail |
public static MutableMessageElement createRoot()
public static MutableMessageElement createText(String text)
text
- text content
public static MutableMessageElement createBold()
public static MutableMessageElement createItalic()
public static MutableMessageElement createIndexedColour(int idx)
idx
- Yahoo colour index
public static MutableMessageElement createNamedColour(String n)
n
- Yahoo colour name
public static MutableMessageElement createAbsoluteColour(Color c)
c
- absolute colour as AWT Color
public static MutableMessageElement createUnderline()
public static MutableMessageElement createFont(Font f)
f
- AWT font object
public static MutableMessageElement createFade(Color[] c)
c
- array of AWT Color objects
public static MutableMessageElement createAlt(Color[] c)
c
- array of AWT Color objects
public int getType()
MessageElement
, for a list of
possible return values.
public String getText() throws IllegalStateException
IllegalStateException
- if not a text elementpublic void setText(String t) throws IllegalStateException
t
- content text
IllegalStateException
- if not a text elementpublic int getIndexedColour() throws IllegalStateException
IllegalStateException
- if not an index colour elementpublic void setIndexedColour(int i) throws IllegalStateException
i
- content index
IllegalStateException
- if not an index colour elementpublic String getNamedColour() throws IllegalStateException
IllegalStateException
- if not a named colour elementpublic void setNamedColour(String n) throws IllegalStateException
n
- content name
IllegalStateException
- if not a named colour elementpublic Color getAbsoluteColour() throws IllegalStateException
IllegalStateException
- if not an absolute colour elementpublic void setAbsoluteColour(Color c) throws IllegalStateException
c
- content AWT Color
IllegalStateException
- if not an absolute colour elementpublic Font getFont() throws IllegalStateException
IllegalStateException
- if not a font elementpublic void setFont(Font f) throws IllegalStateException
f
- content AWT Font
IllegalStateException
- if not a font elementpublic Color[] getTransition() throws IllegalStateException
IllegalStateException
- if not a fade or alt elementpublic void setTransition(Color[] c) throws IllegalStateException
c
- content AWT Color array
IllegalStateException
- if not a fade or alt elementpublic String toYahooIM()
public String toYahooIM(boolean fc)
Old Yahoo colour encodings use escape codes, not SGML-style containers, and as such there is no closing 'tag' to revert to the enclosing colour. But the effect of a closing tag can be 'faked' by simply re-including the parent escape code as a pseudo closing tag, to set the colour back to the parent.
Note: when Yahoo moves entirely to SGML-style message encoding, and drops support from escape codes, it may be possible to deprecate this method.
fc
- true will force containers closed
public String toYahooChat()
public String toYahooChat(boolean fc)
Old Yahoo colour encodings use escape codes, not SGML-style containers, and as such there is no closing 'tag' to revert to the enclosing colour. But the effect of a closing tag can be 'faked' by simply re-including the parent escape code as a pseudo closing tag, to set the colour back to the parent.
Note: when Yahoo moves entirely to SGML-style message encoding, and drops support from escape codes, it may be possible to deprecate this method.
fc
- true will force containers closed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |