public static Type createInstance(String name, int maxLength, String pattern)
    {
        synchronized (STRING_PATTERN_TYPES)
        {
            StringPatternType newType = new StringPatternType(name, maxLength, pattern);

            // Ensure that the named type does not already exist.
            StringPatternType oldType = STRING_PATTERN_TYPES.get(name);

            if ((oldType != null) && !oldType.equals(newType))
            {
                throw new IllegalArgumentException("The type '" + name + "' already exists and cannot be redefined.");
            }
            else if ((oldType != null) && oldType.equals(newType))
            {
                return oldType;
            }
            else
            {
                // Add the newly created type to the map of all types.
                STRING_PATTERN_TYPES.put(name, newType);

                return newType;
            }
        }
    }
public static Type createInstance ( String name , int maxLength , String pattern ) { synchronized ( STRING_PATTERN_TYPES ) { StringPatternType newType = new StringPatternType ( name , maxLength , pattern ) ; StringPatternType oldType = STRING_PATTERN_TYPES . get ( name ) ; if ( ( oldType != null ) && ! oldType . equals ( newType ) ) { throw new IllegalArgumentException ( "The type '" + name + "' already exists and cannot be redefined." ) ; } else if ( ( oldType != null ) && oldType . equals ( newType ) ) { return oldType ; } else { STRING_PATTERN_TYPES . put ( name , newType ) ; return newType ; } } }
Creates a new string pattern type with the specified name, if it does not already exist.

@param  name      The name of the string pattern type to create.
@param  maxLength The maximum length of instances of the type, may be zero or less for no maximum.
@param  pattern   A regular expression that instances must match, or <tt>null</tt> for no pattern.

@return A new string pattern type.

@throws IllegalArgumentException If min is not less than or equal to max, or the named type already exists.