home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-05-26 | 1.6 KB | 78 lines |
- import java.io.*;
-
- /**
- * <code>BookMark</code> class is used to read/write PilotDoc bookmark records
- * @author Jeffrey A. Krzysztow
- * @author Pat Beirne
- * @version 1.1
- */
- public class BookMark {
- /**
- * the name of the bookmark
- * @since 1.0
- */
- public String name = ""; // 16 Bytes Bookmark name
-
- /**
- * offset into PilotDoc for this bookmark
- * @since 1.0
- */
- public int fileOffset = -1; // 4 DWord file offset
- // 20 bytes bookmark
-
- /**
- * The size of the BookMark in bytes
- * @returns the number of bytes in the BookMark
- * @since 1.0
- */
- public static int getSize() {
- return(20);
- }
-
- /**
- * Reads the BookMark from the DataInput
- * @param the DataInput to read from
- * @since 1.0
- */
- public void read(DataInput di) throws IOException {
- byte[] b = new byte[16];
- di.readFully(b);
- name = new String(b);
- int i = name.indexOf('\0');
- if(i >= 0) {
- name = name.substring(0, i);
- }
- fileOffset = di.readInt();
- }
-
- /**
- * Writes the BookMark to the DataInput
- * @param the DataInput to write to
- * @since 1.0
- */
- public void write(DataOutput out) throws IOException {
- byte[] b = new byte[16];
- byte[] bName = name.getBytes();
- for(int x=0; x < b.length; x++) {
- if(x < bName.length) {
- b[x] = bName[x];
- }
- else {
- b[x] = 0;
- }
- }
- out.write(b);
- out.writeInt(fileOffset);
- }
-
- /**
- * override Object.toString()
- * @since 1.0
- */
- public String toString() {
- return ">> BookMark <<\nname = `" + name
- + "`\nfileOffset = " + fileOffset;
- }
- }
-
-