Last change
on this file since 6452 was 6452, checked in by cs025, 20 years ago |
New Metadata type; also extended factory method to support the type and
minor alterations to HTMLRecogniser.
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | package org.greenstone.gsdl3.gs3build.doctypes;
|
---|
2 |
|
---|
3 | import java.sql.SQLException;
|
---|
4 | import java.sql.ResultSet;
|
---|
5 |
|
---|
6 | import org.greenstone.gsdl3.gs3build.util.GS3SQLConnection;
|
---|
7 |
|
---|
8 | public class DocumentFactory
|
---|
9 | {
|
---|
10 | public static AbstractDocument createDocument(String type, DocumentID id)
|
---|
11 | {
|
---|
12 | if (type.equals(HTMLDocument.HTML_DOCUMENT_TYPE))
|
---|
13 | { return new HTMLDocument(id);
|
---|
14 | }
|
---|
15 | else if (type.equals(TextDocument.TEXT_DOCUMENT_TYPE))
|
---|
16 | { return new TextDocument(id);
|
---|
17 | }
|
---|
18 | else if (type.equals(IndexDocument.INDEX_DOCUMENT_TYPE))
|
---|
19 | { return new IndexDocument(id);
|
---|
20 | }
|
---|
21 | else if (type.equals(MetadataDocument.METADATA_DOCUMENT_TYPE))
|
---|
22 | { return new MetadataDocument(id);
|
---|
23 | }
|
---|
24 | return null;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public static DocumentInterface readSQLDocument(GS3SQLConnection connection, DocumentID id)
|
---|
28 | {
|
---|
29 | String query = "SELECT * FROM document WHERE DocID=\""+id.toString()+"\";";
|
---|
30 | connection.execute(query);
|
---|
31 |
|
---|
32 | try {
|
---|
33 | ResultSet results = connection.getResultSet();
|
---|
34 | if (results != null && results.first()) {
|
---|
35 | return AbstractDocument.readSQL(connection, results);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | catch (SQLException sqlEx) {
|
---|
39 | System.err.println(sqlEx);
|
---|
40 | }
|
---|
41 | return null;
|
---|
42 | }
|
---|
43 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.