Package org.nutz.castor.castor

Source Code of org.nutz.castor.castor.String2Pattern

package org.nutz.castor.castor;

import java.util.regex.Pattern;

import org.nutz.castor.Castor;
import org.nutz.castor.FailToCastObjectException;

public class String2Pattern extends Castor<String, Pattern> {

  @Override
  public Pattern cast(String src, Class<?> toType, String... args)
      throws FailToCastObjectException {
    try {
      return Pattern.compile(src);
    }
    catch (Exception e) {
      throw new FailToCastObjectException("Error regex: " + src, e);
    }
  }

}
TOP

Related Classes of org.nutz.castor.castor.String2Pattern

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.