KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > PreviewManager


1 package com.icl.saxon;
2 import com.icl.saxon.om.*;
3 import com.icl.saxon.handlers.*;
4 import com.icl.saxon.expr.*;
5 import com.icl.saxon.output.*;
6
7 import org.xml.sax.*;
8 import java.util.*;
9
10
11 /**
12   * <B>PreviewManager</B> handles the registration of preview elements for use by the Builder
13   * @author Michael H. Kay (mhkay@iclway.co.uk)
14   */

15   
16 public class PreviewManager {
17
18     private int previewModeNameCode = -1;
19     private int[] previewElements = new int[10];
20     private int used = 0;
21     //private Controller controller = null;
22

23     //public void setController(Controller c) {
24
// controller = c;
25
//}
26

27     //public Controller getController() {
28
// return controller;
29
//}
30

31     /**
32     * Define the mode that will be used for previewing elements. The node handler for these
33     * elements is called while the tree is being built, as soon as the element end tag is
34     * encountered.
35     * @param mode The nameCode of the mode to be used
36     */

37
38     public void setPreviewMode(int mode) {
39         previewModeNameCode = mode;
40     }
41
42     public final int getPreviewMode() {
43         return previewModeNameCode;
44     }
45
46     /**
47     * Register an element as a preview element. If an element is so registered, the relevant
48     * node handler for preview mode will be called as soon as the element's end tag is read.
49     * The node handler must be registered in the normal way
50     */

51
52     public void setPreviewElement(int fingerprint) {
53         if (used>=previewElements.length) {
54             int[] n = new int[used*2];
55             System.arraycopy(previewElements, 0, n, 0, used);
56             previewElements = n;
57         }
58         previewElements[used++] = fingerprint;
59     }
60
61     /**
62     * Determine whether an element is a preview element.
63     */

64
65     public boolean isPreviewElement(int fingerprint) {
66         for (int i=0; i<used; i++) {
67             if (fingerprint == previewElements[i]) return true;
68         }
69         return false;
70     }
71
72
73 }
74
75 //
76
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
77
// you may not use this file except in compliance with the License. You may obtain a copy of the
78
// License at http://www.mozilla.org/MPL/
79
//
80
// Software distributed under the License is distributed on an "AS IS" basis,
81
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
82
// See the License for the specific language governing rights and limitations under the License.
83
//
84
// The Original Code is: all this file.
85
//
86
// The Initial Developer of the Original Code is
87
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
88
//
89
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
90
//
91
// Contributor(s): none.
92
//
93
Popular Tags