org.jboss.portal.common.text
Class CharToByteEncoder.Generic

java.lang.Object
  extended by org.jboss.portal.common.text.CharToByteEncoder.Generic
All Implemented Interfaces:
CharToByteEncoder
Enclosing interface:
CharToByteEncoder

public static class CharToByteEncoder.Generic
extends java.lang.Object
implements CharToByteEncoder

Generic implementation that works for any charset, based on NIO.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.portal.common.text.CharToByteEncoder
CharToByteEncoder.Generic
 
Field Summary
static CharToByteEncoder.Generic UTF8
          .
 
Fields inherited from interface org.jboss.portal.common.text.CharToByteEncoder
EMPTY
 
Constructor Summary
CharToByteEncoder.Generic(java.nio.charset.Charset charset)
           
CharToByteEncoder.Generic(java.lang.String encoding)
           
 
Method Summary
 byte[] encode(char c)
          Encode the specified char.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8

public static final CharToByteEncoder.Generic UTF8
.

Constructor Detail

CharToByteEncoder.Generic

public CharToByteEncoder.Generic(java.nio.charset.Charset charset)

CharToByteEncoder.Generic

public CharToByteEncoder.Generic(java.lang.String encoding)
Method Detail

encode

public byte[] encode(char c)
              throws EncodingException
Description copied from interface: CharToByteEncoder
Encode the specified char. The returned byte array can be used safely until a new invocation to the same object is done. If the returned array has a length of zero it means that the char cannot be encoded.

Specified by:
encode in interface CharToByteEncoder
Parameters:
c - the char to encode
Returns:
the encoded char as a byte array
Throws:
EncodingException