1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
182 private char placeholder;
183
184 /** Indicates if the value contains the literal characters. */
185 private boolean containsLiteralChars;
186
187
188 /**
189 * Creates a MaskFormatter with no mask.
190 */
191 public MaskFormatter() {
192 setAllowsInvalid(false);
193 containsLiteralChars = true;
194 maskChars = EmptyMaskChars;
195 placeholder = ' ';
196 }
197
198 /**
199 * Creates a <code>MaskFormatter</code> with the specified mask.
200 * A <code>ParseException</code>
201 * will be thrown if <code>mask</code> is an invalid mask.
202 *
203 * @throws ParseException if mask does not contain valid mask characters
204 */
205 public MaskFormatter(String mask) throws ParseException {
206 this();
207 setMask(mask);
208 }
209
210 /**
211 * Sets the mask dictating the legal characters.
212 * This will throw a <code>ParseException</code> if <code>mask</code> is
213 * not valid.
214 *
215 * @throws ParseException if mask does not contain valid mask characters
216 */
217 public void setMask(String mask) throws ParseException {
218 this.mask = mask;
219 updateInternalMask();
220 }
221
222 /**
223 * Returns the formatting mask.
224 *
225 * @return Mask dictating legal character values.
226 */
227 public String getMask() {
228 return mask;
229 }
230
231 /**
232 * Allows for further restricting of the characters that can be input.
233 * Only characters specified in the mask, not in the
|
1 /*
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
182 private char placeholder;
183
184 /** Indicates if the value contains the literal characters. */
185 private boolean containsLiteralChars;
186
187
188 /**
189 * Creates a MaskFormatter with no mask.
190 */
191 public MaskFormatter() {
192 setAllowsInvalid(false);
193 containsLiteralChars = true;
194 maskChars = EmptyMaskChars;
195 placeholder = ' ';
196 }
197
198 /**
199 * Creates a <code>MaskFormatter</code> with the specified mask.
200 * A <code>ParseException</code>
201 * will be thrown if <code>mask</code> is an invalid mask.
202 * @param mask the mask
203 * @throws ParseException if mask does not contain valid mask characters
204 */
205 public MaskFormatter(String mask) throws ParseException {
206 this();
207 setMask(mask);
208 }
209
210 /**
211 * Sets the mask dictating the legal characters.
212 * This will throw a <code>ParseException</code> if <code>mask</code> is
213 * not valid.
214 * @param mask the mask
215 *
216 * @throws ParseException if mask does not contain valid mask characters
217 */
218 public void setMask(String mask) throws ParseException {
219 this.mask = mask;
220 updateInternalMask();
221 }
222
223 /**
224 * Returns the formatting mask.
225 *
226 * @return Mask dictating legal character values.
227 */
228 public String getMask() {
229 return mask;
230 }
231
232 /**
233 * Allows for further restricting of the characters that can be input.
234 * Only characters specified in the mask, not in the
|