本文整理汇总了Java中org.apache.commons.validator.UrlValidator类的典型用法代码示例。如果您正苦于以下问题:Java UrlValidator类的具体用法?Java UrlValidator怎么用?Java UrlValidator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UrlValidator类属于org.apache.commons.validator包,在下文中一共展示了UrlValidator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: validateUrl
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
public boolean validateUrl(String url){
String[] schemes = {"http","https"};
UrlValidator urlValidator = new UrlValidator(schemes);
if(urlValidator.isValid(url)){
System.out.println("is valid");
return true;
}
else{
return false;
}
}
开发者ID:naeemkhan12,项目名称:websiteMonitor,代码行数:12,代码来源:FieldValidation.java
示例2: isValidUrl
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
/**
* This function checks the syntax of a given url
* and returns true in case of the right syntax.
*
* @param sUrl String
* @return boolean
*/
public static boolean isValidUrl(String sUrl) {
String[] schemes = {"http","https"};
UrlValidator urlValidator = new UrlValidator(schemes);
if (urlValidator.isValid(sUrl)) {
return true;
} else {
return urlValidator.isValid(sUrl.replaceFirst("^https?://localhost", "http://www.example.com"));
}
}
开发者ID:major2015,项目名称:easyrec_major,代码行数:17,代码来源:Web.java
示例3: validateUrl
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
private void validateUrl(String aUrl) throws CommanderException {
String[] schemes = { "http", "https" };
UrlValidator urlValidator = new UrlValidator(schemes);
if (!urlValidator.isValid(aUrl)) {
throw new CommanderException(
"The provided Server-URL in your config-file is not a valid URL: '"
+ aUrl + "'");
}
}
开发者ID:jwiesel,项目名称:sfdcCommander,代码行数:10,代码来源:CommanderPropertiesHandler.java
示例4: getStartupFormValidator
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
public StartupFormValidator getStartupFormValidator(StartupForm startupSettings, MotechUserService userService) {
StartupFormValidator startupFormValidator = new StartupFormValidator();
startupFormValidator.add(new RequiredFieldValidator(StartupForm.LANGUAGE, startupSettings.getLanguage()));
startupFormValidator.add(new RequiredFieldValidator(StartupForm.LOGIN_MODE, startupSettings.getLoginMode()));
startupFormValidator.add(new UserRegistrationValidator(new PersistedUserValidator(userService),
new OpenIdUserValidator(new UrlValidator())));
return startupFormValidator;
}
开发者ID:motech,项目名称:motech,代码行数:11,代码来源:StartupFormValidatorFactory.java
示例5: validate
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
@Override
public void validate(Object o, Errors errors) {
Institution institution = (Institution) o;
UrlValidator urlValidator = new UrlValidator(); //ver como inyectar este objeto
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "general.error.empty");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "zip", "general.error.empty");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "website", "general.error.empty");
// input string contains valid website address
/* if (!(institution.getWebsite() != null && institution.getWebsite().isEmpty())) {
*//*if (!urlValidator.isValid(institution.getWebsite())){
errors.rejectValue("website", "website.containNonAddress");
}*//*
*//* if (!institution.getWebsite().matches(WEBSITE_PATTERN)){
errors.rejectValue("website", "website.containNonAddress");
}*//*
*//*pattern = Pattern.compile(WEBSITE_PATTERN);
matcher = pattern.matcher(institution.getWebsite());
if (!matcher.matches()) {
errors.rejectValue("website", "website.containNonAddress");
}*//*
}
*/
// input string conatains characters only
/* if (!errors.hasFieldErrors("name")) {
pattern = Pattern.compile(STRING_PATTERN);
matcher = pattern.matcher(institution.getName());
if (!matcher.matches()) {
errors.rejectValue("name", "name.containNonChar");
}
}*/
if (!errors.hasFieldErrors("name") && institutionDAO.existInstitutionNameByCountry(institution.getName(), institution.getCountry_id())) {
errors.rejectValue("name",
"general.error.exist",
"At must 40 characters.");
}
if (!errors.hasFieldErrors("zip") && institutionDAO.existInstitutionZip(institution.getZip())) {
errors.rejectValue("zip",
"general.error.exist",
"At must 40 characters.");
}
if (institution.getCountry_id() == 0) {
errors.rejectValue("country_id",
"judge.register.error.country",
"At must 40 characters.");
}
if (!errors.hasFieldErrors("zip")) {
pattern = Pattern.compile(ZIP_PATTERN);
matcher = pattern.matcher(institution.getZip());
if (!matcher.matches()) {
errors.rejectValue("zip",
"general.error.upper.number",
"Upper case characters and numbers only");
}
}
}
开发者ID:dovier,项目名称:coj-web,代码行数:64,代码来源:institutionValidator.java
示例6: OpenIdUserValidator
import org.apache.commons.validator.UrlValidator; //导入依赖的package包/类
public OpenIdUserValidator(UrlValidator urlValidator) {
this.urlValidator = urlValidator;
}
开发者ID:motech,项目名称:motech,代码行数:4,代码来源:OpenIdUserValidator.java
注:本文中的org.apache.commons.validator.UrlValidator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论