EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hivegui.command]

COVERAGE SUMMARY FOR SOURCE FILE [ActionObjectProvider.java]

nameclass, %method, %block, %line, %
ActionObjectProvider.java0%   (0/1)0%   (0/2)0%   (0/69)0%   (0/15)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ActionObjectProvider0%   (0/1)0%   (0/2)0%   (0/69)0%   (0/15)
ActionObjectProvider (ObjectBuilder, ActionFactory): void 0%   (0/1)0%   (0/9)0%   (0/4)
provideObject (Module, Class, String, Location): Object 0%   (0/1)0%   (0/60)0%   (0/11)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hivegui.command;
16 
17import java.util.StringTokenizer;
18 
19import org.apache.hivemind.ApplicationRuntimeException;
20import org.apache.hivemind.HiveMind;
21import org.apache.hivemind.Location;
22import org.apache.hivemind.internal.Module;
23import org.apache.hivemind.service.ObjectProvider;
24 
25import net.sourceforge.hiveutils.service.ObjectBuilder;
26 
27/**
28 * @author Jean-Francois Poilpret
29 */
30public class ActionObjectProvider implements ObjectProvider
31{
32        public ActionObjectProvider(ObjectBuilder builder, ActionFactory factory)
33        {
34                _builder = builder;
35                _factory = factory;
36        }
37        
38        public Object provideObject(        Module                contributingModule,
39                                                                        Class                propertyType,
40                                                                        String                inputValue,
41                                                                        Location        location)
42        {
43                if (HiveMind.isBlank(inputValue))
44                {
45                        return null;
46                }
47 
48                StringTokenizer tokenizer = new StringTokenizer(inputValue, ":");
49                if (tokenizer.countTokens() == NUM_TOKENS_ONLY_ID)
50                {
51                        String action = tokenizer.nextToken();
52                        return _factory.getAction(action);
53                }
54                if (tokenizer.countTokens() == NUM_TOKENS_TARGET_ID)
55                {
56                        String target = tokenizer.nextToken();
57                        String action = tokenizer.nextToken();
58                        return _factory.getAction(action, _builder.create(target));
59                }
60                throw new ApplicationRuntimeException(
61                                        "Bad input value <" + inputValue + ">", location, null);
62        }
63 
64        static final private int        NUM_TOKENS_ONLY_ID = 1;
65        static final private int        NUM_TOKENS_TARGET_ID = 2;
66 
67        private final ObjectBuilder        _builder;
68        private final ActionFactory        _factory;
69}

[all classes][net.sourceforge.hivegui.command]
EMMA 2.0.5312 (C) Vladimir Roubtsov