1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
package org.webmacro.directive; |
24 | |
|
25 | |
import org.webmacro.Context; |
26 | |
import org.webmacro.FastWriter; |
27 | |
import org.webmacro.PropertyException; |
28 | |
import org.webmacro.engine.BuildContext; |
29 | |
import org.webmacro.engine.BuildException; |
30 | |
import org.webmacro.engine.Variable; |
31 | |
|
32 | |
import java.io.IOException; |
33 | |
|
34 | |
|
35 | |
|
36 | 0 | public class GlobalDirective extends Directive |
37 | |
{ |
38 | |
|
39 | |
private static final int GLOBAL_TARGET = 1; |
40 | |
|
41 | |
private static final ArgDescriptor[] |
42 | 0 | myArgs = new ArgDescriptor[]{ |
43 | |
new LValueArg(GLOBAL_TARGET), |
44 | |
}; |
45 | |
|
46 | |
private static final DirectiveDescriptor |
47 | 0 | myDescr = new DirectiveDescriptor("global", null, myArgs, null); |
48 | |
|
49 | |
public static DirectiveDescriptor getDescriptor () |
50 | |
{ |
51 | 0 | return myDescr; |
52 | |
} |
53 | |
|
54 | |
public Object build (DirectiveBuilder builder, |
55 | |
BuildContext bc) |
56 | |
throws BuildException |
57 | |
{ |
58 | 0 | Variable target = null; |
59 | |
|
60 | |
try |
61 | |
{ |
62 | 0 | target = (Variable) builder.getArg(GLOBAL_TARGET, bc); |
63 | |
} |
64 | 0 | catch (ClassCastException e) |
65 | |
{ |
66 | 0 | throw new NotVariableBuildException(myDescr.name, e); |
67 | 0 | } |
68 | 0 | if (!target.isSimpleName()) |
69 | 0 | throw new NotSimpleVariableBuildException(myDescr.name); |
70 | |
|
71 | 0 | bc.setVariableType(target.getName(), Variable.LOCAL_TYPE); |
72 | 0 | return null; |
73 | |
} |
74 | |
|
75 | |
public void write (FastWriter out, Context context) |
76 | |
throws PropertyException, IOException |
77 | |
{ |
78 | 0 | } |
79 | |
|
80 | |
} |