Java Code Examples for org.apache.commons.lang.StringUtils.endsWith()

The following are Jave code examples for showing how to use endsWith() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: Hydrograph   File: IntegerOrParameterValidationRule.java   Source Code and License Vote up 7 votes
@Override
public boolean validate(Object object, String propertyName,Map<String,List<FixedWidthGridRow>> inputSchemaMap,
		boolean isJobImported){
	String value = (String) object;
	if(StringUtils.isNotBlank(value)){
		Matcher matcher=Pattern.compile("[\\d]*").matcher(value);
		if((matcher.matches())|| 
			((StringUtils.startsWith(value, "@{") && StringUtils.endsWith(value, "}")) &&
					!StringUtils.contains(value, "@{}"))){
			return true;
		}
		errorMessage = propertyName + " is mandatory";
	}
	errorMessage = propertyName + " is not integer value or valid parameter";
	return false;
}
 
Example 2
Project: Hydrograph   File: PreStartActivity.java   Source Code and License Vote up 6 votes
/**
 * Checks whether given JDK-PATH is valid or not.
 * 
 * @param javaHome
 * 			input jdk path
 * @param showPopUp
 * 			true if user wants to show pop for invalid path.
 * @return
 * 		true if input string is valid JDK path.
 */
public static boolean isValidJDKPath(String javaHome,boolean showPopUp) {
	try{
		if(javaHome !=null && isValidDirectory(javaHome,showPopUp)){
			if (StringUtils.endsWith(javaHome, SLASH_BIN)) {
				javaHome = StringUtils.replace(javaHome, SLASH_BIN, "");
			}
			if (StringUtils.isNotBlank(javaHome)) {
				StringBuffer jdkPath = new StringBuffer(javaHome);
				jdkPath = jdkPath.delete(0, jdkPath.lastIndexOf("\\") + 1);
				return checkJDKVersion(jdkPath.toString(), showPopUp);
			}
		}
	}
	catch (Exception exception) {
		logger.warn("Exception occurred while validating javaHome path",exception);
	}
	return false;
}
 
Example 3
Project: integrations   File: MadisonPoliceDept.java   Source Code and License Vote up 5 votes
public static String safeParse( Row row ) {
    String date = row.getAs( "Date" );
    String time = row.getAs( "Time" );
    if ( StringUtils.endsWith( date, "/10" ) ) {
        date = "2010";
    }
    if ( StringUtils.endsWith( date, "/11" ) ) {
        date = "2011";
    }
    if ( StringUtils.endsWith( date, "/12" ) ) {
        date = "2012";
    }
    if ( StringUtils.endsWith( date, "/13" ) ) {
        date = "2013";
    }
    if ( StringUtils.endsWith( date, "/14" ) ) {
        date = "2014";
    }
    if ( StringUtils.endsWith( date, "/15" ) ) {
        date = "2015";
    }
    if ( StringUtils.endsWith( date, "/16" ) ) {
        date = "2016";

    }
    if ( StringUtils.endsWith( date, "/17" ) ) {
        date = "2017";
    }
    if ( date.contains( "#" ) || time.contains( "#" ) ) {
        return null;
    }
    return dtHelper.parse( date + " " + time );
}
 
Example 4
Project: ymate-module-sso   File: DefaultModuleCfg.java   Source Code and License Vote up 5 votes
public DefaultModuleCfg(YMP owner) {
    Map<String, String> _moduleCfgs = owner.getConfig().getModuleConfigs(ISSO.MODULE_NAME);
    //
    __tokenCookieName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_cookie_name"), ISSO.MODULE_NAME + "_token");
    //
    __tokenHeaderName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_header_name"), "X-ModuleSSO-Token");
    //
    __tokenParamName = StringUtils.defaultIfBlank(_moduleCfgs.get("token_param_name"), "token");
    //
    __tokenMaxage = BlurObject.bind(_moduleCfgs.get("token_maxage")).toIntValue();
    //
    __tokenValidateTimeInterval = BlurObject.bind(_moduleCfgs.get("token_validate_time_interval")).toIntValue();
    //
    __cacheNamePrefix = StringUtils.trimToEmpty(_moduleCfgs.get("cache_name_prefix"));
    //
    __multiSessionEnabled = BlurObject.bind(_moduleCfgs.get("multi_session_enabled")).toBooleanValue();
    //
    __ipCheckEnabled = BlurObject.bind(_moduleCfgs.get("ip_check_enabled")).toBooleanValue();
    //
    __isClientMode = BlurObject.bind(_moduleCfgs.get("client_mode")).toBooleanValue();
    //
    __serviceAuthKey = StringUtils.trimToEmpty(_moduleCfgs.get("service_auth_key"));
    //
    if (__isClientMode) {
        __serviceBaseUrl = StringUtils.trimToNull(_moduleCfgs.get("service_base_url"));
        if (__serviceBaseUrl != null) {
            if (!StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "http://") &&
                    !StringUtils.startsWithIgnoreCase(__serviceBaseUrl, "https://")) {
                throw new IllegalArgumentException("The parameter service_base_url is invalid");
            } else if (!StringUtils.endsWith(__serviceBaseUrl, "/")) {
                __serviceBaseUrl = __serviceBaseUrl + "/";
            }
        }
    }
    //
    __tokenApater = ClassUtils.impl(_moduleCfgs.get("token_adapter_class"), ISSOTokenAdapter.class, getClass());
    if (__tokenApater == null) {
        __tokenApater = new DefaultSSOTokenAdapter();
    }
    //
    __tokenStorageAdapter = ClassUtils.impl(_moduleCfgs.get("storage_adapter_class"), ISSOTokenStorageAdapter.class, getClass());
    if (!__isClientMode && __tokenStorageAdapter == null) {
        throw new IllegalArgumentException("The parameter storage_adapter_class is invalid");
    }
    //
    if (!__isClientMode) {
        __tokenAttributeAdapter = ClassUtils.impl(_moduleCfgs.get("attribute_adapter_class"), ISSOTokenAttributeAdapter.class, getClass());
    }
}
 
