Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VMContext |
|
| 2.0;2 |
1 | /* | |
2 | * | |
3 | * ==================================================================== | |
4 | * | |
5 | * Copyright 2004 The Apache Software Foundation | |
6 | * | |
7 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
8 | * you may not use this file except in compliance with the License. | |
9 | * You may obtain a copy of the License at | |
10 | * | |
11 | * http://www.apache.org/licenses/LICENSE-2.0 | |
12 | * | |
13 | * Unless required by applicable law or agreed to in writing, software | |
14 | * distributed under the License is distributed on an "AS IS" BASIS, | |
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
16 | * See the License for the specific language governing permissions and | |
17 | * limitations under the License. | |
18 | * | |
19 | */ | |
20 | package org.apache.commons.contract.context; | |
21 | ||
22 | import java.util.ArrayList; | |
23 | import java.util.List; | |
24 | ||
25 | import org.apache.commons.contract.Context; | |
26 | import org.apache.commons.contract.Information; | |
27 | import org.apache.commons.contract.Store; | |
28 | import org.apache.commons.contract.store.Environment; | |
29 | ||
30 | 0 | public class VMContext implements Context { |
31 | 0 | private Environment environment = new Environment(); |
32 | 0 | private List informations = new ArrayList(); |
33 | 0 | private int informationNumber = 0; |
34 | ||
35 | public Store getStore(String id) { | |
36 | 0 | if ( id.equals(Environment.ID) ) { |
37 | 0 | return environment; |
38 | } | |
39 | 0 | return null; |
40 | } | |
41 | ||
42 | public void addInformation(Information info) { | |
43 | 0 | if ( !informations.contains(info) ) { |
44 | 0 | informationNumber++; |
45 | 0 | info.setNumber(informationNumber); |
46 | 0 | informations.add(info); |
47 | } | |
48 | 0 | } |
49 | ||
50 | public List getInformations() { | |
51 | 0 | return informations; |
52 | } | |
53 | } |