78
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2007 IBM Corporation and others.
|
|
3 * All rights reserved. This program and the accompanying materials
|
|
4 * are made available under the terms of the Eclipse Public License v1.0
|
|
5 * which accompanies this distribution, and is available at
|
|
6 * http://www.eclipse.org/legal/epl-v10.html
|
|
7 *
|
|
8 * Contributors:
|
|
9 * IBM Corporation - initial API and implementation
|
|
10 ******************************************************************************/
|
|
11
|
|
12 module org.eclipse.core.internal.databinding.validation.StringToFloatValidator;
|
81
|
13 import org.eclipse.core.internal.databinding.validation.NumberFormatConverter;
|
|
14 import org.eclipse.core.internal.databinding.validation.AbstractStringToNumberValidator;
|
78
|
15
|
|
16 import java.lang.all;
|
|
17
|
|
18 import org.eclipse.core.internal.databinding.conversion.StringToNumberParser;
|
|
19
|
|
20 /**
|
|
21 * Validates that a string is of the appropriate format and is in the range of a
|
|
22 * float.
|
|
23 *
|
|
24 * @since 1.0
|
|
25 */
|
|
26 public class StringToFloatValidator : AbstractStringToNumberValidator {
|
|
27
|
85
|
28 private static Float MIN;
|
|
29 private static Float MAX;
|
78
|
30
|
|
31 /**
|
|
32 * @param converter
|
|
33 */
|
|
34 public this(NumberFormatConverter converter) {
|
85
|
35 if( MIN is null || MAX is null ){
|
|
36 MIN = new Float(-Float.MAX_VALUE);
|
|
37 MAX = new Float( Float.MAX_VALUE);
|
|
38 }
|
78
|
39 super(converter, MIN, MAX);
|
|
40 }
|
|
41
|
|
42 /*
|
|
43 * (non-Javadoc)
|
|
44 *
|
|
45 * @see org.eclipse.core.internal.databinding.validation.AbstractStringToNumberValidator#inRange(java.lang.Number)
|
|
46 */
|
|
47 protected bool isInRange(Number number) {
|
|
48 return StringToNumberParser.inFloatRange(number);
|
|
49 }
|
|
50 }
|