com.mindoo.xpages2eclipse.tools
Class StringConverter

java.lang.Object
  extended by com.mindoo.xpages2eclipse.tools.StringConverter

public class StringConverter
extends java.lang.Object

Various text conversion tools


Nested Class Summary
protected static class StringConverter.RTFEncoder
           
 
Constructor Summary
StringConverter()
           
 
Method Summary
static java.lang.String concatenateStrings(java.lang.String str1, java.lang.String str2, java.lang.String middleText, boolean middleTextIsHtml)
          Concatenates two strings.
static java.lang.String encodeInHTML(java.lang.String text)
          This method converts the provided plain text string into HTML compliant text, which for example can be inserted in the body of a HTML document
Example:
The method converts Test\nTest2 into Test<br>Test2
and it converts <b>Test</b> into &lt;b&gt;Test&lt;/b&gt;.
static java.lang.String encodeInRTF(java.lang.String text)
          Diese Methode konvertiert den plain-Text des übergebenen Strings in RTF-konformen Text.
static java.lang.String extractTextFromHtml(java.lang.String htmlText)
          Extracts the plain text from HTML
static java.lang.String getHexString(byte[] raw)
          Returns the given byte-array as a hex string.
static java.lang.String prepareForHTML(java.lang.String text)
          This method checks of the specified text contains HTML (searches for HTML tags at the beginning and the end of the string) and removes encosing HTML tags.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StringConverter

public StringConverter()
Method Detail

encodeInHTML

public static java.lang.String encodeInHTML(java.lang.String text)
This method converts the provided plain text string into HTML compliant text, which for example can be inserted in the body of a HTML document
Example:
The method converts Test\nTest2 into Test<br>Test2
and it converts <b>Test</b> into &lt;b&gt;Test&lt;/b&gt;.

Parameters:
text -
Returns:
encoded text

prepareForHTML

public static java.lang.String prepareForHTML(java.lang.String text)
This method checks of the specified text contains HTML (searches for HTML tags at the beginning and the end of the string) and removes encosing HTML tags. If the text is no HTML, it is converted into HTML by calling encodeInHTML(String). In any case, the returned text can get inserted directly into a HTML string.

Please note that we are not checking for valid HTML.

Parameters:
text - text to be converted
Returns:
converted text

concatenateStrings

public static java.lang.String concatenateStrings(java.lang.String str1,
                                                  java.lang.String str2,
                                                  java.lang.String middleText,
                                                  boolean middleTextIsHtml)
Concatenates two strings. If one of the strings is in HTML format, the second is also converted to HTML.

Parameters:
str1 - String 1
str2 - String 2
middleText - Text between both strings
Returns:
string

encodeInRTF

public static java.lang.String encodeInRTF(java.lang.String text)
Diese Methode konvertiert den plain-Text des übergebenen Strings in RTF-konformen Text.

Parameters:
text -
Returns:

extractTextFromHtml

public static java.lang.String extractTextFromHtml(java.lang.String htmlText)
Extracts the plain text from HTML

Parameters:
htmlText - HTML
Returns:
Text

getHexString

public static java.lang.String getHexString(byte[] raw)
                                     throws java.io.UnsupportedEncodingException
Returns the given byte-array as a hex string.

Parameters:
raw - the byte array
Returns:
the string
Throws:
java.io.UnsupportedEncodingException