Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*-
  * See the file LICENSE for redistribution information.
  *
  * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
  *
  */
 
 package com.sleepycat.je.config;
 
A JE configuration parameter with a duration integer value in milliseconds. The String format is described under Time Duration Properties in the EnvironmentConfig javadoc.
public class DurationConfigParam extends ConfigParam {
    private static final String DEBUG_NAME =
        DurationConfigParam.class.getName();
    private String minString;
    private int minMillis;
    private String maxString;
    private int maxMillis;
    public DurationConfigParam(String configName,
                               String minVal,
                               String maxVal,
                               String defaultValue,
                               boolean mutable,
                               boolean forReplication) {
        super(configNamedefaultValuemutableforReplication);
        if (minVal != null) {
             = minVal;
             = PropUtil.parseDuration(minVal);
        }
        if (maxVal != null) {
             = maxVal;
             = PropUtil.parseDuration(maxVal);
        }
    }
    @Override
    public void validateValue(String value)
        throws IllegalArgumentException {
        final int millis;
        try {
            /* Parse for validation side-effects. */
            millis = PropUtil.parseDuration(value);
        } catch (IllegalArgumentException e) {
            /* Identify this property in the exception message. */
            throw new IllegalArgumentException
                ( + ":" +
                 " param " +  +
                 " doesn't validate, " +
                 value +
                 " fails validation: " + e.getMessage());
        }
        /* Check min/max. */
        if ( != null) {
            if (millis < ) {
                throw new IllegalArgumentException
                    ( + ":" +
                     " param " +  +
                     " doesn't validate, " +
                     value +
                     " is less than min of "+
                     );
            }
        }
        if ( != null) {
            if (millis > ) {
                throw new IllegalArgumentException
                    ( + ":" +
                     " param " +  +
                     " doesn't validate, " +
                     value +
                     " is greater than max of " +
                     );
            }
        }
    }
New to GrepCode? Check out our FAQ X