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.util.ResourceProperties;
20: import helma.framework.repository.Resource;
21:
22: import java.util.*;
23: import java.io.IOException;
24:
25: /**
26: * Documentation around a properties file
27: */
28: public class DocProperties extends DocResourceElement {
29:
30: ResourceProperties props;
31: String elementName;
32:
33: protected DocProperties(Resource res, ResourceProperties props,
34: int index, DocElement parent) throws IOException {
35: super (res.getShortName(), res, PROPERTIES);
36:
37: this .parent = parent;
38: this .props = props;
39: this .comment = resource.getName();
40: this .content = resource.getContent();
41: this .elementName = name + "_" + index;
42: }
43:
44: /**
45: * Get the underlying properties
46: *
47: * @return the properties
48: */
49: public ResourceProperties getProperties() {
50: return props;
51: }
52:
53: public String getElementName() {
54: return elementName;
55: }
56:
57: /**
58: * returns the comment string, empty string if no comment is set.
59: */
60: public String getComment() {
61: return resource.getName();
62: }
63:
64: /**
65: *
66: *
67: * @return ...
68: */
69: public Properties getMappings() {
70: Properties childProps = new Properties();
71:
72: for (Enumeration e = props.keys(); e.hasMoreElements();) {
73: String key = (String) e.nextElement();
74: String value = props.getProperty(key);
75:
76: if (value.startsWith("collection")
77: || value.startsWith("object")
78: || value.startsWith("mountpoint")) {
79: String prototype = value.substring(
80: value.indexOf("(") + 1, value.indexOf(")"))
81: .trim();
82:
83: childProps.setProperty(key, prototype);
84: }
85: }
86:
87: return childProps;
88: }
89:
90: /**
91: * from helma.framework.IPathElement. Use the same prototype as functions etc.
92: */
93: public java.lang.String getPrototype() {
94: return "docfunction";
95: }
96: }
|