1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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 public class VMContext implements Context {
31 private Environment environment = new Environment();
32 private List informations = new ArrayList();
33 private int informationNumber = 0;
34
35 public Store getStore(String id) {
36 if ( id.equals(Environment.ID) ) {
37 return environment;
38 }
39 return null;
40 }
41
42 public void addInformation(Information info) {
43 if ( !informations.contains(info) ) {
44 informationNumber++;
45 info.setNumber(informationNumber);
46 informations.add(info);
47 }
48 }
49
50 public List getInformations() {
51 return informations;
52 }
53 }