01: package com.teamkonzept.lib.math;
02:
03: public class UnaryLogicalOperator extends UnaryOperator {
04:
05: final static int NOT = 0;
06:
07: int type;
08:
09: public UnaryLogicalOperator(int type, int parenlevel, int position)
10: throws UnsupportedOperatorException {
11: super (parenlevel, getPriority(type, position), position);
12: this .type = type;
13: }
14:
15: public Object evaluate(Object target)
16: throws BadOperandTypeException {
17: if (!(target instanceof Boolean))
18: throw new BadOperandTypeException(target, "Boolean");
19: return new Boolean(!((Boolean) target).booleanValue());
20: }
21:
22: static int getPriority(int op, int position)
23: throws UnsupportedOperatorException {
24: switch (op) {
25: case NOT:
26: return LOGICAL_NOT_PRIORITY;
27: default:
28: throw new UnsupportedOperatorException(
29: UnaryLogicalOperator.class, op, position);
30: }
31: }
32:
33: }
|