List of usage examples for org.apache.commons.lang StringUtils removeEnd
public static String removeEnd(String str, String remove)
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
From source file:co.marcin.novaguilds.enums.Message.java
/** * Gets the path of ConfigurationSection the Message's in * * @return the path/*from ww w . j av a2 s . com*/ */ private String getParentPath() { String[] split = StringUtils.split(getPath(), "."); return StringUtils.removeEnd(getPath(), "." + split[split.length - 1]); }
From source file:edu.mayo.cts2.framework.webapp.rest.controller.AbstractMessageWrappingController.java
protected String mapToQueryString(Map<String, Object> parameters) { if (MapUtils.isNotEmpty(parameters)) { StringBuffer sb = new StringBuffer(); sb.append("?"); for (Entry<String, Object> entry : parameters.entrySet()) { if (entry.getValue().getClass().isArray()) { for (Object val : (Object[]) entry.getValue()) { sb.append(entry.getKey() + "=" + val); sb.append("&"); }// ww w. ja va 2 s. c om } else { sb.append(entry.getKey() + "=" + entry.getValue()); sb.append("&"); } } return StringUtils.removeEnd(sb.toString(), "&"); } else { return ""; } }
From source file:com.funambol.foundation.util.MediaUtils.java
/** * The dates in the EXIF have the format yyyy:MM:dd HH:mm:ss that should * be converted in the UTC format. Since the exif specification does not * declare that this is a date in local time, no timezone will be applied * during convertion in UTC format./*www . j a va 2 s .c o m*/ * * @param date the exif string date to convert * @return the date in UTC format (yyyyMMdd'T'HHmmss'Z') or null */ private String fixExifDate(String tagValueDesc) { try { tagValueDesc = StringUtils.removeStart(tagValueDesc, "'"); tagValueDesc = StringUtils.removeEnd(tagValueDesc, "'"); return TimeUtils.convertDateFromTo(tagValueDesc, TimeUtils.PATTERN_EXIF_DATE, TimeUtils.PATTERN_UTC); } catch (ParseException e) { // don't set the creation date of the FDO } return null; }
From source file:net.paoding.rose.web.impl.module.ModulesBuilderImpl.java
private List<InterceptorDelegate> findInterceptors(XmlWebApplicationContext context) { String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(), ControllerInterceptor.class); ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(interceptorNames.length); for (String beanName : interceptorNames) { ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName); Class<?> userClass = ClassUtils.getUserClass(interceptor); if (userClass.isAnnotationPresent(Ignored.class)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (Ignored):" + interceptor); }/*from w w w . ja v a 2 s . co m*/ continue; } if (userClass.isAnnotationPresent(NotForSubModules.class) && !context.getBeanFactory().containsBeanDefinition(beanName)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (NotForSubModules):" + interceptor); } continue; } if (!userClass.getSimpleName().endsWith(RoseConstants.INTERCEPTOR_SUFFIX)) { logger.error("", new IllegalArgumentException("Interceptor must be end with '" + RoseConstants.INTERCEPTOR_SUFFIX + "': " + userClass.getName())); continue; } InterceptorBuilder builder = new InterceptorBuilder(interceptor); Interceptor annotation = userClass.getAnnotation(Interceptor.class); if (annotation != null) { builder.oncePerRequest(annotation.oncePerRequest()); } String interceporName; if (beanName.startsWith(AUTO_BEAN_NAME_PREFIX)) { interceporName = StringUtils.removeEnd(StringUtils.uncapitalize(userClass.getSimpleName()), RoseConstants.INTERCEPTOR_SUFFIX); } else { interceporName = StringUtils.removeEnd(beanName, RoseConstants.INTERCEPTOR_SUFFIX); } final String rose = "rose"; if (interceporName.startsWith(rose) && (interceporName.length() == rose.length() || Character.isUpperCase(interceporName.charAt(rose.length()))) && !userClass.getName().startsWith("net.paoding.rose.")) { throw new IllegalArgumentException("illegal interceptor name '" + interceporName + "' for " + userClass.getName() + ": don't starts with 'rose', it's reserved"); } builder.name(interceporName); InterceptorDelegate wrapper = builder.build(); interceptors.add(wrapper); if (logger.isDebugEnabled()) { int priority = 0; if (interceptor instanceof Ordered) { priority = ((Ordered) interceptor).getPriority(); } logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n + wrapper.getName() + "=" + userClass.getName()); } } Collections.sort(interceptors); throwExceptionIfDuplicatedNames(interceptors); return interceptors; }
From source file:com.laxser.blitz.web.impl.module.ModulesBuilderImpl.java
private List<InterceptorDelegate> findInterceptors(XmlWebApplicationContext context) { String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(), ControllerInterceptor.class); ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(interceptorNames.length); for (String beanName : interceptorNames) { ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName); Class<?> userClass = ClassUtils.getUserClass(interceptor); if (userClass.isAnnotationPresent(Ignored.class)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (Ignored):" + interceptor); }/*from www . j a v a 2 s. c o m*/ continue; } if (userClass.isAnnotationPresent(NotForSubModules.class) && !context.getBeanFactory().containsBeanDefinition(beanName)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (NotForSubModules):" + interceptor); } continue; } if (!userClass.getSimpleName().endsWith(BlitzConstants.INTERCEPTOR_SUFFIX)) { logger.error("", new IllegalArgumentException("Interceptor must be end with '" + BlitzConstants.INTERCEPTOR_SUFFIX + "': " + userClass.getName())); continue; } InterceptorBuilder builder = new InterceptorBuilder(interceptor); Interceptor annotation = userClass.getAnnotation(Interceptor.class); if (annotation != null) { builder.oncePerRequest(annotation.oncePerRequest()); } String interceporName; if (beanName.startsWith(AUTO_BEAN_NAME_PREFIX)) { interceporName = StringUtils.removeEnd(StringUtils.uncapitalize(userClass.getSimpleName()), BlitzConstants.INTERCEPTOR_SUFFIX); } else { interceporName = StringUtils.removeEnd(beanName, BlitzConstants.INTERCEPTOR_SUFFIX); } final String rose = "rose"; if (interceporName.startsWith(rose) && (interceporName.length() == rose.length() || Character.isUpperCase(interceporName.charAt(rose.length()))) && !userClass.getName().startsWith("net.paoding.rose.")) { throw new IllegalArgumentException("illegal interceptor name '" + interceporName + "' for " + userClass.getName() + ": don't starts with 'rose', it's reserved"); } builder.name(interceporName); InterceptorDelegate wrapper = builder.build(); interceptors.add(wrapper); if (logger.isDebugEnabled()) { int priority = 0; if (interceptor instanceof Ordered) { priority = ((Ordered) interceptor).getPriority(); } logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n + wrapper.getName() + "=" + userClass.getName()); } } Collections.sort(interceptors); throwExceptionIfDuplicatedNames(interceptors); return interceptors; }
From source file:com.sinosoft.one.mvc.web.impl.module.ModulesBuilderImpl.java
private List<InterceptorDelegate> findInterceptors(XmlWebApplicationContext context) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException { String[] interceptorNames = SpringUtils.getBeanNames(context.getBeanFactory(), ControllerInterceptor.class); ArrayList<InterceptorDelegate> interceptors = new ArrayList<InterceptorDelegate>(interceptorNames.length); for (String beanName : interceptorNames) { ControllerInterceptor interceptor = (ControllerInterceptor) context.getBean(beanName); Class<?> userClass = ClassUtils.getUserClass(interceptor); if (userClass.isAnnotationPresent(Ignored.class)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (Ignored):" + interceptor); }/*w ww. j a v a2 s . c om*/ continue; } if (userClass.isAnnotationPresent(NotForSubModules.class) && !context.getBeanFactory().containsBeanDefinition(beanName)) { if (logger.isDebugEnabled()) { logger.debug("Ignored interceptor (NotForSubModules):" + interceptor); } continue; } if (!userClass.getSimpleName().endsWith(MvcConstants.INTERCEPTOR_SUFFIX)) { logger.error("", new IllegalArgumentException("Interceptor must be end with '" + MvcConstants.INTERCEPTOR_SUFFIX + "': " + userClass.getName())); continue; } InterceptorBuilder builder = new InterceptorBuilder(interceptor); Interceptor annotation = userClass.getAnnotation(Interceptor.class); if (annotation != null) { builder.oncePerRequest(annotation.oncePerRequest()); } String interceporName; if (beanName.startsWith(AUTO_BEAN_NAME_PREFIX)) { interceporName = StringUtils.removeEnd(StringUtils.uncapitalize(userClass.getSimpleName()), MvcConstants.INTERCEPTOR_SUFFIX); } else { interceporName = StringUtils.removeEnd(beanName, MvcConstants.INTERCEPTOR_SUFFIX); } final String mvc = "mvc"; if (interceporName.startsWith(mvc) && (interceporName.length() == mvc.length() || Character.isUpperCase(interceporName.charAt(mvc.length()))) && !userClass.getName().startsWith("com.sinosoft.one.mvc.")) { throw new IllegalArgumentException("illegal interceptor name '" + interceporName + "' for " + userClass.getName() + ": don't starts with 'mvc', it's reserved"); } builder.name(interceporName); InterceptorDelegate wrapper = builder.build(); interceptors.add(wrapper); if (logger.isDebugEnabled()) { int priority = 0; if (interceptor instanceof Ordered) { priority = ((Ordered) interceptor).getPriority(); } logger.debug("recognized interceptor[priority=" + priority + "]: " // \r\n + wrapper.getName() + "=" + userClass.getName()); } } // start by kylin List<String> rList = ResourceLoaderUtil.getResource("interceptors-order.xml", true); if (rList != null) { Collections.sort(interceptors); int tempGlobalPriority = 1; for (String configInterName : rList) { for (int j = 0, length = interceptors.size(); j < length; j++) { InterceptorDelegate interceptorDelegate = interceptors.get(j); ControllerInterceptor temp = InterceptorDelegate .getMostInnerInterceptor(interceptorDelegate.getInterceptor()); if (temp.getClass().getName().startsWith("com.sinosoft.one.mvc.web") || temp.getClass().getName().startsWith("com.sinosoft.one.mvc.controllers")) { continue; } if (rList.toString().contains(temp.getClass().getName())) { if (configInterName.trim().equals(temp.getClass().getName())) { if (temp instanceof ControllerInterceptorAdapter) { ((ControllerInterceptorAdapter) temp).setPriority( this.GLOBAL_INTERCEPTOR_CONFIG_START_PRIORITY - tempGlobalPriority++); continue; } else { if (temp instanceof ControllerInterceptorAdapter) { ((ControllerInterceptorAdapter) temp).setPriority( this.INTERCEPTOR_NOT_CONFIG_START_PRIORITY - tempGlobalPriority++); } } } } else { if (temp instanceof ControllerInterceptorAdapter) { ((ControllerInterceptorAdapter) temp) .setPriority(this.INTERCEPTOR_NOT_CONFIG_START_PRIORITY - tempGlobalPriority++); } } if (logger.isDebugEnabled()) { logger.debug("Interceptor's Priority:" + temp.getClass().getName() + ":" + ((ControllerInterceptorAdapter) temp).getPriority()); } } } } // end by kylin Collections.sort(interceptors); throwExceptionIfDuplicatedNames(interceptors); return interceptors; }
From source file:adalid.commons.velocity.Writer.java
private boolean accept(File templatePropertiesFile, String[] pathfilters) { if (templatePropertiesFile == null) { return false; }/*from w w w . jav a 2 s .c om*/ if (pathfilters == null || pathfilters.length == 0) { return true; } String name = StringUtils.removeEndIgnoreCase(templatePropertiesFile.getName(), PROPERTIES_SUFFIX); String lowerName = name.toLowerCase(); String fileFilter; String anything = ".*"; String delimiters = "[\\W]"; String word = "[\\w\\-]*"; for (String pathfilter : pathfilters) { fileFilter = pathfilter.replace(FILE_SEPARATOR, SLASH); fileFilter = fileFilter.toLowerCase(); fileFilter = StringUtils.removeStart(fileFilter, SLASH); fileFilter = StringUtils.removeEnd(fileFilter, SLASH); if (fileFilter.isEmpty()) { continue; } if (fileFilter.matches(word)) { if (lowerName .matches(CARET + anything + delimiters + fileFilter + delimiters + anything + DOLLAR)) { logger.debug("filter " + ASTERISK + pathfilter + ASTERISK + " excludes " + name); return false; } if (lowerName.matches(CARET + fileFilter + delimiters + anything)) { logger.debug("filter " + pathfilter + ASTERISK + " excludes " + name); return false; } if (lowerName.matches(anything + delimiters + fileFilter + DOLLAR)) { logger.debug("filter " + ASTERISK + pathfilter + " excludes " + name); return false; } if (lowerName.matches(CARET + fileFilter + DOLLAR)) { logger.debug("filter " + pathfilter + " excludes " + name); return false; } } } return true; }
From source file:com.hangum.tadpole.rdb.core.dialog.job.CreateJobDialog.java
private void initParameters(int index) { try {/*from www. ja v a 2 s . co m*/ ProcedureFunctionDAO dao = this.showObjects.get(index); SqlMapClient client = TadpoleSQLManager.getInstance(userDB); HashMap<String, String> map = new HashMap<String, String>(); map.put("schema_name", dao.getSchema_name() == null ? userDB.getSchema() : dao.getSchema_name()); //$NON-NLS-1$ map.put("package_name", dao.getPackagename()); map.put("object_name", dao.getName()); map.put("overload", dao.getOverload() + ""); String strParam = ""; List<InOutParameterDAO> inParamList = client.queryForList("getProcedureInParamter", map); for (InOutParameterDAO param : inParamList) { strParam += param.getName() + "/* " + param.getType() + ":" + param.getRdbType() + " */" + ","; } String strVariable = ""; List<InOutParameterDAO> outParamList = client.queryForList("getProcedureOutParamter", map); for (InOutParameterDAO param : outParamList) { if (StringUtils.equals("OUT", param.getType())) { strVariable += param.getName() + " " + param.getRdbType() + "; "; strParam += param.getName() + "/* " + param.getType() + ":" + param.getRdbType() + " */" + ","; } } strParam = StringUtils.removeEnd(strParam.toString(), ","); if (!StringUtils.isBlank(strVariable)) { strVariable = "DECLARE " + strVariable; } String strWhat = strVariable + "BEGIN "; if (!StringUtils.isBlank(dao.getSchema_name())) { strWhat += SQLUtil.makeIdentifierName(userDB, dao.getSchema_name()) + "."; } strWhat += SQLUtil.makeIdentifierName(userDB, dao.getName()) + "("; strWhat += strParam; strWhat += "); "; strWhat += "END;"; this.textScript.setText(strWhat); } catch (Exception e) { logger.error("Initialize parameter body", e); } }
From source file:adalid.util.velocity.BaseBuilder.java
private String finalisePath(String path) { String p = path + "/"; if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) { if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) { p = "${resourcesProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME); p = p.replace("/src/conf/", "/${resourcesConfigurationFilesFolder}/"); p = p.replace("/src/code/", "/${resourcesJavaMainFolder}/"); p = p.replace("/src/copy/", "/${resourcesPacketsFolder}/"); p = p.replace("/src/crop/", "/${resourcesBundlesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) { p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME); p = p.replace("/src/conf/", "/${libConfigurationFilesFolder}/"); p = p.replace("/src/java/code/", "/${libJavaMainFolder}/"); p = p.replace("/src/java/copy/", "/${libJavaCopyFolder}/"); p = p.replace("/src/java/crop/", "/${libJavaSourcesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) { p = "${warProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME); p = p.replace("/src/conf/", "/${warConfigurationFilesFolder}/"); p = p.replace("/src/java/code/", "/${webJavaMainFolder}/"); p = p.replace("/src/java/copy/", "/${webJavaCopyFolder}/"); p = p.replace("/src/java/copy-1/", "/${webJavaCopy1Folder}/"); p = p.replace("/src/java/copy-2/", "/${webJavaCopy2Folder}/"); p = p.replace("/src/java/crop/", "/${webJavaSourcesFolder}/"); p = p.replace("/web/WEB-INF/", "/${webConfigurationFilesFolder}/"); p = p.replace("/web/code/", "/${webPagesMainFolder}/"); p = p.replace("/web/copy/", "/${webPagesCopyFolder}/"); p = p.replace("/web/crop/", "/${webPagesSourcesFolder}/"); p = p.replace("/web/", "/${webPagesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) { p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME); p = p.replace("/src/conf/", "/${ejbConfigurationFilesFolder}/"); p = p.replace("/src/java/code/", "/${ejbJavaMainFolder}/"); p = p.replace("/src/java/copy/", "/${ejbJavaCopyFolder}/"); p = p.replace("/src/java/crop/", "/${ejbJavaSourcesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) { p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME); p = p.replace("/src/conf/", "/${earConfigurationFilesFolder}/"); } else {/* w ww . jav a 2s .c om*/ p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p; } p = StringUtils.removeEnd(p, "/"); return p; } return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path; }
From source file:adalid.util.velocity.SecondBaseBuilder.java
private String finalisePath(String path) { String p = path + "/"; if (StringUtils.startsWithIgnoreCase(p, SOURCE_PROJECT_ROOT_FOLDER_NAME)) { if (StringUtils.startsWithIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME)) { p = "${resourcesProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, RESOURCES_PROJECT_FOLDER_NAME); p = p.replace("/src/main/resources/META-INF/", "/${resourcesConfigurationFilesFolder}/"); p = p.replace("/src/main/resources/", "/${resourcesBundlesFolder}/"); p = p.replace("/src/main/java/", "/${resourcesJavaMoreFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, LIB_PROJECT_FOLDER_NAME)) { p = "${libProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, LIB_PROJECT_FOLDER_NAME); p = p.replace("/src/main/resources/META-INF/", "/${libConfigurationFilesFolder}/"); p = p.replace("/src/main/java/", "/${libJavaMoreFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, WAR_PROJECT_FOLDER_NAME)) { p = "${webProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, WAR_PROJECT_FOLDER_NAME); p = p.replace("/src/main/resources/META-INF/", "/${warConfigurationFilesFolder}/"); p = p.replace("/src/main/java/", "/${webJavaMoreFolder}/"); p = p.replace("/src/main/webapp/WEB-INF/", "/${webConfigurationFilesFolder}/"); p = p.replace("/src/main/webapp/", "/${webPagesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, EJB_PROJECT_FOLDER_NAME)) { p = "${ejbProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EJB_PROJECT_FOLDER_NAME); p = p.replace("/src/main/resources/META-INF/", "/${ejbConfigurationFilesFolder}/"); p = p.replace("/src/main/java/", "/${ejbJavaMoreFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, EAR_PROJECT_FOLDER_NAME)) { p = "${earProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, EAR_PROJECT_FOLDER_NAME); p = p.replace("/src/main/application/META-INF/", "/${earConfigurationFilesFolder}/"); } else if (StringUtils.startsWithIgnoreCase(p, POM_PROJECT_FOLDER_NAME)) { p = "${rootProjectFolderPath}/" + StringUtils.removeStartIgnoreCase(p, POM_PROJECT_FOLDER_NAME); } else {/*from w w w. j av a 2s . com*/ p = ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + p; } p = StringUtils.removeEnd(p, "/"); return p; } return ROOT_FOLDER_SLASHED_PATH + "/" + BASE_FOLDER_NAME + path; }