Package net.sf.cb2java.data

Examples of net.sf.cb2java.data.Record


     */
    public void testWeCanParseAlpha() throws FileNotFoundException, IOException {
        Copybook copybook = CopybookParser.parse("TYPES", new FileInputStream(new File("./src/test/resources/types.copybook")));
        assertEquals(16, copybook.getLength());
        List<Record> records = copybook.parseData(new FileInputStream(new File("./src/test/resources/types.txt")));
        Record record = records.get(0);
        assertEquals("!", record.getChild("TYPES").getChildren().get(0).getChildren().get(0).toString());
        assertEquals(">--------<", record.getChild("TYPES").getChildren().get(0).getChildren().get(1).toString());
    }
View Full Code Here


    }

    public void testWeCanParseIntegers() throws FileNotFoundException, IOException {
        Copybook copybook = CopybookParser.parse("TYPES", new FileInputStream(new File("./src/test/resources/types.copybook")));
        List<Record> records = copybook.parseData(new FileInputStream(new File("./src/test/resources/types.txt")));
        Record record = records.get(0);
        GroupData integers = (GroupData) record.getChild("TYPES").getChildren().get(1);
        assertEquals(BigInteger.ZERO, integers.getChild("ZEROH").getValue());
        assertEquals(BigInteger.ONE,  integers.getChild("ONE").getValue());
        assertEquals(BigInteger.valueOf(9),   integers.getChild("NINE").getValue());
    }
View Full Code Here

    }

    public void testWeCanParseNegativeIntegers() throws FileNotFoundException, IOException {
        Copybook copybook = CopybookParser.parse("TYPES", new FileInputStream(new File("./src/test/resources/types.copybook")));
        List<Record> records = copybook.parseData(new FileInputStream(new File("./src/test/resources/types.txt")));
        Record record = records.get(0);
        GroupData integers = (GroupData) record.getChild("TYPES").getChildren().get(1);
        // todo assertEquals(BigInteger.valueOf(-1),  integers.getChild("MINUSONE").getValue());
        // todo assertEquals(BigInteger.valueOf(-65), integers.getChild("MINUSSIXTYFIVE").getValue());
        // todo assertEquals(BigInteger.valueOf(-82), integers.getChild("EIGHTYTWO").getValue());
    }
View Full Code Here

     *
     * @return a new empty application data instance
     */
    public Record createNew()
    {
        return new Record(getName(), (GroupData) super.create());
    }
View Full Code Here

    public void testWeCanParseCopybookData() throws FileNotFoundException, IOException {
        Copybook copybook = CopybookParser.parse("B", new FileInputStream(new File("./target/test-classes/b.copybook")));
        assertEquals(31, copybook.getLength());
        List<Record> results = copybook.parseData(new FileInputStream(new File("./target/test-classes/b.input.txt")));
        assertEquals(1, results.size());
        Record record = results.get(0);
        Data root = record.getChild("ROOT");
        assertEquals("ABCDEF", root.getChildren().get(0).toString());
        assertEquals("B", ((Data)root.getChildren().get(1)).getName().toString());
        assertEquals("BCDE", root.getChildren().get(1).toString());
        // TODO assertEquals(12345, root.getChildren().get(2).toString());
        // TODO assertEquals(1234, ((Data)root.getChildren().get(3)).getValue());
View Full Code Here

     * @return a new application data element with the given data
     * @throws IOException
     */
    public Record parseData(byte[] data) throws IOException
    {
        return new Record(getName(), (GroupData) parse(data));
    }
View Full Code Here

    {
        ByteBuffer buffer = new ByteBuffer(stream);       
        List<Record> list = new ArrayList<Record>();
       
        while (buffer.hasNext()) {
            list.add(new Record(getName(), (GroupData) parse(buffer.getNext())));
        }
       
        return list;
    }
View Full Code Here

TOP

Related Classes of net.sf.cb2java.data.Record

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.