]> git.argeo.org Git - gpl/argeo-slc.git/blob - StatusFieldHandler.java
a69eb87daeb0592c4abaf927f6cf6701cec0761c
[gpl/argeo-slc.git] / StatusFieldHandler.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.castor.test.tree;
17
18 import org.argeo.slc.core.test.SimpleResultPart;
19 import org.argeo.slc.core.test.SlcTestUtils;
20 import org.argeo.slc.test.TestStatus;
21 import org.exolab.castor.mapping.AbstractFieldHandler;
22
23 public class StatusFieldHandler extends AbstractFieldHandler {
24
25 @Override
26 public Object getValue(Object object) throws IllegalStateException {
27 SimpleResultPart part = (SimpleResultPart) object;
28 return SlcTestUtils.statusToString(part.getStatus());
29 }
30
31 @Override
32 public Object newInstance(Object parent) throws IllegalStateException {
33 return null;
34 }
35
36 @Override
37 public Object newInstance(Object parent, Object[] args)
38 throws IllegalStateException {
39 return null;
40 }
41
42 @Override
43 public void resetValue(Object object) throws IllegalStateException,
44 IllegalArgumentException {
45 SimpleResultPart part = (SimpleResultPart) object;
46 // ERROR by default since it should be explicitely set
47 part.setStatus(TestStatus.ERROR);
48 }
49
50 @Override
51 public void setValue(Object object, Object value)
52 throws IllegalStateException, IllegalArgumentException {
53 SimpleResultPart part = (SimpleResultPart) object;
54 Integer status = SlcTestUtils.stringToStatus((String) value);
55 part.setStatus(status);
56 }
57
58 }