Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
IScriptProcessor |
|
| 1.0;1 |
1 | // Copyright 2004, 2005 The Apache Software Foundation |
|
2 | // |
|
3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
|
4 | // you may not use this file except in compliance with the License. |
|
5 | // You may obtain a copy of the License at |
|
6 | // |
|
7 | // http://www.apache.org/licenses/LICENSE-2.0 |
|
8 | // |
|
9 | // Unless required by applicable law or agreed to in writing, software |
|
10 | // distributed under the License is distributed on an "AS IS" BASIS, |
|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
12 | // See the License for the specific language governing permissions and |
|
13 | // limitations under the License. |
|
14 | ||
15 | package org.apache.tapestry; |
|
16 | ||
17 | import org.apache.hivemind.Resource; |
|
18 | ||
19 | /** |
|
20 | * Defines methods needed by a {@link org.apache.tapestry.IScript}to execute. |
|
21 | * |
|
22 | * @author Howard Lewis Ship |
|
23 | * @since 3.0 |
|
24 | * @see org.apache.tapestry.html.Body |
|
25 | */ |
|
26 | ||
27 | public interface IScriptProcessor |
|
28 | { |
|
29 | /** |
|
30 | * Adds scripting code to the main body. During the render, multiple scripts may render multiple |
|
31 | * bodies; all are concatinated together to form a single block. The |
|
32 | * {@link org.apache.tapestry.html.Body} component will write the body script contents |
|
33 | * just inside the <code><body></code> tag. |
|
34 | * |
|
35 | * @deprecated To be removed sometime after 4.1. |
|
36 | * @see {@link #addBodyScript(IComponent, String)} |
|
37 | */ |
|
38 | ||
39 | void addBodyScript(String script); |
|
40 | ||
41 | /** |
|
42 | * Adds scripting code to the main body. During the render, multiple scripts may render multiple |
|
43 | * bodies; all are concatinated together to form a single block. The |
|
44 | * {@link org.apache.tapestry.html.Body} component will write the body script contents |
|
45 | * just inside the <code><body></code> tag. |
|
46 | * |
|
47 | * @param target |
|
48 | * The component this script is being added for. |
|
49 | * @param script |
|
50 | * The script to add to the body response. |
|
51 | */ |
|
52 | void addBodyScript(IComponent target, String script); |
|
53 | ||
54 | /** |
|
55 | * Adds initialization script. Initialization script is executed once, when the containing page |
|
56 | * loads. Initialization script content is written only after all HTML content that could be |
|
57 | * referenced from the script (in effect, just before the <code></body></code> tag). |
|
58 | * |
|
59 | * @deprecated To be removed sometime after 4.1. |
|
60 | * @see {@link #addInitializationScript(IComponent, String)} |
|
61 | */ |
|
62 | void addInitializationScript(String script); |
|
63 | ||
64 | /** |
|
65 | * Adds initialization script. Initialization script is executed once, when the containing page |
|
66 | * loads. Initialization script content is written only after all HTML content that could be |
|
67 | * referenced from the script (in effect, just before the <code></body></code> tag). |
|
68 | * |
|
69 | * @param target |
|
70 | * The component the script is being added for. |
|
71 | * @param script |
|
72 | * The script to add. |
|
73 | */ |
|
74 | void addInitializationScript(IComponent target, String script); |
|
75 | ||
76 | /** |
|
77 | * Adds an external script. The processor is expected to ensure that external scripts are only |
|
78 | * loaded a single time per page. |
|
79 | * |
|
80 | * @deprecated To be removed sometime after 4.1 |
|
81 | * @see {@link #addExternalScript(IComponent, Resource)} |
|
82 | */ |
|
83 | ||
84 | void addExternalScript(Resource resource); |
|
85 | ||
86 | /** |
|
87 | * Adds an external script. The processor is expected to ensure that external scripts are only |
|
88 | * loaded a single time per page. The target will be checked to filter the scripts |
|
89 | * added for those types of responses that require them. |
|
90 | * |
|
91 | * @param target |
|
92 | * The component the script is being added for. |
|
93 | * @param resource |
|
94 | * The external script to add. |
|
95 | */ |
|
96 | void addExternalScript(IComponent target, Resource resource); |
|
97 | ||
98 | /** |
|
99 | * Determines if the specified component should have its javascript |
|
100 | * body added to the response. |
|
101 | * |
|
102 | * @param target |
|
103 | * The component to allow/disallow body script content from. |
|
104 | * @return True if the component script should be allowed. |
|
105 | */ |
|
106 | boolean isBodyScriptAllowed(IComponent target); |
|
107 | ||
108 | /** |
|
109 | * Determines if the specified component should have its javascript |
|
110 | * initialization added to the response. |
|
111 | * |
|
112 | * @param target |
|
113 | * The component to allow/disallow initialization script content from. |
|
114 | * @return True if the component script should be allowed. |
|
115 | */ |
|
116 | boolean isInitializationScriptAllowed(IComponent target); |
|
117 | ||
118 | /** |
|
119 | * Determines if the specified component should have its javascript |
|
120 | * external resource scripts added to the response. |
|
121 | * |
|
122 | * @param target |
|
123 | * The component to check for inclusion/exclusion. |
|
124 | * @return True if external scripts from this component should be added to |
|
125 | * the response. |
|
126 | */ |
|
127 | boolean isExternalScriptAllowed(IComponent target); |
|
128 | ||
129 | /** |
|
130 | * Ensures that the given string is unique. The string is either returned unchanged, or a suffix |
|
131 | * is appended to ensure uniqueness. |
|
132 | */ |
|
133 | ||
134 | String getUniqueString(String baseValue); |
|
135 | } |