Example 5
Project: YiDu-Novel   File: CreateSiteMapJob.java   Source Code and License Vote up 5 votes
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    log.debug("CreateSiteMapJob start.");
    boolean createSiteMapFlag = YiDuConstants.yiduConf.getBoolean(YiDuConfig.CREATE_SITEMAP, false);
    if (createSiteMapFlag) {
        String uri = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
        String sitemapUri = uri + (StringUtils.endsWith(uri, "/") ? "" : "/") + SITEMAP_DIR + "/";
        try {
            String currentPath = CreateSiteMapJob.class.getClassLoader().getResource("").getPath();
            File f = new File(currentPath).getParentFile().getParentFile();
            currentPath = f.getAbsolutePath();
            log.debug(currentPath);
            String sitemapDir = currentPath + "/" + SITEMAP_DIR + "/";

            log.debug("sitemap dir: " + sitemapDir);
            if (!new File(sitemapDir).exists()) {
                new File(sitemapDir).mkdirs();
            }

            if (SiteMapType.XML.getName().equalsIgnoreCase(
                    YiDuConstants.yiduConf.getString(YiDuConfig.SITEMAP_TYPE))) {
                createXmlSiteMap(sitemapDir, sitemapUri, false);
                createXmlSiteMap(sitemapDir, sitemapUri, true);
            } else {
                String responseBody = Utils.getContentFromUri(uri + SiteMapAction.URL);
                if (StringUtils.isNotBlank(responseBody)) {
                    File destFile = new File(sitemapDir + "/index.html");
                    FileUtils.writeFile(destFile, responseBody, false);
                }
            }
            log.debug("CreateSiteMapJob normally end.");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
 
Example 6
Project: Yidu   File: CreateSiteMapJob.java   Source Code and License Vote up 5 votes
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    log.debug("CreateSiteMapJob start.");
    boolean createSiteMapFlag = YiDuConstants.yiduConf.getBoolean(YiDuConfig.CREATE_SITEMAP, false);
    if (createSiteMapFlag) {
        String uri = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
        String sitemapUri = uri + (StringUtils.endsWith(uri, "/") ? "" : "/") + SITEMAP_DIR + "/";
        try {
            String currentPath = CreateSiteMapJob.class.getClassLoader().getResource("").getPath();
            File f = new File(currentPath).getParentFile().getParentFile();
            currentPath = f.getAbsolutePath();
            log.debug(currentPath);
            String sitemapDir = currentPath + "/" + SITEMAP_DIR + "/";

            log.debug("sitemap dir: " + sitemapDir);
            if (!new File(sitemapDir).exists()) {
                new File(sitemapDir).mkdirs();
            }

            if (SiteMapType.XML.getName().equalsIgnoreCase(
                    YiDuConstants.yiduConf.getString(YiDuConfig.SITEMAP_TYPE))) {
                createXmlSiteMap(sitemapDir, sitemapUri, false);
                uri = YiDuConstants.yiduConf.getString(YiDuConfig.MOBILE_URI);
                sitemapUri = uri + (StringUtils.endsWith(uri, "/") ? "" : "/") + SITEMAP_DIR + "/";
                createXmlSiteMap(sitemapDir, sitemapUri, true);
            } else {
                String responseBody = Utils.getContentFromUri(uri + SiteMapAction.URL);
                if (StringUtils.isNotBlank(responseBody)) {
                    File destFile = new File(sitemapDir + "/index.html");
                    FileUtils.writeFile(destFile, responseBody, false);
                }
            }
            log.debug("CreateSiteMapJob normally end.");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
 
Example 7
Project: Yidu   File: CreateStructuringDataJob.java   Source Code and License Vote up 5 votes
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
    log.debug("CreateStructuringDataJob start.");
    boolean createStructuringDataFlag = YiDuConstants.yiduConf.getBoolean(YiDuConfig.CREATE_STRUCTURINGDATA, false);
    if (createStructuringDataFlag) {
        String uri = YiDuConstants.yiduConf.getString(YiDuConfig.URI);
        String sitemapUri = uri + (StringUtils.endsWith(uri, "/") ? "" : "/") + STRUCTURINGDATA_DIR + "/";
        try {
            String currentPath = CreateSiteMapJob.class.getClassLoader().getResource("").getPath();
            File f = new File(currentPath).getParentFile().getParentFile();
            currentPath = f.getAbsolutePath();
            log.debug(currentPath);
            String sitemapDir = currentPath + "/" + STRUCTURINGDATA_DIR + "/";

            log.debug("sitemap dir: " + sitemapDir);
            if (!new File(sitemapDir).exists()) {
                new File(sitemapDir).mkdirs();
            }

            createXmlSiteMap(sitemapDir, sitemapUri, false);
            uri = YiDuConstants.yiduConf.getString(YiDuConfig.MOBILE_URI);
            sitemapUri = uri + (StringUtils.endsWith(uri, "/") ? "" : "/") + STRUCTURINGDATA_DIR + "/";
            createXmlSiteMap(sitemapDir, sitemapUri, true);

            log.debug("CreateStructuringDataJob normally end.");
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
    }
}
 
Example 8
Project: ymate-payment-v2   File: WxPayAccountMeta.java   Source Code and License Vote up 5 votes
public void setSandboxPrefix(String sandboxPrefix) {
    sandboxPrefix = StringUtils.defaultIfBlank(sandboxPrefix, "sandboxnew");
    if (StringUtils.startsWith(sandboxPrefix, "/")) {
        sandboxPrefix = StringUtils.substringAfter(sandboxPrefix, "/");
    }
    if (!StringUtils.endsWith(this.sandboxPrefix, "/")) {
        sandboxPrefix = sandboxPrefix + "/";
    }
    this.sandboxPrefix = sandboxPrefix;
}
 
Example 9
Project: Hydrograph   File: FTPProtocolSelectionValidator.java   Source Code and License Vote up 5 votes
private boolean validatePort(String text, String propertyName){
	if(StringUtils.isNotBlank(text)){
		Matcher matcher=Pattern.compile("[\\d]*").matcher(text);
		if((matcher.matches())|| 
			((StringUtils.startsWith(text, "@{") && StringUtils.endsWith(text, "}")) &&
					!StringUtils.contains(text, "@{}"))){
			return true;
		}
		errorMessage = propertyName + " is mandatory";
	}
	errorMessage = propertyName + " is not integer value or valid parameter";
	return false;
}
 
Example 10
Project: Hydrograph   File: ExpressionEditorUtil.java   Source Code and License Vote up 5 votes
public String lastString(String field, String seperator) {
	String result = Constants.EMPTY_STRING;
	if (StringUtils.isNotBlank(field)) {
		String[] strArray = StringUtils.split(field, seperator);
		result = strArray[strArray.length - 1];
		if (StringUtils.endsWith(result, Constants.SEMICOLON)) {
			result = StringUtils.remove(result, Constants.SEMICOLON);
		}
	}
	return result;
}
 
Example 11
Project: Hydrograph   File: SchemaHelper.java   Source Code and License Vote up 5 votes
/**
 * This function will return file path with validation
 * @param path
 * @return validPath
 */
public String validatePath(String path){
	String validPath = null;
		if(StringUtils.endsWith(path,File.separator)){
			return path;
		}else{
			validPath = path + File.separator;
			return validPath;
		}
}
 
Example 12
Project: integrations   File: ConvertImages.java   Source Code and License Vote up 4 votes
public static boolean isImage( String path ) {
    return StringUtils.endsWith( path, ".jpg" )
            || StringUtils.endsWith( path, ".png" )
            || StringUtils.endsWith( path, ".gif" );
}
 
Example 13
Project: integrations   File: ConvertImages.java   Source Code and License Vote up 4 votes
public static boolean isImage( String path ) {
    return StringUtils.endsWith( path, ".jpg" )
            || StringUtils.endsWith( path, ".png" )
            || StringUtils.endsWith( path, ".gif" );
}
 
Example 14
Project: integrations   File: ConvertImages.java   Source Code and License Vote up 4 votes
public static boolean isImage( String path ) {
    return StringUtils.endsWith( path, ".jpg" )
            || StringUtils.endsWith( path, ".png" )
            || StringUtils.endsWith( path, ".gif" );
}