1 | // SECTION-START[License Header] |
2 | // <editor-fold defaultstate="collapsed" desc=" Generated License "> |
3 | /* |
4 | * Copyright (c) 2010 The JOMC Project |
5 | * Copyright (c) 2005 Christian Schulte <cs@jomc.org> |
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 BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" |
21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
22 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR |
24 | * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
26 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
27 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
28 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
29 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
30 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
31 | * |
32 | * $Id: DefaultScope.java 1346 2010-01-19 12:16:43Z schulte2005 $ |
33 | * |
34 | */ |
35 | // </editor-fold> |
36 | // SECTION-END |
37 | package org.jomc.ri; |
38 | |
39 | import java.util.Map; |
40 | import org.jomc.spi.Scope; |
41 | |
42 | // SECTION-START[Documentation] |
43 | // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> |
44 | /** |
45 | * Default {@code Scope} implementation. |
46 | * |
47 | * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0 |
48 | * @version $Id: DefaultScope.java 1346 2010-01-19 12:16:43Z schulte2005 $ |
49 | */ |
50 | // </editor-fold> |
51 | // SECTION-END |
52 | // SECTION-START[Annotations] |
53 | // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> |
54 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
55 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-15/jomc-tools" ) |
56 | // </editor-fold> |
57 | // SECTION-END |
58 | public class DefaultScope implements Scope |
59 | { |
60 | // SECTION-START[DefaultScope] |
61 | |
62 | /** Objects of the scope. */ |
63 | private Map<String, Object> objects; |
64 | |
65 | /** |
66 | * Creates a new {@code DefaultScope} instance taking a map backing the scope. |
67 | * |
68 | * @param map The map backing the scope or {@code null}. |
69 | */ |
70 | public DefaultScope( final Map<String, Object> map ) |
71 | { |
72 | this.objects = map; |
73 | } |
74 | |
75 | public Map<String, Object> getObjects() |
76 | { |
77 | return this.objects; |
78 | } |
79 | |
80 | public Object getObject( final String instance ) |
81 | { |
82 | if ( this.getObjects() != null ) |
83 | { |
84 | return this.getObjects().get( instance ); |
85 | } |
86 | |
87 | return null; |
88 | } |
89 | |
90 | public Object putObject( final String instance, final Object object ) |
91 | { |
92 | if ( this.getObjects() != null ) |
93 | { |
94 | return this.getObjects().put( instance, object ); |
95 | } |
96 | |
97 | return null; |
98 | } |
99 | |
100 | public Object removeObject( final String instance ) |
101 | { |
102 | if ( this.getObjects() != null ) |
103 | { |
104 | return this.getObjects().remove( instance ); |
105 | } |
106 | |
107 | return null; |
108 | } |
109 | |
110 | // SECTION-END |
111 | // SECTION-START[Constructors] |
112 | // <editor-fold defaultstate="collapsed" desc=" Generated Constructors "> |
113 | |
114 | /** Creates a new {@code DefaultScope} instance. */ |
115 | @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", |
116 | comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-15/jomc-tools" ) |
117 | public DefaultScope() |
118 | { |
119 | // SECTION-START[Default Constructor] |
120 | super(); |
121 | // SECTION-END |
122 | } |
123 | // </editor-fold> |
124 | // SECTION-END |
125 | // SECTION-START[Dependencies] |
126 | // SECTION-END |
127 | // SECTION-START[Properties] |
128 | // SECTION-END |
129 | // SECTION-START[Messages] |
130 | // SECTION-END |
131 | } |