Source Code Cross Referenced for NoteRecord.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:         * NOTE: Comment Associated with a Cell (1Ch)
024:         *
025:         * @author Yegor Kozlov
026:         */
027:        public class NoteRecord extends Record {
028:            public final static short sid = 0x1C;
029:
030:            /**
031:             * Flag indicating that the comment is hidden (default)
032:             */
033:            public final static short NOTE_HIDDEN = 0x0;
034:
035:            /**
036:             * Flag indicating that the comment is visible
037:             */
038:            public final static short NOTE_VISIBLE = 0x2;
039:
040:            private short field_1_row;
041:            private short field_2_col;
042:            private short field_3_flags;
043:            private short field_4_shapeid;
044:            private String field_5_author;
045:
046:            /**
047:             * Construct a new <code>NoteRecord</code> and
048:             * fill its data with the default values
049:             */
050:            public NoteRecord() {
051:                field_5_author = "";
052:                field_3_flags = 0;
053:            }
054:
055:            /**
056:             * Constructs a <code>NoteRecord</code> and fills its fields
057:             * from the supplied <code>RecordInputStream</code>.
058:             *
059:             * @param in the stream to read from
060:             */
061:            public NoteRecord(RecordInputStream in) {
062:                super (in);
063:
064:            }
065:
066:            /**
067:             * @return id of this record.
068:             */
069:            public short getSid() {
070:                return sid;
071:            }
072:
073:            /**
074:             * Checks the sid matches the expected side for this record
075:             *
076:             * @param id   the expected sid.
077:             */
078:            protected void validateSid(short id) {
079:                if (id != sid) {
080:                    throw new RecordFormatException("Not a NoteRecord record");
081:                }
082:            }
083:
084:            /**
085:             * Read the record data from the supplied <code>RecordInputStream</code>
086:             */
087:            protected void fillFields(RecordInputStream in) {
088:                field_1_row = in.readShort();
089:                field_2_col = in.readShort();
090:                field_3_flags = in.readShort();
091:                field_4_shapeid = in.readShort();
092:                int length = in.readShort();
093:                byte[] bytes = in.readRemainder();
094:                field_5_author = new String(bytes, 1, length);
095:            }
096:
097:            /**
098:             * Serialize the record data into the supplied array of bytes
099:             *
100:             * @param offset offset in the <code>data</code>
101:             * @param data the data to serialize into
102:             *
103:             * @return size of the record
104:             */
105:            public int serialize(int offset, byte[] data) {
106:                LittleEndian.putShort(data, 0 + offset, sid);
107:                LittleEndian.putShort(data, 2 + offset,
108:                        (short) (getRecordSize() - 4));
109:
110:                LittleEndian.putShort(data, 4 + offset, field_1_row);
111:                LittleEndian.putShort(data, 6 + offset, field_2_col);
112:                LittleEndian.putShort(data, 8 + offset, field_3_flags);
113:                LittleEndian.putShort(data, 10 + offset, field_4_shapeid);
114:                LittleEndian.putShort(data, 12 + offset, (short) field_5_author
115:                        .length());
116:
117:                byte[] str = field_5_author.getBytes();
118:                System.arraycopy(str, 0, data, 15 + offset, str.length);
119:
120:                return getRecordSize();
121:            }
122:
123:            /**
124:             * Size of record
125:             */
126:            public int getRecordSize() {
127:                int retval = 4 + 2 + 2 + 2 + 2 + 2 + 1
128:                        + field_5_author.length() + 1;
129:
130:                return retval;
131:            }
132:
133:            /**
134:             * Convert this record to string.
135:             * Used by BiffViewer and other utulities.
136:             */
137:            public String toString() {
138:                StringBuffer buffer = new StringBuffer();
139:
140:                buffer.append("[NOTE]\n");
141:                buffer.append("    .recordid = 0x"
142:                        + Integer.toHexString(getSid()) + ", size = "
143:                        + getRecordSize() + "\n");
144:                buffer.append("    .row =     " + field_1_row + "\n");
145:                buffer.append("    .col =     " + field_2_col + "\n");
146:                buffer.append("    .flags =   " + field_3_flags + "\n");
147:                buffer.append("    .shapeid = " + field_4_shapeid + "\n");
148:                buffer.append("    .author =  " + field_5_author + "\n");
149:                buffer.append("[/NOTE]\n");
150:                return buffer.toString();
151:            }
152:
153:            /**
154:             * Return the row that contains the comment
155:             *
156:             * @return the row that contains the comment
157:             */
158:            public short getRow() {
159:                return field_1_row;
160:            }
161:
162:            /**
163:             * Specify the row that contains the comment
164:             *
165:             * @param row the row that contains the comment
166:             */
167:            public void setRow(short row) {
168:                field_1_row = row;
169:            }
170:
171:            /**
172:             * Return the column that contains the comment
173:             *
174:             * @return the column that contains the comment
175:             */
176:            public short getColumn() {
177:                return field_2_col;
178:            }
179:
180:            /**
181:             * Specify the column that contains the comment
182:             *
183:             * @param col the column that contains the comment
184:             */
185:            public void setColumn(short col) {
186:                field_2_col = col;
187:            }
188:
189:            /**
190:             * Options flags.
191:             *
192:             * @return the options flag
193:             * @see #NOTE_VISIBLE
194:             * @see #NOTE_HIDDEN
195:             */
196:            public short getFlags() {
197:                return field_3_flags;
198:            }
199:
200:            /**
201:             * Options flag
202:             *
203:             * @param flags the options flag
204:             * @see #NOTE_VISIBLE
205:             * @see #NOTE_HIDDEN
206:             */
207:            public void setFlags(short flags) {
208:                field_3_flags = flags;
209:            }
210:
211:            /**
212:             * Object id for OBJ record that contains the comment
213:             */
214:            public short getShapeId() {
215:                return field_4_shapeid;
216:            }
217:
218:            /**
219:             * Object id for OBJ record that contains the comment
220:             */
221:            public void setShapeId(short id) {
222:                field_4_shapeid = id;
223:            }
224:
225:            /**
226:             * Name of the original comment author
227:             *
228:             * @return the name of the original author of the comment
229:             */
230:            public String getAuthor() {
231:                return field_5_author;
232:            }
233:
234:            /**
235:             * Name of the original comment author
236:             *
237:             * @param author the name of the original author of the comment
238:             */
239:            public void setAuthor(String author) {
240:                field_5_author = author;
241:            }
242:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.