Source Code Cross Referenced for EscherDgRecord.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » ddf » 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.ddf 
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.ddf;
019:
020:        import org.apache.poi.util.HexDump;
021:        import org.apache.poi.util.LittleEndian;
022:
023:        /**
024:         * This record simply holds the number of shapes in the drawing group and the
025:         * last shape id used for this drawing group.
026:         *
027:         * @author Glen Stampoultzis
028:         */
029:        public class EscherDgRecord extends EscherRecord {
030:            public static final short RECORD_ID = (short) 0xF008;
031:            public static final String RECORD_DESCRIPTION = "MsofbtDg";
032:
033:            private int field_1_numShapes;
034:            private int field_2_lastMSOSPID;
035:
036:            /**
037:             * This method deserializes the record from a byte array.
038:             *
039:             * @param data          The byte array containing the escher record information
040:             * @param offset        The starting offset into <code>data</code>.
041:             * @param recordFactory May be null since this is not a container record.
042:             * @return The number of bytes read from the byte array.
043:             */
044:            public int fillFields(byte[] data, int offset,
045:                    EscherRecordFactory recordFactory) {
046:                int bytesRemaining = readHeader(data, offset);
047:                int pos = offset + 8;
048:                int size = 0;
049:                field_1_numShapes = LittleEndian.getInt(data, pos + size);
050:                size += 4;
051:                field_2_lastMSOSPID = LittleEndian.getInt(data, pos + size);
052:                size += 4;
053:                //        bytesRemaining -= size;
054:                //        remainingData  =  new byte[bytesRemaining];
055:                //        System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
056:                return getRecordSize();
057:            }
058:
059:            /**
060:             * This method serializes this escher record into a byte array.
061:             *
062:             * @param offset   The offset into <code>data</code> to start writing the record data to.
063:             * @param data     The byte array to serialize to.
064:             * @param listener A listener to retrieve start and end callbacks.  Use a <code>NullEscherSerailizationListener</code> to ignore these events.
065:             * @return The number of bytes written.
066:             * @see NullEscherSerializationListener
067:             */
068:            public int serialize(int offset, byte[] data,
069:                    EscherSerializationListener listener) {
070:                listener.beforeRecordSerialize(offset, getRecordId(), this );
071:
072:                LittleEndian.putShort(data, offset, getOptions());
073:                LittleEndian.putShort(data, offset + 2, getRecordId());
074:                LittleEndian.putInt(data, offset + 4, 8);
075:                LittleEndian.putInt(data, offset + 8, field_1_numShapes);
076:                LittleEndian.putInt(data, offset + 12, field_2_lastMSOSPID);
077:                //        System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length );
078:                //        int pos = offset + 8 + 18 + remainingData.length;
079:
080:                listener.afterRecordSerialize(offset + 16, getRecordId(),
081:                        getRecordSize(), this );
082:                return getRecordSize();
083:            }
084:
085:            /**
086:             * Returns the number of bytes that are required to serialize this record.
087:             *
088:             * @return Number of bytes
089:             */
090:            public int getRecordSize() {
091:                return 8 + 8;
092:            }
093:
094:            public short getRecordId() {
095:                return RECORD_ID;
096:            }
097:
098:            /**
099:             * The short name for this record
100:             */
101:            public String getRecordName() {
102:                return "Dg";
103:            }
104:
105:            /**
106:             * Returns the string representation of this record.
107:             */
108:            public String toString() {
109:                String nl = System.getProperty("line.separator");
110:
111:                //        String extraData;
112:                //        ByteArrayOutputStream b = new ByteArrayOutputStream();
113:                //        try
114:                //        {
115:                //            HexDump.dump(this.remainingData, 0, b, 0);
116:                //            extraData = b.toString();
117:                //        }
118:                //        catch ( Exception e )
119:                //        {
120:                //            extraData = "error";
121:                //        }
122:                return getClass().getName() + ":" + nl + "  RecordId: 0x"
123:                        + HexDump.toHex(RECORD_ID) + nl + "  Options: 0x"
124:                        + HexDump.toHex(getOptions()) + nl + "  NumShapes: "
125:                        + field_1_numShapes + nl + "  LastMSOSPID: "
126:                        + field_2_lastMSOSPID + nl;
127:
128:            }
129:
130:            /**
131:             * The number of shapes in this drawing group.
132:             */
133:            public int getNumShapes() {
134:                return field_1_numShapes;
135:            }
136:
137:            /**
138:             * The number of shapes in this drawing group.
139:             */
140:            public void setNumShapes(int field_1_numShapes) {
141:                this .field_1_numShapes = field_1_numShapes;
142:            }
143:
144:            /**
145:             * The last shape id used in this drawing group.
146:             */
147:            public int getLastMSOSPID() {
148:                return field_2_lastMSOSPID;
149:            }
150:
151:            /**
152:             * The last shape id used in this drawing group.
153:             */
154:            public void setLastMSOSPID(int field_2_lastMSOSPID) {
155:                this .field_2_lastMSOSPID = field_2_lastMSOSPID;
156:            }
157:
158:            /**
159:             * Gets the drawing group id for this record.  This is encoded in the
160:             * instance part of the option record.
161:             *
162:             * @return  a drawing group id.
163:             */
164:            public short getDrawingGroupId() {
165:                return (short) (getOptions() >> 4);
166:            }
167:
168:            public void incrementShapeCount() {
169:                this.field_1_numShapes++;
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.