Clover Coverage Report - XWiki Commons - Parent POM 4.0-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Mar 12 2012 17:13:48 CET
../../../../img/srcFileCovDistChart9.png 20% of files have more coverage
11   117   11   1.1
2   56   1   10
10     1.1  
1    
 
  AbstractRequest       Line # 31 11 0% 11 4 82.6% 0.82608694
 
No Tests
 
1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.job;
21   
22    import java.util.Collection;
23    import java.util.HashMap;
24    import java.util.Map;
25   
26    /**
27    * Base class for {@link Request} implementations.
28    *
29    * @version $Id: 8fb9de440c5f87edd90d4a5f27a7cfbe2cc84e97 $
30    */
 
31    public abstract class AbstractRequest implements Request
32    {
33    /**
34    * @see #getId()
35    */
36    private String id;
37   
38    /**
39    * The properties.
40    */
41    private Map<String, Object> properties = new HashMap<String, Object>();
42   
43    /**
44    * Default constructor.
45    */
 
46  70 toggle public AbstractRequest()
47    {
48   
49    }
50   
51    /**
52    * @param request the request to copy
53    */
 
54  66 toggle public AbstractRequest(Request request)
55    {
56  66 for (String key : request.getPropertyNames()) {
57  102 setProperty(key, request.getProperty(key));
58    }
59    }
60   
 
61  894 toggle @Override
62    public String getId()
63    {
64  894 return this.id;
65    }
66   
67    /**
68    * @param id the identifier used to acccess the job
69    */
 
70  136 toggle public void setId(String id)
71    {
72  136 this.id = id;
73    }
74   
 
75  0 toggle @Override
76    public boolean isRemote()
77    {
78  0 return this.<Boolean> getProperty(PROPERTY_REMOTE, false);
79    }
80   
81    /**
82    * @param remote indicate if the job has been triggered by a remote event
83    */
 
84  0 toggle public void setRemote(boolean remote)
85    {
86  0 setProperty(PROPERTY_REMOTE, remote);
87    }
88   
89    /**
90    * @param key the name of the property
91    * @param value the value of the property
92    */
 
93  208 toggle public void setProperty(String key, Object value)
94    {
95  208 this.properties.put(key, value);
96    }
97   
 
98  548 toggle @Override
99    public <T> T getProperty(String key)
100    {
101  548 return getProperty(key, null);
102    }
103   
 
104  548 toggle @Override
105    public <T> T getProperty(String key, T def)
106    {
107  548 Object value = this.properties.get(key);
108   
109  548 return value != null ? (T) value : def;
110    }
111   
 
112  129 toggle @Override
113    public Collection<String> getPropertyNames()
114    {
115  129 return this.properties.keySet();
116    }
117    }