KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > util > Base64PutHashMap


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.util;
15
16 import java.util.HashMap JavaDoc;
17 import java.util.Map JavaDoc;
18
19
20 /** An implementation of HashMap that base64 encodes all String's that you 'put',
21  * it encodes them to form "B64:<base64 encoded string>". It only encodes objects of type String.
22  *
23  * @author tomasg
24  * @version $Id: Base64PutHashMap.java,v 1.4 2006/07/28 07:14:15 anatom Exp $
25  */

26 public class Base64PutHashMap extends HashMap JavaDoc {
27     public Base64PutHashMap() {
28         super();
29     }
30     public Base64PutHashMap(Map JavaDoc m) {
31         super(m);
32     }
33     public Object JavaDoc put(Object JavaDoc key, Object JavaDoc value) {
34         if (value == null) {
35             return super.put(key, value);
36         }
37         if (value instanceof String JavaDoc) {
38             String JavaDoc s = StringTools.putBase64String((String JavaDoc)value);
39             return super.put(key,s);
40         }
41         return super.put(key, value);
42     }
43     
44 }
45
Popular Tags