01: /*
02: * Helma License Notice
03: *
04: * The contents of this file are subject to the Helma License
05: * Version 2.0 (the "License"). You may not use this file except in
06: * compliance with the License. A copy of the License is available at
07: * http://adele.helma.org/download/helma/license.txt
08: *
09: * Copyright 1998-2003 Helma Software. All Rights Reserved.
10: *
11: * $RCSfile$
12: * $Author: root $
13: * $Revision: 8604 $
14: * $Date: 2007-09-28 15:16:38 +0200 (Fre, 28 Sep 2007) $
15: */
16:
17: package helma.doc;
18:
19: import helma.framework.repository.Repository;
20: import helma.framework.repository.Resource;
21:
22: import java.io.*;
23:
24: /**
25: *
26: */
27: public abstract class DocRepositoryElement extends DocElement {
28:
29: protected Repository repos;
30:
31: // a default file that is read as comment for applications
32: // and prototypes if found in their directories
33: public static final String[] DOCFILES = { "doc.html", "doc.htm",
34: "app.html", "app.htm", "prototype.html", "prototype.htm",
35: "index.html", "index.htm" };
36:
37: protected DocRepositoryElement(String name, Repository repos,
38: int type) throws IOException {
39: super (name, type);
40: this .repos = repos;
41: checkCommentFiles();
42: }
43:
44: /**
45: * Get a string describing this element's location
46: *
47: * @return lstring representation of the element's repository
48: */
49: public String toString() {
50: return repos.getName();
51: }
52:
53: /**
54: * @return absolute path to location of element
55: * (directory for apps and prototypes, file for
56: * methods and properties files)
57: */
58: public Repository getRepository() {
59: return repos;
60: }
61:
62: private void checkCommentFiles() throws IOException {
63: if (repos == null) {
64: return;
65: }
66: for (int i = 0; i < DOCFILES.length; i++) {
67: Resource res = repos.getResource(DOCFILES[i]);
68:
69: if (res.exists()) {
70: String rawComment = res.getContent();
71: parseComment(rawComment);
72: return;
73: }
74: }
75: }
76: }
|