LibreOffice Module xmerge (master) 1
PalmDocument.java
Go to the documentation of this file.
1/*
2 * This file is part of the LibreOffice project.
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 *
8 * This file incorporates work covered by the following license notice:
9 *
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
17 */
18
19package org.openoffice.xmerge.converter.palm;
20
21import java.io.IOException;
22import java.io.InputStream;
23import java.io.ByteArrayOutputStream;
24
25import java.io.OutputStream;
26import java.io.UnsupportedEncodingException;
27
29
37public class PalmDocument
38 implements Document {
39
41 private PalmDB pdb;
42
45
53 public PalmDocument(InputStream is) throws IOException {
54 read(is);
55 }
56
71 public PalmDocument(String name, int creatorID, int typeID, int version,
72 short attribute, Record[] recs)
73 throws UnsupportedEncodingException {
74 pdb = new PalmDB(name, creatorID, typeID, version, attribute, recs);
76 }
77
85 public void read(InputStream is) throws IOException {
86 PdbDecoder decoder = new PdbDecoder();
87 ByteArrayOutputStream baos = new ByteArrayOutputStream();
88 byte[] buf = new byte[4096];
89 int n;
90 while ((n = is.read(buf)) > 0) {
91 baos.write(buf, 0, n);
92 }
93 byte[] bytearr = baos.toByteArray();
94 pdb = decoder.parse(bytearr);
96 }
97
105 public void write(OutputStream os) throws IOException {
106 PdbEncoder encoder = new PdbEncoder(pdb);
107 encoder.write(os);
108 }
109
115 public PalmDB getPdb() {
116 return pdb;
117 }
118
124 public void setPdb(PalmDB pdb) {
125 this.pdb = pdb;
126
128 fileName = name;
129 }
130
137 return fileName + ".pdb";
138 }
139
145 public String getName() {
146 return fileName;
147 }
148}
This class contains data for a single Palm database for use during a conversion process.
Definition: PalmDB.java:59
String getPDBNameString()
Return the PDB name associated with this object.
Definition: PalmDB.java:284
A PalmDocument is palm implementation of the Document interface.
void write(OutputStream os)
Writes the PalmDocument to an OutputStream.
PalmDB getPdb()
Returns the PalmDB contained in this object.
void setPdb(PalmDB pdb)
Sets the PalmDocument to a new PalmDB value.
PalmDocument(InputStream is)
Constructor to create a PalmDocument from an InputStream.
String getFileName()
Returns the name of the file.
String getName()
Returns the Document name.
void read(InputStream is)
Reads in a file from the InputStream.
PalmDB pdb
The internal representation of a pdb.
PalmDocument(String name, int creatorID, int typeID, int version, short attribute, Record[] recs)
Constructor to create a PalmDocument with Record objects.
Provides functionality to decode a PDB formatted file into a PalmDB object given an InputStream.
Definition: PdbDecoder.java:51
PalmDB parse(byte[] b)
This method decodes a PDB file into a PalmDB object.
Definition: PdbDecoder.java:67
Provides functionality to encode a PalmDB object into a PDB formatted file given a file OutputStream.
Definition: PdbEncoder.java:44
void write(OutputStream os)
Write out a PDB into the given OutputStream.
Contains the raw bytes for a Record in a PDB.
Definition: Record.java:35
const char * name
A Document represents any Document to be converted and the resulting Document from any conversion.
Definition: Document.java:36
sal_Int64 n
CFUUIDRef typeID
Provides interfaces for converting between two Document formats, and supports a "merge" interface for...
Definition: Convert.java:19
sal_Int32 attribute