KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > jcetaglib > tools > safeText


1 /*
2   Name: safeText.java
3   Licensing: LGPL
4
5   API: Sun (http://java.sun.com) JCE 1.2.2 API (cleanroom implementation by Bouncy Castle)
6   Provider: Bouncy Castle (http://www.bouncycastle.org)
7
8   Disclaimer:
9
10   COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, WITHOUT WARRANTY OF ANY KIND,
11   EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE
12   IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE
13   RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE
14   PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR)
15   ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY
16   CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED
17   HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
18 */

19
20 package net.sourceforge.jcetaglib.tools;
21
22 /**
23  * Object containing text that can be removed from memory by calling clearText()
24  * method
25  *
26  * @author Gert Van Ham
27  * @author hamgert@users.sourceforge.net
28  * @author http://jcetaglib.sourceforge.net
29  * @version 0.6 (beta) 05-nov-2002
30  */

31
32 public class safeText {
33     private byte[] safetext;
34
35     /**
36      * Set text
37      *
38      * @param safetext byte[] byte array of text
39      * @exception Exception for all errors
40      **/

41     public void setText(byte[] safetext)
42             throws Exception JavaDoc {
43         this.safetext = safetext;
44     }
45
46     /**
47      * Retrieve text
48      *
49      * @return StringBuffer text
50      * @exception Exception for all errors
51      **/

52     public StringBuffer JavaDoc getText()
53             throws Exception JavaDoc {
54         return new StringBuffer JavaDoc(new String JavaDoc(safetext));
55     }
56
57     /**
58      * Wipe text from memory
59      *
60      * @exception Exception for all errors
61      **/

62     public void clearText()
63             throws Exception JavaDoc {
64         for (int i = 0; i < safetext.length; i++) {
65             safetext[i] = 0;
66         }
67     }
68 }
69
Popular Tags