de.speexx.pebble.decorator
Class Emoticon

java.lang.Object
  extended byde.speexx.pebble.decorator.Emoticon

public abstract class Emoticon
extends java.lang.Object

Contains the data of an emoticon and the functionality to replace the emoticon sequence, given by the regular expression with the HTML sequence given by getHtml().

Author:
Sascha Kohlmann

Constructor Summary
protected Emoticon()
          Simple default constructor.
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Adds an attribute for the HTML img element.
 java.util.Iterator attributeIterator()
          Returns an Iterator over the attribute names.
protected  void buildHtml()
          Build the <img> element.
 java.lang.String getAttributeValue(java.lang.String name)
          Returns the value for the given attribute name.
 java.lang.String getEmoticonRegex()
          Returns the emoticon regular expression to decorate in the content with an <img<>, element.
protected  java.lang.String getHtml()
          Returns the HTML representation of the emoticon.
 java.lang.String getImageUrl()
          Returns the src attribute part of an <img> element.
static Emoticon newInstance()
          Returns a new Emoticon instance.
 java.lang.StringBuffer replaceEmoticon(java.lang.StringBuffer content)
          Exchange the emoticon characters with an <img> element.
 void setEmoticonRegex(java.lang.String emoticon)
          Sets the regulare expression to decorate in the content with an <img<>, element.
 void setImageUrl(java.lang.String imageUrl)
          Sets the value of the src atribute in an <img> element.
 java.lang.String toString()
          Returns a String representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Emoticon

protected Emoticon()
Simple default constructor.

Method Detail

newInstance

public static Emoticon newInstance()
Returns a new Emoticon instance.

Returns:
a new Emoticon instance.

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
Adds an attribute for the HTML img element.

If you overwrite this method and don't call the super method, you must also overwrite attributeIterator() and getAttributeValue(String).

Parameters:
name - the attribute name.
value - the content of the attribute.
Throws:
java.lang.IllegalArgumentException - if name == null or value == null or if the length of name is zero.

attributeIterator

public java.util.Iterator attributeIterator()
Returns an Iterator over the attribute names.

If you overwrite this method and don't call the super method, you must also overwrite addAttribute(String, String) and getAttributeValue(String).

Returns:
an iterator over the attribute names.

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name)
Returns the value for the given attribute name.

If you overwrite this method and don't call the super method, you must also overwrite addAttribute(String, String) and attributeIterator().

Parameters:
name - the name of the attribute.
Returns:
the value of the attribute or null if the attribute does not exist.

getImageUrl

public java.lang.String getImageUrl()
Returns the src attribute part of an <img> element.

Returns:
the src attribute part of an <img> element.

setImageUrl

public void setImageUrl(java.lang.String imageUrl)
Sets the value of the src atribute in an <img> element.

Parameters:
imageUrl - the value of the src atribute in an <img> element.

getEmoticonRegex

public java.lang.String getEmoticonRegex()
Returns the emoticon regular expression to decorate in the content with an <img<>, element.

Returns:
the emoticon regular expression to decorate in the content with an <img<>, element.

setEmoticonRegex

public void setEmoticonRegex(java.lang.String emoticon)
                      throws java.util.regex.PatternSyntaxException
Sets the regulare expression to decorate in the content with an <img<>, element.

Parameters:
emoticon - thr regulare expression
Throws:
java.util.regex.PatternSyntaxException - if the emoticon pattern is illegal.

toString

public java.lang.String toString()
Returns a String representation of the object.

It's possible that the format of the Stringrepresentation will change in further versions.

Returns:
The String representation of the object.

getHtml

protected java.lang.String getHtml()
Returns the HTML representation of the emoticon.

Returns:
the HTML representation.

buildHtml

protected void buildHtml()
Build the <img> element.

Call this method after changing any data manipulation method (attribute and image URL).


replaceEmoticon

public java.lang.StringBuffer replaceEmoticon(java.lang.StringBuffer content)
Exchange the emoticon characters with an <img> element.

Parameters:
content - The content in which a the emoticon characters must be replaced
Returns:
The emoticon replaced content.
Throws:
java.lang.IllegalStateException - if getEmoticonRegex() returns null or getImageUrl() also returns null.


Copyright © 2005 . All Rights Reserved.