001: /*
002: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
003: * NETSCAPE COMMUNICATIONS CORPORATION
004: *
005: * Copyright (c) 1996 Netscape Communications Corporation.
006: * All Rights Reserved.
007: * Use of this Source Code is subject to the terms of the applicable
008: * license agreement from Netscape Communications Corporation.
009: */
010:
011: package soif;
012:
013: import java.applet.Applet;
014:
015: import util.ReportError;
016:
017: /**
018: Lo, a header file.
019: *
020: */
021: public class Header {
022: /* ----------------------------------------------------------- */
023:
024: /**
025: * Version string.
026: */
027: public final static String VERSION = "SOIF Package";
028:
029: /**
030: * Long version string.
031: */
032: public final static String LONG_VERSION = VERSION;
033:
034: /* ----------------------------------------------------------- */
035:
036: /**
037: * Array of star gif names.
038: */
039: public final static String starPower[] = { "star0.gif",
040: "star0.gif", "star-5.gif", "star1.gif", "star1-5.gif",
041: "star2.gif", "star2-5.gif", "star3.gif", "star3-5.gif",
042: "star4.gif" };
043:
044: /**
045: * Prints the version string and, if the <b>dbgLvl</b> parameter
046: * includes the value <i>longVer</i>, also prints the long
047: * version of the version string.
048: * @param a the calling applet whose parameters are to be checked
049: */
050: public final static void printVersion(Applet a) {
051: String dbgString = a.getParameter("dbgLvl");
052:
053: if (dbgString != null) {
054: if (dbgString.indexOf("longVer") != -1) {
055: System.out.println(LONG_VERSION);
056: return;
057: }
058: }
059:
060: System.out.println(VERSION);
061: }
062:
063: /**
064: * Prints the version string and, if the <b>dbgLvl</b> parameter
065: * includes the value <i>longVer</i>, also prints the long
066: * version of the version string.
067: * @param b print long version, true or false
068: */
069: public final static void printVersion(boolean b) {
070: if (b) {
071: System.out.println(LONG_VERSION);
072: } else {
073: System.out.println(VERSION);
074: }
075: }
076:
077: /* ----------------------------------------------------------- */
078:
079: /**
080: * Macro for obtaining parameters and returning not found errors.
081: * @param param parameter
082: */
083: public final static String paramMacro(Applet applet, String param) {
084: String s = applet.getParameter(param);
085:
086: if (s == null) {
087: ReportError.reportError(ReportError.ADMIN, "Header",
088: "paramMacro", Messages.MISSINGPARAMETER + ": "
089: + param);
090: }
091:
092: return s;
093: }
094:
095: /**
096: * Build a CSID based on the codebase and expected application
097: * parameters host, port and name.
098: * @param app application
099: */
100: public final static CSID parameterCSIDMacro(Applet applet) {
101: CSID csid = new CSID(applet.getCodeBase().toString(), applet
102: .getParameter("host"), applet.getParameter("port"),
103: applet.getParameter("name"));
104:
105: if (csid.isValid() == false) {
106: ReportError.reportError(ReportError.ADMIN, "Header",
107: "parameterCSIDMacro", Messages.INVALIDCSID);
108: }
109:
110: return csid;
111: }
112: }
|