org.duraspace.fcrepo.cloudsync.service.util
Class StringUtil

java.lang.Object
  extended by org.duraspace.fcrepo.cloudsync.service.util.StringUtil

public final class StringUtil
extends Object


Method Summary
static String normalize(String val)
          Normalizes the given string by trimming it if non-null and returning null if null or empty.
static String validate(String name, String value)
           
static String validate(String name, String value, int maxLen)
          Checks that the given value's normalized length is in the allowed range.
static String validate(String name, String value, String[] validValues)
          Checks that the given value's normalized form is one of the allowed values.
static String validateInt(String name, String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

normalize

public static String normalize(String val)
Normalizes the given string by trimming it if non-null and returning null if null or empty.

Parameters:
val - the string value to normalize.
Returns:
the normalized value.

validate

public static String validate(String name,
                              String value,
                              int maxLen)
                       throws IllegalArgumentException
Checks that the given value's normalized length is in the allowed range.

Parameters:
name - the name of the property being checked, for error reporting.
value - the value.
maxLen - the maximum length allowed.
Returns:
the normalized value.
Throws:
IllegalArgumentException - if the normalized value is null, zero-length, or exceeds the maximum length specified.

validate

public static String validate(String name,
                              String value,
                              String[] validValues)
                       throws IllegalArgumentException
Checks that the given value's normalized form is one of the allowed values.

Parameters:
name - the name of the property being checked, for error reporting.
value - the value.
validValues - the allowed values.
Returns:
the normalized value.
Throws:
IllegalArgumentException - if the normalized value is null, zero-length, or not one of the allowed values.

validate

public static String validate(String name,
                              String value)
                       throws IllegalArgumentException
Throws:
IllegalArgumentException

validateInt

public static String validateInt(String name,
                                 String value)
                          throws IllegalArgumentException
Throws:
IllegalArgumentException


Copyright © 2012 DuraSpace. All Rights Reserved.