FileDocCategorySizeDatePackage
MkServices.javaAPI DocExample2221Sat Jul 21 11:10:06 BST 2001None

MkServices

public class MkServices extends Object

Fields Summary
protected static final String
INPUT_NAME
protected static final String
PUBLIC_NAME
protected static final String
LOGGEDIN_NAME
Constructors Summary
protected MkServices()

	// protected final static String TEASER_NAME = "restricted.html";


	    
	
Methods Summary
public static voidmain(java.lang.String[] argv)


		try {
			MkServices mk = new MkServices();
			mk.run();
		} catch (IOException e) {
			System.err.println(e.toString());
		}
	
public voidmkLink(java.io.PrintWriter out, java.lang.String url, java.lang.String name)

		out.println("<li><a href=\"" + url + "\" id=\"LinkLocal\">" + name + "</a></li>");
	
protected voidrun()

		BufferedReader is = new BufferedReader(new FileReader(INPUT_NAME));
		PrintWriter pub = new PrintWriter(new FileWriter(PUBLIC_NAME));
		PrintWriter logged = new PrintWriter(new FileWriter(LOGGEDIN_NAME));
		// PrintWriter teaser = new PrintWriter(new FileWriter(TEASER_NAME));
		String line;
		while ((line = is.readLine()) != null) {
			// Login:P:login.jsp
			// Search:L:search.jsp

			if (line.startsWith("#")) {		// comment
				continue;
			}

			StringTokenizer st = new StringTokenizer(line, ":");
			String name = st.nextToken();
			String perm = st.nextToken();
			String url = st.nextToken();

			// if P-only
			if (perm.indexOf('P")!=-1 && perm.indexOf('L")==-1) {
				mkLink(pub, url, name);
			} else
				// if L and P
				if (perm.indexOf('L")!=-1 && perm.indexOf('P")!=-1) {
					mkLink(pub, url, name);
					mkLink(logged, url, name);
			} else
				// if L and !P
				if (perm.indexOf('L")!=-1 && perm.indexOf('P")==-1) {
					mkLink(logged, url, name);
					pub.print("<li><i id=\"LinkLocal\">");
					pub.print(name);
					pub.println("</i>");
			} else if (perm.equals("E")) {	// Editorial
				// ignore for now
			}
			else if (perm.equals("A")) {	// Administration
				// ignore for now
			}
			else {
				System.err.println("WARNING: line " + line + 
					"--> has invalid permission tag " + perm);
			}
		}
		pub.close();
		logged.close();
		// teaser.close();