/* * RS.java - Reed-Solomon Decoder Main. * * ------------------------------------------------------------------ * * @begin[license] * Copyright (C) 2003 Kai Chen, Caltech * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * @author: Kai Chen * @email{kchen@cs.caltech.edu} * @end[license] * */ public class RS { /* ASCII values for certain chars */ private static final byte ASCII_1 = 0x31; private static final byte ASCII_A = 0x41; private static final byte ASCII_6 = 0x36; private static final byte ASCII_Z = 0x5A; private static final byte NUM_LETTERS = 26; public static void main(String[] args) { // build the GF we are working with int gfPoly[] = {1, 0, 1, 0, 0, 1}; GF gf = new GF(2, 5, gfPoly); // build the RS decoder RSDecoder decoder = new RSDecoder(gf, 16); RSJFrame frame = new RSJFrame(decoder); } /* * pre: s is the input string, 0 ... 31 are encoded as A, ..., Z, 1 ... 6 * post: parses the values 0 ... 31 into the array values[] * returns the number of chars parsed. */ public static int parse(String s, int values[]) { int i; char c[] = s.toUpperCase().toCharArray(); // incomplete input if(c.length < values.length) return -1; for(i=0; i=0 && values[i]<26) b[i] = new Integer(values[i]+ASCII_A).byteValue(); else if(values[i]>=26 && values[i]<32) b[i] = new Integer(values[i]+ASCII_1-NUM_LETTERS).byteValue(); else return null; } return new String(b); } }