|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.components.serializers.encoding.AbstractCharset org.apache.cocoon.components.serializers.encoding.CompiledCharset
public abstract class CompiledCharset
Field Summary | |
---|---|
protected byte[] |
encoding
The encoding table of this Charset . |
Constructor Summary | |
---|---|
protected |
CompiledCharset(String name,
String[] aliases)
Create a new instance of this CompiledCharset . |
protected |
CompiledCharset(String name,
String[] aliases,
byte[] encoding)
Create a new instance of this CompiledCharset . |
Method Summary | |
---|---|
boolean |
allows(char c)
Check if the specified character is representable by this specifiec Charset instance. |
protected void |
compile()
Compile the encoding table of this CompiledCharset . |
protected abstract boolean |
compile(char c)
Return true or false wether this encoding can encode the specified character or not. |
Methods inherited from class org.apache.cocoon.components.serializers.encoding.AbstractCharset |
---|
equals, equals, getAliases, getName, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected byte[] encoding
Charset
.
Constructor Detail |
---|
protected CompiledCharset(String name, String[] aliases)
CompiledCharset
.
After construction, the compile()
method will have to
be called for proper operation of this Charset
.
name
- This Charset
name.aliases
- This Charset
alias names.
NullPointerException
- If one of the arguments is null.protected CompiledCharset(String name, String[] aliases, byte[] encoding) throws NullPointerException, IllegalArgumentException
CompiledCharset
.
The encodings table passed to this constructor needs to be 8192 bytes long, or (in other words), must contain exactly 65536 bits.
As in the Java Programming Language a char
can assume
values between 0 (zero) and 65535 (inclusive), each bit in the specified
array refers to a specific char
value.
When this specific bit is set to 1 (one or true) we assume that the
charset can encode the given character, while when the bit is
set to 0 (zero or false), the character cannot be represented using
this Charset
.
For example, the US-ASCII Charset
can represent
only Java characters between 0 (zero) and 255 (inclusive), therefore
the specified byte array will contain only 256 true bits.
To check if a character can be encoded by this Charset
,
given "c
" as the character to verify, one
can write this simple formula:
((encoding[c >> 3] & (1 << (c & 0x07))) > 0)
If the result of this operation is 0 (zero) the bit was set to zero,
and therefore "c
" cannot be represented in
this Charset
, while if the result is greater than 0 (zero)
the character "c
" can actually be represented
by this Charset
name
- This Charset
name.aliases
- This Charset
alias names.encoding
- This Charset
encoding table as specified
above.
NullPointerException
- If one of the arguments is null.
IllegalArgumentException
- If the length of the encoding table
is not 8192 precisely.Method Detail |
---|
public boolean allows(char c)
Charset
instance.
protected final void compile()
CompiledCharset
.
This method will invoke the compile(...)
method for any
possible value of a Java character (65536 times, from 0, zero, to
65535 inclusive), building the encoding table of the characters this
Charset
can successfully represent.
protected abstract boolean compile(char c)
This method is equivalent to the allows(...)
method, but
it will be called upon construction of the encoding table.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |