spelhelper/src/main/java/net/abhinavsarkar/spelhelper/ReadOnlyGenericPropertyAcce...

28 lines
953 B
Java
Raw Normal View History

2010-05-26 19:00:31 +05:30
package net.abhinavsarkar.spelhelper;
import java.text.MessageFormat;
import org.springframework.expression.AccessException;
import org.springframework.expression.EvaluationContext;
import org.springframework.expression.PropertyAccessor;
public abstract class ReadOnlyGenericPropertyAccessor implements
2010-05-26 19:22:11 +05:30
PropertyAccessor {
2010-05-26 19:00:31 +05:30
2010-05-26 19:22:11 +05:30
public final boolean canWrite(final EvaluationContext context,
final Object target, final String name) throws AccessException {
return false;
}
2010-05-26 19:00:31 +05:30
2010-05-26 19:22:11 +05:30
@SuppressWarnings("unchecked")
2010-05-26 19:00:31 +05:30
public final Class[] getSpecificTargetClasses() {
2010-05-26 19:22:11 +05:30
return null;
}
2010-05-26 19:00:31 +05:30
2010-05-26 19:22:11 +05:30
public final void write(final EvaluationContext context, final Object target,
final String name, final Object newValue) throws AccessException {
throw new AccessException(MessageFormat.format(
"Cannot write property: {0} of target: {1}", name, target));
}
2010-05-26 19:00:31 +05:30
}