001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Java Object Management and Configuration
005     *   Copyright (C) Christian Schulte, 2005-206
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
021     *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
022     *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
023     *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
024     *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
025     *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026     *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027     *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028     *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
029     *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030     *
031     *   $JOMC: DefaultScope.java 4381 2012-03-04 19:29:29Z schulte2005 $
032     *
033     */
034    // </editor-fold>
035    // SECTION-END
036    package org.jomc.ri;
037    
038    import java.util.Map;
039    import org.jomc.spi.Scope;
040    
041    // SECTION-START[Documentation]
042    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
043    /**
044     * Default {@code Scope} implementation.
045     *
046     * <dl>
047     *   <dt><b>Identifier:</b></dt><dd>org.jomc.ri.DefaultScope</dd>
048     *   <dt><b>Name:</b></dt><dd>JOMC RI</dd>
049     *   <dt><b>Abstract:</b></dt><dd>No</dd>
050     *   <dt><b>Final:</b></dt><dd>No</dd>
051     *   <dt><b>Stateless:</b></dt><dd>No</dd>
052     * </dl>
053     *
054     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
055     * @version 1.0
056     */
057    // </editor-fold>
058    // SECTION-END
059    // SECTION-START[Annotations]
060    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
061    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
062    // </editor-fold>
063    // SECTION-END
064    public class DefaultScope implements Scope
065    {
066        // SECTION-START[DefaultScope]
067    
068        /** Objects of the scope. */
069        private Map<String, Object> objects;
070    
071        /**
072         * Creates a new {@code DefaultScope} instance taking a map backing the scope.
073         *
074         * @param map The map backing the scope or {@code null}.
075         */
076        public DefaultScope( final Map<String, Object> map )
077        {
078            this.objects = map;
079        }
080    
081        public Map<String, Object> getObjects()
082        {
083            return this.objects;
084        }
085    
086        public Object getObject( final String identifier )
087        {
088            if ( this.getObjects() != null )
089            {
090                return this.getObjects().get( identifier );
091            }
092    
093            return null;
094        }
095    
096        public Object putObject( final String identifier, final Object object )
097        {
098            if ( this.getObjects() != null )
099            {
100                return this.getObjects().put( identifier, object );
101            }
102    
103            return null;
104        }
105    
106        public Object removeObject( final String identifier )
107        {
108            if ( this.getObjects() != null )
109            {
110                return this.getObjects().remove( identifier );
111            }
112    
113            return null;
114        }
115    
116        // SECTION-END
117        // SECTION-START[Constructors]
118        // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
119        /** Creates a new {@code DefaultScope} instance. */
120        @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
121        public DefaultScope()
122        {
123            // SECTION-START[Default Constructor]
124            super();
125            // SECTION-END
126        }
127        // </editor-fold>
128        // SECTION-END
129        // SECTION-START[Dependencies]
130        // SECTION-END
131        // SECTION-START[Properties]
132        // SECTION-END
133        // SECTION-START[Messages]
134        // SECTION-END
135    }