001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)ContextImpl.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.internal.security.test.binding1.rt;
030:
031: import com.sun.jbi.binding.security.Context;
032: import java.util.HashMap;
033:
034: /**
035: * Implementation of the Context.
036: *
037: * @author Sun Microsystems, Inc.
038: */
039: public class ContextImpl implements Context {
040: /**
041: * The Context.
042: */
043: private HashMap mContext;
044:
045: /**
046: * Creates a new instance of ContextImpl.
047: */
048: public ContextImpl() {
049: mContext = new HashMap();
050: }
051:
052: /* ------------------------------------------------------------------------------- *\
053: * Context Impl. *
054: \* ------------------------------------------------------------------------------- */
055:
056: /**
057: * @param key is the key to look for in the context.
058: * @return true if the Context contains a particular Key
059: */
060: public boolean containsKey(String key) {
061: return mContext.containsKey(key);
062: };
063:
064: /**
065: * @param key whose associated value is to be returned.
066: * @return the Object value associated with a particular Key
067: */
068: public Object getValue(String key) {
069: return mContext.get(key);
070: }
071:
072: /**
073: * @param key is the Key whose value is to be set.
074: * @param value is the value for the Key.
075: */
076: public void setValue(String key, Object value) {
077: mContext.put(key, value);
078: };
079:
080: /**
081: * Enumerate all the Keys in the Context.
082: *
083: * @return the List of Keys (Strings) in the Context.
084: */
085: public java.util.Set enumerateKeys() {
086: return mContext.keySet();
087: };
088:
089: /**
090: * Remove a entry.
091: *
092: * @param key is the Key identifying the entry to be deleted.
093: */
094: public void removeValue(String key)
095:
096: {
097: mContext.remove(key);
098: }
099:
100: /**
101: * Print the Contents of the Context to the Logger.
102: *
103: * @param logger is the java.util.Logger to use for printing out the contents.
104: * @param level is the logging level
105: */
106: public void print(java.util.logging.Logger logger,
107: java.util.logging.Level level) {
108: StringBuffer buffer = new StringBuffer();
109:
110: buffer.append("Context : \n");
111:
112: java.util.Iterator itr = enumerateKeys().iterator();
113:
114: while (itr.hasNext()) {
115: String param = (String) itr.next();
116:
117: buffer.append("\tParameter : " + param + "\n");
118: buffer.append("\tValue :" + (String) getValue(param)
119: + "\n");
120: }
121:
122: logger.log(level, buffer.toString());
123: }
124: }
|