01: /*
02: * Copyright 2006 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.core.datadictionary.mask;
17:
18: import java.io.Serializable;
19:
20: /**
21: * Contains a mask configuration and method to mask a data value.
22: *
23: *
24: */
25: public class Mask implements Serializable {
26: static final public long serialVersionUID = 0L;
27:
28: private MaskFormatter maskFormatter;
29: private Class maskFormatterClass;
30:
31: /**
32: * Masks a data value with the configured maskFormatter;
33: *
34: * @param value
35: * @return
36: */
37: public String maskValue(Object value) {
38: if (maskFormatter == null) {
39: if (maskFormatterClass != null) {
40: try {
41: maskFormatter = (MaskFormatter) maskFormatterClass
42: .newInstance();
43: } catch (Exception e) {
44: throw new RuntimeException(
45: "Unable to create instance of mask formatter class: "
46: + maskFormatterClass.getName());
47: }
48: } else {
49: throw new RuntimeException(
50: "Mask formatter not set for secure field.");
51: }
52: }
53:
54: return maskFormatter.maskValue(value);
55: }
56:
57: /**
58: * Gets the maskFormatter attribute.
59: *
60: * @return Returns the maskFormatter.
61: */
62: public MaskFormatter getMaskFormatter() {
63: return maskFormatter;
64: }
65:
66: /**
67: * Sets the maskFormatter attribute value.
68: *
69: * @param maskFormatter The maskFormatter to set.
70: */
71: public void setMaskFormatter(MaskFormatter maskFormatter) {
72: this .maskFormatter = maskFormatter;
73: }
74:
75: /**
76: * Gets the maskFormatterClass attribute.
77: *
78: * @return Returns the maskFormatterClass.
79: */
80: public Class getMaskFormatterClass() {
81: return maskFormatterClass;
82: }
83:
84: /**
85: * Sets the maskFormatterClass attribute value.
86: *
87: * @param maskFormatterClass The maskFormatterClass to set.
88: */
89: public void setMaskFormatterClass(Class maskFormatterClass) {
90: this.maskFormatterClass = maskFormatterClass;
91: }
92:
93: }
|