1 // Copyright 2006-2007, by the California Institute of Technology. 2 // ALL RIGHTS RESERVED. United States Government Sponsorship acknowledged. 3 // Any commercial use must be negotiated with the Office of Technology Transfer 4 // at the California Institute of Technology. 5 // 6 // This software is subject to U. S. export control laws and regulations 7 // (22 C.F.R. 120-130 and 15 C.F.R. 730-774). To the extent that the software 8 // is subject to U.S. export control laws and regulations, the recipient has 9 // the responsibility to obtain export licenses or other export authority as 10 // may be required before exporting such information to foreign countries or 11 // providing access to foreign nationals. 12 // 13 // $Id: CharacterChecker.java 2601 2007-04-12 18:34:25Z pramirez $ 14 // 15 16 package gov.nasa.pds.tools.dict.type; 17 18 /*** 19 * @author pramirez 20 * @version $Revision: 2601 $ 21 * 22 */ 23 public class CharacterChecker extends LengthChecker implements TypeChecker { 24 25 /* (non-Javadoc) 26 * @see gov.nasa.jpl.pds.tools.label.validate.TypeChecker#cast(java.lang.String) 27 */ 28 public Object cast(String value) throws InvalidTypeException { 29 if (!value.matches("[a-zA-Z0-9_//s!#$%&'//(//)//*+,-//./:;<=>?@//[//]//^_`//{|//}//~////]*")) 30 throw new InvalidTypeException(value + " contains characters that are not allowed."); 31 return value; 32 } 33 34 }