1 16 package org.apache.ws.jaxme.sqls.impl; 17 18 import java.util.ArrayList ; 19 import java.util.List ; 20 21 import org.apache.ws.jaxme.sqls.Case; 22 import org.apache.ws.jaxme.sqls.Column; 23 import org.apache.ws.jaxme.sqls.Column.Type; 24 25 26 29 public class CaseImpl implements Case { 30 33 public static class WhenImpl implements When { 34 private final Object condition, value; 35 38 public WhenImpl(Object pCondition, Object pValue) { 39 condition = ValueImpl.asValue(pCondition); 40 value = ValueImpl.asValue(pValue); 41 } 42 public Object getCondition() { return condition; } 43 public Object getValue() { return value; } 44 } 45 46 private final Column.Type type; 47 private Object checkedValue, elseValue; 48 private List whens = new ArrayList (); 49 50 52 protected CaseImpl(Column.Type pType) { 53 type = pType; 54 } 55 56 public void setCheckedValue(Object pValue) { 57 checkedValue = ValueImpl.asValue(pValue); 58 } 59 public Object getCheckedValue() { 60 return checkedValue; 61 } 62 public void addWhen(Object pCondition, Object pValue) { 63 addWhen(new WhenImpl(pCondition, pValue)); 64 } 65 public void addWhen(When pWhen) { whens.add(pWhen); } 66 public void setElseValue(Object pValue) { 67 elseValue = ValueImpl.asValue(pValue); 68 } 69 public Object getElseValue() { return elseValue; } 70 public Type getType() { return type; } 71 public When[] getWhens() { 72 return (When[]) whens.toArray(new When[whens.size()]); 73 } 74 } 75 | Popular Tags |