KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > gtk > GTKEngineParser


1 /*
2  * @(#)GTKEngineParser.java 1.7 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package com.sun.java.swing.plaf.gtk;
9
10 import java.io.IOException JavaDoc;
11
12 /**
13  * The abstract base class for all theme engine parsers.
14  *
15  * @author Shannon Hickey
16  * @version 1.7 12/19/03
17  */

18 abstract class GTKEngineParser {
19
20     protected final int uniqueScopeID = GTKScanner.getUniqueScopeID();
21
22     /**
23      * Parse the body of an 'engine' section of an rc file and store
24      * the results in a <CODE>GTKParser.EngineInfo<CODE> object.
25      * <P>
26      * This method takes three parameters. The first is a scanner to
27      * retrieve tokens from. Configuration options on the scanner may be
28      * changed by this method, but it must be sure to restore the previous
29      * values when it has completed. A typical implementation will also
30      * want to register its own symbols with the scanner. To do so, it should
31      * save the current scope of the scanner, and then set the scanner's scope
32      * to the value of 'uniqueScopeID'. Then, it should register its own
33      * symbols with the scanner if they don't already exist. The int value
34      * of every symbol registered must be > GTKScanner.TOKEN_LAST.
35      * At the successful completion of this method, the old scope should be
36      * restored, but the registered symbols can be left for the next use.
37      * <P>
38      * When this method is called, the scanner will be ready to return the first
39      * token inside the opening '{' of an engine section. Therefore, with the
40      * exception of returning early in error, this method must continue parsing
41      * until it sees a matching outer '}', even if it no longer has interest in
42      * the tokens returned.
43      * <P>
44      * The second parameter is the parser that called this method. It should
45      * not be modified in any way, and has been included only to make available
46      * its <CODE>resolvePixmapPath</CODE> method for resolving paths to images.
47      * <P>
48      * The last parameter will always be a single element array, for returning a
49      * <CODE>GTKParser.EngineInfo</CODE> object representing the information
50      * that was parsed. Upon invocation of this method, the array may already
51      * contain an info object. If so, it is guaranteed that it was created by this
52      * <CODE>GTKEngineParser</CODE> on a previous call to <CODE>parse</CODE>.
53      * As such, its type can be assumed. Typically, an implementation will
54      * want to append to, or merge with the information contained in any passed in
55      * info object.
56      * <P>
57      * Upon successful completion, the information parsed should be stored in
58      * a <CODE>GTKParser.EngineInfo</CODE> object as element 0 in the array
59      * parameter. This can be null if we wish to signify, for any reason, that
60      * that this entire engine section be thrown out and to use the default
61      * engine instead.
62      * <P>
63      * This method should return <CODE>GTKScanner.TOKEN_NONE</CODE>, if successful,
64      * otherwise the token that it expected but didn't get.
65      *
66      * @param scanner The scanner to retrieve tokens from.
67      * @param parser The parser that called us.
68      * @param retVal A single element array to store an object containing the
69      * information parsed.
70      *
71      * @return <CODE>GTKScanner.TOKEN_NONE</CODE> if the parse was successful,
72      * otherwise the token that was expected but not received.
73      */

74     abstract int parse(GTKScanner scanner,
75                        GTKParser parser,
76                        GTKParser.EngineInfo[] retVal) throws IOException JavaDoc;
77
78 }
79
Popular Tags