pmHelpRepository.java revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*
* ident "%Z%%M% %I% %E% SMI"
*
* Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Database of help articles
*/
/*
* The help repository manages three distinct databases.
*
* helpItemDB: String tag -> pmHelpItem
* Returns a pmHelpItem given its unique tag.
* Used to resolve a reference from the app.
*
* helpKeywordDB: String -> Vector(of pmHelpItems)
* Returns a Vector containing all pmHelpItems whose `keywords'
* property contains the specifed keyword.
*
* helpTitleDB: String -> Vector (of pmHelpItems)
* Returns a Vector containing all pmHelpItems whose `title'
* property is a partial match for the specified string.
*/
final class pmHelpRepository {
// database of HelpItems, by tag string
static void populateHelpItemDB() {
helpItemDB = new Hashtable();
// Debug.message("HELP: helpItemDB: " + helpItemDB);
}
// database of Vectors of HelpItems, by keyword string
static void populateHelpKeywordDB() {
if (helpItemDB == null)
return;
/*
* Strategy:
* for each item
* for each keyword
* if kw not in db
* add ititem.tag
* add item to keyword entry
*/
helpKeywordDB = new Hashtable();
while (items.hasMoreElements()) {
while (keywords.hasMoreElements()) {
if (v == null)
v.addElement(item);
}
}
// Debug.message("HELP: KeywordDB: " + helpKeywordDB);
}
// database of HelpItems, by (partial) title string
static void populateHelpTitleDB() {
if (helpItemDB == null)
return;
/*
* strategy:
* assume itemDB is loaded
* for each item in itemDB
* create an entry in titleDB
*/
helpTitleDB = new BST();
while (items.hasMoreElements()) {
}
}
return null;
}
if (helpKeywordDB == null)
return null;
}
throws pmHelpException {
if (helpTitleDB == null)
return new Vector();
v.size() + " items");
return v;
}
// this should go in utils...
try {
try {
"com.sun.admin.pm.client.pmHelpResources");
} catch (MissingResourceException e) {
}
try {
} catch (MissingResourceException e) {
}
}
return keyvalue;
}
// from resources, presumably
static public void loadHelpItemDB() {
// Debug.setDebugLevel(new pmHelpRepository(), Debug.ALL);
/*
* strategy:
* for each tag name (from pmHelpTagNameEnumerator):
* get the property values from the resource bundle
*/
try {
"com.sun.admin.pm.client.pmHelpResources");
} catch (MissingResourceException e) {
return;
}
while (e.hasMoreElements()) {
try {
} catch (MissingResourceException x) {
continue;
}
if (s != null) {
v = new Vector();
st = new StringTokenizer(s);
while (st.hasMoreTokens())
item.setSeeAlso(v);
}
v = new Vector();
if (s != null) {
st = new StringTokenizer(s);
while (st.hasMoreTokens()) {
}
} else
" keywords is empty");
// insert item's title words into its keywords
while (st.hasMoreTokens()) {
// ignore useless words
" from " + theTitle);
continue;
}
" from " + theTitle);
v.addElement(word);
}
item.setKeywords(v);
}
}
}
// these words are not to be treated as keywords when they appear in title
static final private String
/* JSTYLED */
}