Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.runtime.output

public final Class Encoded

extends Object
Class Inheritance
Imports
java.io.IOException

Buffer for UTF-8 encoded string. See http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 for the UTF-8 encoding.
Author
Kohsuke Kawaguchi

Field Summary

Modifier and TypeField and Description
private static final byte[][]
public byte[]
private static final byte[][]
entities

UTF-8 encoded entities keyed by their character code.

public int

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
private static void
add(char c, String s, boolean attOnly)

public void
append(char b)

Appends a new character to the end of the buffer.

public void
compact()

Reallocate the buffer to the exact size of the data to reduce the memory footprint.

public void
ensureSize(int size)

public void
set(String text)

public void
setEscape(String text, boolean
if true, characters like \t, \r, and \n are also escaped.
isAttribute
)

Fill in the buffer by encoding the specified characters while escaping characters like <

public void
write(UTF8XmlOutput out)

Writes the encoded bytes to the given output stream.

private int
writeEntity(byte[] entity, int ptr)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeEntitiesback to summary
private static final byte[][] attributeEntities
bufback to summary
public byte[] buf
entitiesback to summary
private static final byte[][] entities

UTF-8 encoded entities keyed by their character code. e.g., entities['&'] == AMP_ENTITY. In attributes we need to encode more characters.

lenback to summary
public int len

Constructor Detail

Encodedback to summary
public Encoded()
Encodedback to summary
public Encoded(String text)

Method Detail

addback to summary
private static void add(char c, String s, boolean attOnly)
appendback to summary
public void append(char b)

Appends a new character to the end of the buffer. This assumes that you have enough space in the buffer.

compactback to summary
public void compact()

Reallocate the buffer to the exact size of the data to reduce the memory footprint.

ensureSizeback to summary
public void ensureSize(int size)
setback to summary
public void set(String text)
setEscapeback to summary
public void setEscape(String text, boolean isAttribute)

Fill in the buffer by encoding the specified characters while escaping characters like <

Parameters
isAttribute:boolean

if true, characters like \t, \r, and \n are also escaped.

writeback to summary
public void write(UTF8XmlOutput out) throws IOException

Writes the encoded bytes to the given output stream.

writeEntityback to summary
private int writeEntity(byte[] entity, int ptr)