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, 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 4795 2013-04-21 09:09:02Z 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.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) 62 // </editor-fold> 63 // SECTION-END 64 public class DefaultScope implements Scope 65 { 66 // SECTION-START[DefaultScope] 67 68 /** Objects of the scope. */ 69 private Map<String, Object> objects; 70 71 /** 72 * Creates a new {@code DefaultScope} instance taking a map backing the scope. 73 * 74 * @param map The map backing the scope or {@code null}. 75 */ 76 public DefaultScope( final Map<String, Object> map ) 77 { 78 this.objects = map; 79 } 80 81 public Map<String, Object> getObjects() 82 { 83 return this.objects; 84 } 85 86 public Object getObject( final String identifier ) 87 { 88 if ( this.getObjects() != null ) 89 { 90 return this.getObjects().get( identifier ); 91 } 92 93 return null; 94 } 95 96 public Object putObject( final String identifier, final Object object ) 97 { 98 if ( this.getObjects() != null ) 99 { 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.5", comments = "See http://www.jomc.org/jomc/1.5/jomc-tools-1.5" ) 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 }