| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
package org.apache.tapestry5.internal.bindings; |
| 16 | |
|
| 17 | |
import org.apache.tapestry5.PropertyConduit; |
| 18 | |
import org.apache.tapestry5.internal.services.Invariant; |
| 19 | |
import org.apache.tapestry5.ioc.Location; |
| 20 | |
import org.apache.tapestry5.ioc.internal.util.TapestryException; |
| 21 | |
|
| 22 | |
import java.lang.annotation.Annotation; |
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
public class PropBinding extends AbstractBinding |
| 29 | |
{ |
| 30 | |
private final Object root; |
| 31 | |
|
| 32 | |
private final PropertyConduit conduit; |
| 33 | |
|
| 34 | |
private final String toString; |
| 35 | |
|
| 36 | |
private boolean invariant; |
| 37 | |
|
| 38 | |
public PropBinding(final Location location, final Object root, final PropertyConduit conduit, final String toString |
| 39 | |
) |
| 40 | |
{ |
| 41 | 7077 | super(location); |
| 42 | |
|
| 43 | 7077 | this.root = root; |
| 44 | 7077 | this.conduit = conduit; |
| 45 | 7077 | this.toString = toString; |
| 46 | |
|
| 47 | 7077 | invariant = conduit.getAnnotation(Invariant.class) != null; |
| 48 | 7077 | } |
| 49 | |
|
| 50 | |
|
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
public Object get() |
| 55 | |
{ |
| 56 | |
try |
| 57 | |
{ |
| 58 | 208123 | return conduit.get(root); |
| 59 | |
} |
| 60 | 4 | catch (Exception ex) |
| 61 | |
{ |
| 62 | 4 | throw new TapestryException(ex.getMessage(), getLocation(), ex); |
| 63 | |
} |
| 64 | |
} |
| 65 | |
|
| 66 | |
@Override |
| 67 | |
public void set(Object value) |
| 68 | |
{ |
| 69 | |
try |
| 70 | |
{ |
| 71 | 77704 | conduit.set(root, value); |
| 72 | |
} |
| 73 | 4 | catch (Exception ex) |
| 74 | |
{ |
| 75 | 4 | throw new TapestryException(ex.getMessage(), getLocation(), ex); |
| 76 | 77700 | } |
| 77 | 77700 | } |
| 78 | |
|
| 79 | |
@Override |
| 80 | |
public String toString() |
| 81 | |
{ |
| 82 | 6 | return toString; |
| 83 | |
} |
| 84 | |
|
| 85 | |
|
| 86 | |
|
| 87 | |
|
| 88 | |
|
| 89 | |
@Override |
| 90 | |
public boolean isInvariant() |
| 91 | |
{ |
| 92 | 293295 | return invariant; |
| 93 | |
} |
| 94 | |
|
| 95 | |
@Override |
| 96 | |
public Class getBindingType() |
| 97 | |
{ |
| 98 | 78248 | return conduit.getPropertyType(); |
| 99 | |
} |
| 100 | |
|
| 101 | |
@Override |
| 102 | |
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) |
| 103 | |
{ |
| 104 | 488 | return conduit.getAnnotation(annotationClass); |
| 105 | |
} |
| 106 | |
} |