From c046cab54a99233f6fffb068c3358d6f3874c047 Mon Sep 17 00:00:00 2001 From: "Andrew C. Oliver" Date: Sun, 17 Mar 2002 00:39:26 +0000 Subject: added stuff for generating hdf type records git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352238 13f79535-47bb-0310-9956-ffa450edef68 --- src/types/styles/hdftype.xsl | 263 ++++++++++++++++++++++++++++++++++ src/types/styles/hdftype_document.xsl | 51 +++++++ src/types/styles/hdftype_test.xsl | 130 +++++++++++++++++ 3 files changed, 444 insertions(+) create mode 100644 src/types/styles/hdftype.xsl create mode 100644 src/types/styles/hdftype_document.xsl create mode 100644 src/types/styles/hdftype_test.xsl (limited to 'src') diff --git a/src/types/styles/hdftype.xsl b/src/types/styles/hdftype.xsl new file mode 100644 index 0000000000..b284315d93 --- /dev/null +++ b/src/types/styles/hdftype.xsl @@ -0,0 +1,263 @@ + + + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache POI" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache POI", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + + +package ; + + + +import org.apache.poi.util.BitField; +import org.apache.poi.util.LittleEndian; +import org.apache.poi.util.StringUtil; +import org.apache.poi.util.HexDump; + +/** + * + * NOTE: This source is automatically generated please do not modify this file. Either subclass or + * remove the record in src/records/definitions. + + */ +public class Type + extends HDFType +{ + public final static short sid = ; + private ; + + + + public Type() + { + + + = ; + + } + + /** + * Constructs a record and sets its fields appropriately. + * + * @param id id must be or an exception + * will be throw upon validation + * @param size size the size of the data area of the record + * @param data data of the record (should not contain sid/len) + */ + + public Type(short id, short size, byte [] data) + { + super(id, size, data); + } + + /** + * Constructs a record and sets its fields appropriately. + * + * @param id id must be or an exception + * will be throw upon validation + * @param size size the size of the data area of the record + * @param data data of the record (should not contain sid/len) + * @param offset of the record's data + */ + + public Type(short id, short size, byte [] data, int offset) + { + super(id, size, data, offset); + } + + /** + * Checks the sid matches the expected side for this record + * + * @param id the expected sid. + */ + protected void validateSid(short id) + { + if (id != sid) + { + throw new HDFTypeFormatException("Not a record"); + } + } + + protected void fillFields(byte [] data, short size, int offset) + { + + + = ; + + } + + public String toString() + { + StringBuffer buffer = new StringBuffer(); + + buffer.append("[]\n"); + + buffer.append("[/]\n"); + return buffer.toString(); + } + + public int serialize(int offset, byte[] data) + { + LittleEndian.putShort(data, 0 + offset, sid); + LittleEndian.putShort(data, 2 + offset, (short)(getSize() - 4)); + + + + + + return getSize(); + } + + /** + * Size of record (exluding 4 byte header) + */ + public int getSize() + { + + return 4 + + + +; + } + + public short getSid() + { + return this.sid; + } + + + + +} // END OF CLASS + + + + + + + + + + /** + * Sets the field value. + * + */ + public void set(boolean value) + { + = .setBoolean(, value); + } + + /** + * + * @return the field value. + */ + public boolean is() + { + return .isSet(); + } + + + + private BitField = new BitField(); + + public final static = ; + + + + + * + + + /** + * Get the field for the record. + * + * @return One of + */ + public get() + { + return ; + } + + /** + * Set the field for the record. + * + * @param + * One of + */ + public void set( ) + { + this. = ; + } + + + + buffer.append(" . = ") + .append("0x") + .append(HexDump.toHex(()get())) + .append(" (").append(get()).append(" )\n"); + + + + buffer.append(" . = ").append(is()).append('\n'); + + + + * @author + + + diff --git a/src/types/styles/hdftype_document.xsl b/src/types/styles/hdftype_document.xsl new file mode 100644 index 0000000000..5ca751cc30 --- /dev/null +++ b/src/types/styles/hdftype_document.xsl @@ -0,0 +1,51 @@ + + + + +
+ <xsl:value-of select="@name"/> Documentation For HDF Type +
+ + + +

+

+
+ + + + + + + + + + +
NameSizeOffsetDescriptionDefault Value
+
+ +
+ + Copyright (c) @year@ The Poi Project All rights reserved. + $Revision$ $Date$ + +
+ +
+
+ + + + + + + + + + + +
diff --git a/src/types/styles/hdftype_test.xsl b/src/types/styles/hdftype_test.xsl new file mode 100644 index 0000000000..def9d802ae --- /dev/null +++ b/src/types/styles/hdftype_test.xsl @@ -0,0 +1,130 @@ + + + +/* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2002 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" and + * "Apache POI" must not be used to endorse or promote products + * derived from this software without prior written permission. For + * written permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache", + * "Apache POI", nor may "Apache" appear in their name, without + * prior written permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + */ + + +package ; + + +import junit.framework.TestCase; + +/** + * Tests the serialization and deserialization of the Type + * class works correctly. Test data taken directly from a real + * Excel file. + * + + */ +public class TestType + extends TestCase +{ + byte[] data = new byte[] { + // PASTE DATA HERE + }; + + public TestType(String name) + { + super(name); + } + + public void testLoad() + throws Exception + { + + Type type = new Type((short), (short)data.length, data); + assertEquals( XXX, type.get()); + + + + assertEquals( XXX, type.getSize() ); + + type.validateSid((short)); + } + + public void testStore() + { + Type type = new Type(); + type.set( XXXX ); + + + + byte [] typeBytes = type.serialize(); + assertEquals(typeBytes.length - 4, data.length); + for (int i = 0; i < data.length; i++) + assertEquals("At offset " + i, data[i], typeBytes[i+4]); + } +} + + + + * @author + + + + assertEquals( XXX, type.is() ); + + + + + type.set( XXX ); + + + + -- cgit v1.2.3