View Javadoc
1   // SECTION-START[License Header]
2   // <editor-fold defaultstate="collapsed" desc=" Generated License ">
3   /*
4    * Java Object Management and Configuration
5    * Copyright (C) Christian Schulte <cs@schulte.it>, 2005-206
6    * All rights reserved.
7    *
8    * Redistribution and use in source and binary forms, with or without
9    * modification, are permitted provided that the following conditions
10   * are met:
11   *
12   *   o Redistributions of source code must retain the above copyright
13   *     notice, this list of conditions and the following disclaimer.
14   *
15   *   o Redistributions in binary form must reproduce the above copyright
16   *     notice, this list of conditions and the following disclaimer in
17   *     the documentation and/or other materials provided with the
18   *     distribution.
19   *
20   * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21   * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23   * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
24   * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25   * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26   * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30   *
31   * $JOMC: DefaultScope.java 5061 2015-05-31 13:20:40Z schulte $
32   *
33   */
34  // </editor-fold>
35  // SECTION-END
36  package org.jomc.ri;
37  
38  import java.util.Map;
39  import org.jomc.spi.Scope;
40  
41  // SECTION-START[Documentation]
42  // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
43  /**
44   * Default {@code Scope} implementation.
45   *
46   * <dl>
47   *   <dt><b>Identifier:</b></dt><dd>org.jomc.ri.DefaultScope</dd>
48   *   <dt><b>Name:</b></dt><dd>JOMC ⁑ RI ⁑ DefaultScope</dd>
49   *   <dt><b>Abstract:</b></dt><dd>No</dd>
50   *   <dt><b>Final:</b></dt><dd>No</dd>
51   *   <dt><b>Stateless:</b></dt><dd>No</dd>
52   * </dl>
53   *
54   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
55   * @version 1.0
56   */
57  // </editor-fold>
58  // SECTION-END
59  // SECTION-START[Annotations]
60  // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
61  @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
62  // </editor-fold>
63  // SECTION-END
64  public class DefaultScope implements Scope
65  {
66      // SECTION-START[DefaultScope]
67  
68      /**
69       * Objects of the scope.
70       */
71      private Map<String, Object> objects;
72  
73      /**
74       * Creates a new {@code DefaultScope} instance taking a map backing the scope.
75       *
76       * @param map The map backing the scope or {@code null}.
77       */
78      public DefaultScope( final Map<String, Object> map )
79      {
80          this.objects = map;
81      }
82  
83      public Map<String, Object> getObjects()
84      {
85          return this.objects;
86      }
87  
88      public Object getObject( final String identifier )
89      {
90          if ( this.getObjects() != null )
91          {
92              return this.getObjects().get( identifier );
93          }
94  
95          return null;
96      }
97  
98      public Object putObject( final String identifier, final Object object )
99      {
100         if ( this.getObjects() != null )
101         {
102             return this.getObjects().put( identifier, object );
103         }
104 
105         return null;
106     }
107 
108     public Object removeObject( final String identifier )
109     {
110         if ( this.getObjects() != null )
111         {
112             return this.getObjects().remove( identifier );
113         }
114 
115         return null;
116     }
117 
118     // SECTION-END
119     // SECTION-START[Constructors]
120     // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
121     /** Creates a new {@code DefaultScope} instance. */
122     @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
123     public DefaultScope()
124     {
125         // SECTION-START[Default Constructor]
126         super();
127         // SECTION-END
128     }
129     // </editor-fold>
130     // SECTION-END
131     // SECTION-START[Dependencies]
132     // SECTION-END
133     // SECTION-START[Properties]
134     // SECTION-END
135     // SECTION-START[Messages]
136     // SECTION-END
137 
138 }