1 8 9 package com.sleepycat.je.config; 10 11 14 public class LongConfigParam extends ConfigParam { 15 16 private static final String DEBUG_NAME = LongConfigParam.class.getName(); 17 18 private Long min; 19 private Long max; 20 21 LongConfigParam(String configName, 22 Long minVal, 23 Long maxVal, 24 Long defaultValue, 25 boolean mutable, 26 boolean forReplication, 27 String description) { 28 29 super(configName, defaultValue.toString(), mutable, 31 forReplication, description); 32 min = minVal; 33 max = maxVal; 34 } 35 36 39 private void validate(Long value) 40 throws IllegalArgumentException { 41 42 if (value != null) { 43 if (min != null) { 44 if (value.compareTo(min) < 0) { 45 throw new IllegalArgumentException 46 (DEBUG_NAME + ":" + 47 " param " + name + 48 " doesn't validate, " + 49 value + 50 " is less than min of " 51 + min); 52 } 53 } 54 if (max != null) { 55 if (value.compareTo(max) > 0) { 56 throw new IllegalArgumentException 57 (DEBUG_NAME + ":" + 58 " param " + name + 59 " doesn't validate, " + 60 value + 61 " is greater than max "+ 62 " of " + max); 63 } 64 } 65 } 66 } 67 68 public void validateValue(String value) 69 throws IllegalArgumentException { 70 71 try { 72 validate(new Long (value)); 73 } catch (NumberFormatException e) { 74 throw new IllegalArgumentException 75 (DEBUG_NAME + ": " + value + " not valid value for " + name); 76 } 77 } 78 79 public String getExtraDescription() { 80 StringBuffer minMaxDesc = new StringBuffer (); 81 if (min != null) { 82 minMaxDesc.append("# minimum = ").append(min); 83 } 84 if (max != null) { 85 if (min != null) { 86 minMaxDesc.append("\n"); 87 } 88 minMaxDesc.append("# maximum = ").append(max); 89 } 90 return minMaxDesc.toString(); 91 } 92 } 93 | Popular Tags |