001: /*
002: * Helma License Notice
003: *
004: * The contents of this file are subject to the Helma License
005: * Version 2.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://adele.helma.org/download/helma/license.txt
008: *
009: * Copyright 1998-2003 Helma Software. All Rights Reserved.
010: *
011: * $RCSfile$
012: * $Author: root $
013: * $Revision: 8604 $
014: * $Date: 2007-09-28 15:16:38 +0200 (Fre, 28 Sep 2007) $
015: */
016:
017: package helma.doc;
018:
019: import helma.framework.core.Application;
020: import helma.framework.core.Prototype;
021: import helma.main.Server;
022: import helma.util.ResourceProperties;
023: import java.io.*;
024: import java.util.*;
025:
026: /**
027: *
028: */
029: public class DocApplication extends DocElement {
030:
031: Application app;
032: HashSet excluded;
033:
034: /**
035: * Creates a new DocApplication object.
036: *
037: */
038: public DocApplication(Application app) {
039: super (app.getName(), APPLICATION);
040: this .app = app;
041: readProps();
042: }
043:
044: /**
045: * reads the app.properties file and parses for helma.excludeDocs
046: */
047: private void readProps() {
048: ResourceProperties appProps = app.getProperties();
049:
050: excluded = new HashSet();
051: addExclude("cvs");
052: addExclude(".docs");
053:
054: String excludeProps = appProps.getProperty("helma.excludeDocs");
055:
056: if (excludeProps != null) {
057: StringTokenizer tok = new StringTokenizer(excludeProps, ",");
058:
059: while (tok.hasMoreTokens()) {
060: String str = tok.nextToken().trim();
061:
062: addExclude(str);
063: }
064: }
065: }
066:
067: /**
068: *
069: *
070: * @param str ...
071: */
072: public void addExclude(String str) {
073: excluded.add(str.toLowerCase());
074: }
075:
076: /**
077: *
078: *
079: * @param name ...
080: *
081: * @return ...
082: */
083: public boolean isExcluded(String name) {
084: return (excluded.contains(name.toLowerCase()));
085: }
086:
087: /**
088: * reads all prototypes and files of the application
089: */
090: public void readApplication() throws IOException {
091: readProps();
092: children.clear();
093:
094: Iterator it = app.getPrototypes().iterator();
095: // Iterator it = app.getRepositories().iterator();
096:
097: while (it.hasNext()) {
098:
099: Prototype proto = (Prototype) it.next();
100: proto.checkForUpdates();
101: DocPrototype pt = new DocPrototype(proto, this );
102: addChild(pt);
103: pt.readFiles();
104:
105: for (Iterator i = children.values().iterator(); i.hasNext();) {
106: ((DocPrototype) i.next()).checkInheritance();
107: }
108: }
109: }
110:
111: /**
112: *
113: *
114: * @return ...
115: */
116: public DocElement[] listFunctions() {
117: Vector allFunctions = new Vector();
118:
119: for (Iterator i = children.values().iterator(); i.hasNext();) {
120: DocElement proto = (DocElement) i.next();
121:
122: allFunctions.addAll(proto.children.values());
123: }
124:
125: Collections.sort(allFunctions, new DocComparator(
126: DocComparator.BY_NAME, this ));
127:
128: return (DocElement[]) allFunctions
129: .toArray(new DocElement[allFunctions.size()]);
130: }
131:
132: /**
133: * from helma.framework.IPathElement, overridden with "api"
134: * to work in manage-application
135: */
136: public String getElementName() {
137: return "api";
138: }
139:
140: /**
141: * from helma.framework.IPathElement, overridden with
142: * Server.getServer() to work in manage-application
143: */
144: public Object getParentElement() {
145: Server s = helma.main.Server.getServer();
146:
147: return s.getApplication(this.name);
148: }
149: }
|