org.peaseplate.internal.util
Class EncodeUtils

java.lang.Object
  extended by org.peaseplate.internal.util.EncodeUtils

public class EncodeUtils
extends java.lang.Object


Constructor Summary
EncodeUtils()
           
 
Method Summary
protected static java.lang.String encode(org.peaseplate.internal.util.EncodeUtils.EscapeSequenceProducer producer, java.lang.Object value)
          Encodes the value by using the specified escape sequences.
protected static java.lang.String get4DigitHexValue(char value)
          Returns the 4-digit hex value of the character.
static java.lang.String toHTML(java.lang.Object value)
          Encodes the value using HTML entities.
static java.lang.String toHTML(java.lang.Object value, boolean encodeCRLF)
          Encodes the value using HTML entities.
static java.lang.String toHTML(java.lang.Object value, boolean encodeCRLF, boolean encodeSpace, int encodeTabBy)
          Encodes the value using HTML entities
static java.lang.String toJavaScript(java.lang.Object value)
          Encodes the value to be used in Javascript strings.
static java.lang.String toJSON(java.lang.Object value)
          Encodes the value to be used in JSON strings.
static java.lang.String toXML(java.lang.Object value)
          Encodes the value using XML entities
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodeUtils

public EncodeUtils()
Method Detail

toJavaScript

public static java.lang.String toJavaScript(java.lang.Object value)
Encodes the value to be used in Javascript strings.

Parameters:
context - the context
value - the value, may be null
Returns:
the encoded value

toJSON

public static java.lang.String toJSON(java.lang.Object value)
Encodes the value to be used in JSON strings.

Parameters:
value - the value, may be null
Returns:
the encoded value

toXML

public static java.lang.String toXML(java.lang.Object value)
Encodes the value using XML entities

Parameters:
value - the value, may be null
Returns:
the encoded (or empty) string

toHTML

public static java.lang.String toHTML(java.lang.Object value)
Encodes the value using HTML entities. Encodes encodes CR or LF or CRLF to <br />, does not touch spaces or tabs.

Parameters:
value - the value, may be null
Returns:
the encoded (or empty) string

toHTML

public static java.lang.String toHTML(java.lang.Object value,
                                      boolean encodeCRLF)
Encodes the value using HTML entities. Does not touch spaces or tabs.

Parameters:
value - the value, may be null
encodeCRLF - if set to true, this method encodes CR or LF or CRLF to <br />
Returns:
the encoded (or empty) string

toHTML

public static java.lang.String toHTML(java.lang.Object value,
                                      boolean encodeCRLF,
                                      boolean encodeSpace,
                                      int encodeTabBy)
Encodes the value using HTML entities

Parameters:
value - the value, may be null
encodeCRLF - if set to true, this method encodes \r or \n or \r\n to <br />
encodeSpace - if set to true, this method encodes spaces (0x20) to &nbsp;
encodeTabBy - if set to >= 0, this method encodes tabs to the specified amount of &nbsp;
Returns:
the encoded (or empty) string

encode

protected static java.lang.String encode(org.peaseplate.internal.util.EncodeUtils.EscapeSequenceProducer producer,
                                         java.lang.Object value)
Encodes the value by using the specified escape sequences.

Parameters:
producer - the producer for the escape sequenced
value - the value, may be null
Returns:
the encoded value or empty if null

get4DigitHexValue

protected static java.lang.String get4DigitHexValue(char value)
Returns the 4-digit hex value of the character. This method is performance optimized, even if it looks wierd.

Parameters:
value - the value
Returns:
the 4-digit hex value


Copyright © 2008. All Rights Reserved.