001 // SECTION-START[License Header] 002 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 003 /* 004 * Copyright (c) 2009 The JOMC Project 005 * Copyright (c) 2005 Christian Schulte <cs@jomc.org> 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 BY THE JOMC PROJECT AND CONTRIBUTORS "AS IS" 021 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 022 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 023 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE JOMC PROJECT OR 024 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 026 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 027 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 028 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 029 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 030 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 031 * 032 * $Id: DefaultScope.java 1102 2009-12-07 03:01:58Z schulte2005 $ 033 * 034 */ 035 // </editor-fold> 036 // SECTION-END 037 package org.jomc.ri; 038 039 import java.util.Map; 040 import org.jomc.spi.Scope; 041 042 // SECTION-START[Documentation] 043 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 044 /** 045 * Default {@code Scope} implementation. 046 * 047 * @author <a href="mailto:cs@jomc.org">Christian Schulte</a> 1.0 048 * @version $Id: DefaultScope.java 1102 2009-12-07 03:01:58Z schulte2005 $ 049 */ 050 // </editor-fold> 051 // SECTION-END 052 // SECTION-START[Annotations] 053 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 054 @javax.annotation.Generated( value = "org.jomc.tools.JavaSources", 055 comments = "See http://jomc.sourceforge.net/jomc/1.0-alpha-11/jomc-tools" ) 056 // </editor-fold> 057 // SECTION-END 058 public class DefaultScope implements Scope 059 { 060 // SECTION-START[DefaultScope] 061 062 /** Objects of the scope. */ 063 private Map<String, Object> objects; 064 065 /** 066 * Creates a new {@code DefaultScope} instance taking a map backing the scope. 067 * 068 * @param map The map backing the scope or {@code null}. 069 */ 070 public DefaultScope( final Map<String, Object> map ) 071 { 072 this.objects = map; 073 } 074 075 public Map<String, Object> getObjects() 076 { 077 return this.objects; 078 } 079 080 public Object getObject( final String instance ) 081 { 082 if ( this.getObjects() != null ) 083 { 084 return this.getObjects().get( instance ); 085 } 086 087 return null; 088 } 089 090 public Object putObject( final String instance, final Object object ) 091 { 092 if ( this.getObjects() != null ) 093 { 094 return this.getObjects().put( instance, object ); 095 } 096 097 return null; 098 } 099 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-11/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 }