annotate src/edu/unc/genomics/PositiveIntegerValidator.java @ 2:e16016635b2a

Uploaded
author timpalpant
date Mon, 13 Feb 2012 22:12:06 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
1 package edu.unc.genomics;
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
2
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
3 import com.beust.jcommander.IParameterValidator;
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
4 import com.beust.jcommander.ParameterException;
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
5
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
6 /**
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
7 * @author timpalpant
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
8 *
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
9 */
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
10 public class PositiveIntegerValidator implements IParameterValidator {
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
11
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
12 /* (non-Javadoc)
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
13 * @see com.beust.jcommander.IParameterValidator#validate(java.lang.String, java.lang.String)
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
14 */
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
15 @Override
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
16 public void validate(String name, String value) throws ParameterException {
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
17 int n = Integer.parseInt(value);
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
18 if (n <= 0) {
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
19 throw new ParameterException("Parameter "+name+" must be > 0 (was "+value+")");
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
20 }
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
21 }
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
22
e16016635b2a Uploaded
timpalpant
parents:
diff changeset
23 }