Source Code Cross Referenced for UnknownRecord.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » record » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Collaboration » poi 3.0.2 beta2 » org.apache.poi.hssf.record 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.hssf.record;
019:
020:        import org.apache.poi.util.LittleEndian;
021:
022:        /**
023:         * Title:        Unknown Record (for debugging)<P>
024:         * Description:  Unknown record just tells you the sid so you can figure out
025:         *               what records you are missing.  Also helps us read/modify sheets we
026:         *               don't know all the records to.  (HSSF leaves these alone!) <P>
027:         * Company:      SuperLink Software, Inc.<P>
028:         * @author Andrew C. Oliver (acoliver at apache dot org)
029:         * @author Jason Height (jheight at chariot dot net dot au)
030:         * @author Glen Stampoultzis (glens at apache.org)
031:         */
032:
033:        public class UnknownRecord extends Record {
034:            private short sid = 0;
035:            private byte[] thedata = null;
036:
037:            public UnknownRecord() {
038:            }
039:
040:            /**
041:             * @param id    id of the record -not validated, just stored for serialization
042:             * @param data  the data
043:             */
044:            public UnknownRecord(short id, byte[] data) {
045:                this .sid = id;
046:                this .thedata = data;
047:            }
048:
049:            /**
050:             * construct an unknown record.  No fields are interperated and the record will
051:             * be serialized in its original form more or less
052:             * @param in the RecordInputstream to read the record from
053:             */
054:
055:            public UnknownRecord(RecordInputStream in) {
056:                sid = in.getSid();
057:                thedata = in.readRemainder();
058:
059:                //System.out.println("UnknownRecord: 0x"+Integer.toHexString(sid));
060:            }
061:
062:            /**
063:             * spit the record out AS IS.  no interpretation or identification
064:             */
065:            public int serialize(int offset, byte[] data) {
066:                if (thedata == null) {
067:                    thedata = new byte[0];
068:                }
069:                LittleEndian.putShort(data, 0 + offset, sid);
070:                LittleEndian.putShort(data, 2 + offset,
071:                        (short) (thedata.length));
072:                if (thedata.length > 0) {
073:                    System.arraycopy(thedata, 0, data, 4 + offset,
074:                            thedata.length);
075:                }
076:                return getRecordSize();
077:            }
078:
079:            public int getRecordSize() {
080:                int retval = 4;
081:
082:                if (thedata != null) {
083:                    retval += thedata.length;
084:                }
085:                return retval;
086:            }
087:
088:            protected void fillFields(byte[] data, short sid) {
089:                this .sid = sid;
090:                thedata = data;
091:            }
092:
093:            /**
094:             * NO OP!
095:             */
096:
097:            protected void validateSid(short id) {
098:
099:                // if we had a valid sid we wouldn't be using the "Unknown Record" record now would we?
100:            }
101:
102:            /**
103:             * print a sort of string representation ([UNKNOWN RECORD] id = x [/UNKNOWN RECORD])
104:             */
105:
106:            public String toString() {
107:                StringBuffer buffer = new StringBuffer();
108:
109:                buffer.append("[UNKNOWN RECORD:" + Integer.toHexString(sid)
110:                        + "]\n");
111:                buffer.append("    .id        = ").append(
112:                        Integer.toHexString(sid)).append("\n");
113:                buffer.append("[/UNKNOWN RECORD]\n");
114:                return buffer.toString();
115:            }
116:
117:            public short getSid() {
118:                return sid;
119:            }
120:
121:            /**
122:             * called by the constructor, should set class level fields.  Should throw
123:             * runtime exception for bad/icomplete data.
124:             *
125:             * @param in the RecordInputstream to read the record from
126:             */
127:
128:            protected void fillFields(RecordInputStream in) {
129:                throw new RecordFormatException(
130:                        "Unknown record cannot be constructed via offset -- we need a copy of the data");
131:            }
132:
133:            /** Unlike the other Record.clone methods this is a shallow clone*/
134:            public Object clone() {
135:                UnknownRecord rec = new UnknownRecord();
136:                rec.sid = sid;
137:                rec.thedata = thedata;
138:                return rec;
139:            }
140:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.