KickJava   Java API By Example, From Geeks To Geeks.

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


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 decodes all String's that you 'get',
21  * if they start with 'B64', i.e. it base64 decodes string of form "B64:<base64 encoded string>".
22  * It only tries to decode objects of type String.
23  *
24  * @author tomasg
25  * @version $Id: Base64GetHashMap.java,v 1.4 2006/07/28 07:14:15 anatom Exp $
26  */

27 public class Base64GetHashMap extends HashMap JavaDoc {
28     public Base64GetHashMap() {
29         super();
30     }
31     public Base64GetHashMap(Map JavaDoc m) {
32         super(m);
33     }
34     
35     public Object JavaDoc get(Object JavaDoc key) {
36         Object JavaDoc o = super.get(key);
37         if (o == null) {
38             return o;
39         }
40         if (o instanceof String JavaDoc) {
41             String JavaDoc s = (String JavaDoc) o;
42             return StringTools.getBase64String(s);
43         }
44         return o;
45     }
46     
47 }
48
Popular Tags