|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--net.sourceforge.foobase.CBFUtil
Class containing a number of usefull methods for old-style chessbase databases.
The code in this class consists of static methods.
| Field Summary | |
static java.lang.String |
__version
|
| Constructor Summary | |
CBFUtil()
|
|
| Method Summary | |
static java.lang.String |
bytesToString(byte[] bar,
int ofs,
int len)
Convert input byte array containing annotated text from a database to String format using the required encoding for this
package. |
static void |
decodeHeader(byte[] hdr)
Decode a game header from its file format. |
static void |
decodeHeaderText(byte[] hdrtxt)
Decode or encode the specified header text. |
static void |
encodeHeader(byte[] hdr)
Encode a game header into the file format. |
static char |
evalToString(byte b)
Convert an evaluation byte to proper internal code. |
static boolean |
isChecksumValid(byte[] hdr)
Compute checksum on decoded header and check if it matches the specified checksum in that header. |
static boolean |
isPreferredChecksumValid(byte[] hdr)
Compute checksum on decoded header and check if it matches the specified checksum in that header. |
static char |
movEvalToString(byte b)
Convert a move evaluation byte to proper internal code. |
static char |
posEvalToString(byte b)
Convert a position evaluation byte to proper internal code. |
static void |
setChecksum(byte[] hdr)
Set checksum in header data. |
static byte[] |
stringToBytes(java.lang.String s)
Convert a normalized string to byte array suitable for storage in oldstyle chessbase database. |
static byte |
stringToEval(java.lang.String s)
Convert an internal evaluation code to proper byte value. |
static byte |
stringToMovEval(java.lang.String s)
Convert an internal move evaluation code to proper byte value. |
static byte |
stringToPosEval(java.lang.String s)
Convert an internal position evaluation code to proper byte value. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Field Detail |
public static final java.lang.String __version
| Constructor Detail |
public CBFUtil()
| Method Detail |
public static void decodeHeader(byte[] hdr)
On return, the input buffer contains the decoded version of the header (this is an "in-place" operation)
hdr - byte[] containing the encoded 14-byte headerpublic static void encodeHeader(byte[] hdr)
On return, the input buffer contains the encoded version of the header (this is an "in-place" operation)
hdr - byte[] containing the 14-byte decoded headerpublic static void decodeHeaderText(byte[] hdrtxt)
Decoding decoded text results back in the original encoded text, so there is only one coding method required.
Coding occurs in place (that is: the input array is changed)
hdrtxt - byte[] containing the text to decodepublic static boolean isChecksumValid(byte[] hdr)
hdr - byte[] containing the 14-byte decoded header
databoolean value true if the computed
checksum matches the specified checksum.public static boolean isPreferredChecksumValid(byte[] hdr)
hdr - byte[] containing the 14-byte decoded header
databoolean value true if the computed
checksum matches the specified checksum.public static void setChecksum(byte[] hdr)
The computed checksum is stored in the input byte[].
hdr - byte]\ containing the 14-byte decoded header
data.
public static java.lang.String bytesToString(byte[] bar,
int ofs,
int len)
String format using the required encoding for this
package.bar - byte[] containing the input data to processofs - int containing the start offset from where to
process barlen - int containing the number of bytes to processString containing the input data with special
codes converted to symbolspublic static char evalToString(byte b)
b - byte to convertchar containing the internal code for the
evaluationpublic static byte stringToEval(java.lang.String s)
s - String to convertbyte containing the corresponding byte code to
store in oldstyle chessbase databases.public static char posEvalToString(byte b)
b - byte to convertchar containing the internal code for the
position evaluationpublic static byte stringToPosEval(java.lang.String s)
s - String to convertbyte containing the corresponding byte code to
store in oldstyle chessbase databases.public static char movEvalToString(byte b)
b - byte to convertchar containing the internal code for the
move evaluationpublic static byte stringToMovEval(java.lang.String s)
s - String to convertbyte containing the corresponding byte code to
store in oldstyle chessbase databases.public static byte[] stringToBytes(java.lang.String s)
s - String to convertbyte[] containing the converted string
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||