|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ScriptUsage.java | 0% | 0% | 0% | 0% |
|
1 |
/*
|
|
2 |
* Joey and its relative products are published under the terms
|
|
3 |
* of the Apache Software License.
|
|
4 |
*/
|
|
5 |
/*
|
|
6 |
* Created on 2004/01/08
|
|
7 |
*/
|
|
8 |
package org.asyrinx.brownie.tapestry.script;
|
|
9 |
|
|
10 |
import org.apache.tapestry.IComponent;
|
|
11 |
import org.apache.tapestry.IRequestCycle;
|
|
12 |
|
|
13 |
/**
|
|
14 |
* @author akima
|
|
15 |
*/
|
|
16 |
public abstract class ScriptUsage { |
|
17 |
|
|
18 | 0 |
public boolean canWrite(IComponent component, IRequestCycle cycle) { |
19 | 0 |
final String key = key(component); |
20 | 0 |
final boolean result = cycle.getAttribute(key) == null; |
21 | 0 |
if (result)
|
22 | 0 |
cycle.setAttribute(key, this);
|
23 | 0 |
return result;
|
24 |
} |
|
25 |
|
|
26 | 0 |
protected String key(IComponent component) {
|
27 | 0 |
return null; |
28 |
} |
|
29 |
|
|
30 |
public static final ScriptUsage ONCE_BY_CLASS = new ScriptUsage() { |
|
31 | 0 |
protected String key(IComponent component) {
|
32 | 0 |
return component.getClass().getName();
|
33 |
} |
|
34 |
}; |
|
35 |
|
|
36 |
public static final ScriptUsage ONCE_BY_OBJECT = new ScriptUsage() { |
|
37 | 0 |
protected String key(IComponent component) {
|
38 | 0 |
return component.getClass().getName() + "." + component.hashCode(); |
39 |
} |
|
40 |
}; |
|
41 |
|
|
42 |
public static final ScriptUsage EVERYTIME = new ScriptUsage() { |
|
43 | 0 |
public boolean canWrite(IComponent component, IRequestCycle cycle) { |
44 | 0 |
return true; |
45 |
} |
|
46 |
}; |
|
47 |
|
|
48 |
} |
|