KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gnu > kawa > xml > Focus


1 // Copyright (C) 2002, 2003 Per M.A. Bothner.
2
// This is free software; for terms and warranty disclaimer see ./COPYING.
3

4 package gnu.kawa.xml;
5 import gnu.lists.*;
6 import gnu.bytecode.*;
7 import gnu.expr.*;
8 import gnu.math.IntNum;
9
10 /** This is only used for XSLT, which should be fixed. */
11
12 public final class Focus extends TreePosition
13 {
14   /* #ifdef JAVA2 */
15   static ThreadLocal JavaDoc current = new ThreadLocal JavaDoc();
16   /* #endif */
17   /* #ifndef JAVA2 */
18   // static Focus current = new Focus();
19
/* #endif */
20
21   public static Focus getCurrent()
22   {
23     /* #ifdef JAVA2 */
24     Object JavaDoc obj = current.get();
25     if (obj == null)
26       {
27     obj = new Focus();
28     current.set(obj);
29       }
30     return (Focus) obj;
31     /* #endif */
32     /* #ifndef JAVA2 */
33     // return current;
34
/* #endif */
35   }
36
37   public long position;
38   IntNum contextPosition;
39
40   public static void compileGetCurrent(Compilation comp)
41   {
42     // FIXME This should be optimized so it only done once per method.
43
CodeAttr code = comp.getCode();
44     code.emitInvoke(getCurrentFocusMethod);
45   }
46
47   public static final ClassType TYPE = ClassType.make("gnu.kawa.xml.Focus");
48   static final Method getCurrentFocusMethod
49     = TYPE.getDeclaredMethod("getCurrent", 0);
50 }
51
Popular Tags