View Javadoc

1   //========================================================================
2   //$Id: SystemProperties.java 4440 2009-02-09 07:49:11Z ayao $
3   //Copyright 2008 Mort Bay Consulting Pty. Ltd.
4   //------------------------------------------------------------------------
5   //Licensed under the Apache License, Version 2.0 (the "License");
6   //you may not use this file except in compliance with the License.
7   //You may obtain a copy of the License at 
8   //http://www.apache.org/licenses/LICENSE-2.0
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  //========================================================================
15  
16  package org.mortbay.jetty.plugin.util;
17  
18  import java.util.ArrayList;
19  import java.util.HashMap;
20  import java.util.List;
21  import java.util.Map;
22  
23  /**
24   * SystemProperties
25   *
26   * Map of name to SystemProperty.
27   * 
28   * When a SystemProperty instance is added, if it has not
29   * been already set (eg via the command line java system property)
30   * then it will be set.
31   */
32  public class SystemProperties
33  {
34      Map properties;
35      
36      public SystemProperties()
37      {
38          properties = new HashMap();
39      }
40      
41      public void setSystemProperty (SystemProperty prop)
42      {
43          properties.put(prop.getName(), prop);
44          prop.setIfNotSetAlready();
45      }
46      
47      public SystemProperty getSystemProperty(String name)
48      {
49          return (SystemProperty)properties.get(name);
50      }
51      
52      public boolean containsSystemProperty(String name)
53      {
54         return properties.containsKey(name); 
55      }
56      
57      public List getSystemProperties ()
58      {
59          return new ArrayList(properties.values());
60      }
61  }