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 org.kuali.rice.krad.datadictionary.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20
21 import java.io.Serializable;
22
23
24
25
26
27
28 @BeanTag(name = "mask")
29 public class Mask implements Serializable {
30 private static final long serialVersionUID = 4035984416568235531L;
31
32 protected MaskFormatter maskFormatter;
33 protected Class<? extends MaskFormatter> maskFormatterClass;
34
35
36
37
38
39
40
41 public String maskValue(Object value) {
42 if (maskFormatter == null) {
43 if (maskFormatterClass != null) {
44 try {
45 maskFormatter = maskFormatterClass.newInstance();
46 } catch (Exception e) {
47 throw new RuntimeException(
48 "Unable to create instance of mask formatter class: " + maskFormatterClass.getName());
49 }
50 } else {
51 throw new RuntimeException("Mask formatter not set for secure field.");
52 }
53 }
54
55 return maskFormatter.maskValue(value);
56 }
57
58
59
60
61
62
63 @BeanTagAttribute(name = "maskFormater", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
64 public MaskFormatter getMaskFormatter() {
65 return maskFormatter;
66 }
67
68
69
70
71 public void setMaskFormatter(MaskFormatter maskFormatter) {
72 this.maskFormatter = maskFormatter;
73 }
74
75
76
77
78
79
80 @BeanTagAttribute(name = "maskFormatterClass", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
81 public Class<? extends MaskFormatter> getMaskFormatterClass() {
82 return maskFormatterClass;
83 }
84
85
86
87
88
89
90 public void setMaskFormatterClass(Class<? extends MaskFormatter> maskFormatterClass) {
91 this.maskFormatterClass = maskFormatterClass;
92 }
93
94 }