1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krad.datadictionary.mask;
17
18 import java.io.Serializable;
19
20
21
22
23
24
25 public class Mask implements Serializable {
26 private static final long serialVersionUID = 4035984416568235531L;
27
28 protected MaskFormatter maskFormatter;
29 protected Class<? extends MaskFormatter> maskFormatterClass;
30
31
32
33
34
35
36 public String maskValue(Object value) {
37 if (maskFormatter == null) {
38 if (maskFormatterClass != null) {
39 try {
40 maskFormatter = maskFormatterClass.newInstance();
41 } catch (Exception e) {
42 throw new RuntimeException("Unable to create instance of mask formatter class: " + maskFormatterClass.getName());
43 }
44 }
45 else {
46 throw new RuntimeException("Mask formatter not set for secure field.");
47 }
48 }
49
50 return maskFormatter.maskValue(value);
51 }
52
53
54
55
56
57
58 public MaskFormatter getMaskFormatter() {
59 return maskFormatter;
60 }
61
62
63
64
65
66 public void setMaskFormatter(MaskFormatter maskFormatter) {
67 this.maskFormatter = maskFormatter;
68 }
69
70
71
72
73
74
75 public Class<? extends MaskFormatter> getMaskFormatterClass() {
76 return maskFormatterClass;
77 }
78
79
80
81
82
83
84 public void setMaskFormatterClass(Class<? extends MaskFormatter> maskFormatterClass) {
85 this.maskFormatterClass = maskFormatterClass;
86 }
87
88 }