List of usage examples for org.apache.commons.lang StringUtils substringBefore
public static String substringBefore(String str, String separator)
Gets the substring before the first occurrence of a separator.
From source file:com.google.gdt.eclipse.designer.uibinder.parser.UiBinderDescriptionProcessor.java
/** * UiBinder does not allow attributes for setter which differs only in type, so we should not * create {@link Property}s for them, unless String. *///from w w w .j a v a2 s. c om private void removeAmbiguousProperties(ComponentDescription componentDescription) { List<GenericPropertyDescription> properties = componentDescription.getProperties(); // prepare duplicate names of properties Set<String> propertyNames = Sets.newHashSet(); Set<String> duplicateNames = Sets.newHashSet(); for (GenericPropertyDescription propertyDescription : properties) { String title = propertyDescription.getTitle(); String name = StringUtils.substringBefore(title, "("); if (propertyNames.contains(name)) { duplicateNames.add(name); } else { propertyNames.add(name); } } // if name of property is duplicate, remove it for (GenericPropertyDescription propertyDescription : properties) { String title = propertyDescription.getTitle(); String name = StringUtils.substringBefore(title, "("); if (duplicateNames.contains(name) && propertyDescription.getType() != String.class) { propertyDescription.setEditor(null); } } }
From source file:info.magnolia.cms.i18n.HierarchyBasedI18nContentSupport.java
@Override protected Locale onDetermineLocale() { Locale locale = null;/*from w w w . j a v a 2s . co m*/ Locale validUnsupportedLocale = null; final String i18nURI = MgnlContext.getAggregationState().getCurrentURI(); log.debug("URI to check for locales is {}", i18nURI); final String[] splitURI = i18nURI.split("/"); final int lastTokenIdx = splitURI.length - 1; for (int i = 0; i < splitURI.length; i++) { String uriToken = splitURI[i]; if (i == lastTokenIdx) { uriToken = StringUtils.substringBefore(uriToken, "."); } locale = determineLocalFromString(uriToken); if (LocaleUtils.isAvailableLocale(locale)) { log.debug("found a valid Locale code {}", uriToken); if (isLocaleSupported(locale)) { break; } // the URI contains a valid Locale code but it is not // supported by the current I18n configuration. // We store it anyway and eventually return it if no exact // match will be found at the end of this loop. validUnsupportedLocale = locale; } locale = null; } return locale != null ? locale : validUnsupportedLocale; }
From source file:com.cognifide.actions.msg.push.active.PushClient.java
private PushClientRunnable createLoop(AgentConfig config) throws URISyntaxException { final String url = StringUtils.substringBefore(config.getTransportURI(), "/bin"); final String username = config.getTransportUser(); final String password = config.getTransportPassword(); return new PushClientRunnable(receivers, url, username, password); }
From source file:com.stevpet.sonar.plugins.dotnet.mscover.codecoverage.command.WindowsCodeCoverageCommand.java
private void extractBinaries(String tempFolder) { try {/*from w w w . j a va2 s. c o m*/ URL executableURL = WindowsCodeCoverageCommand.class.getResource(binaryFolder); String archivePath = StringUtils.substringBefore(executableURL.getFile().replace("%20", " "), "!") .substring(5); ZipUtils.extractArchiveFolderIntoDirectory(archivePath, binaryName, tempFolder); } catch (IOException e) { throw new MsCoverException("Could not extract the embedded executable: " + e.getMessage(), e); } }
From source file:com.haulmont.cuba.core.sys.javacl.compiler.ClassLoaderImpl.java
private boolean cacheContainsFirstLevelClass(String qualifiedClassName) { String outerClassName = StringUtils.substringBefore(qualifiedClassName, "$"); return proxyClassLoader.contains(outerClassName); }
From source file:eu.annocultor.xconverter.impl.XmlElementForVelocity.java
public static String removeAffix(String value, String affixChar) throws Exception { return StringUtils.substringBefore(value, affixChar); }
From source file:eionet.cr.dao.virtuoso.VirtuosoUrgentHarvestQueueDAO.java
@Override public void addPushHarvest(UrgentHarvestQueueItemDTO queueItem) throws DAOException { List<Object> values = new ArrayList<Object>(); String url = queueItem.getUrl(); if (url != null) { url = StringUtils.substringBefore(url, "#"); }/*from w ww . java 2s .c o m*/ values.add(url); values.add(queueItem.getPushedContent()); Connection conn = null; try { conn = getSQLConnection(); SQLUtil.executeUpdate(ADD_PUSH_HARVEST_SQL, values, conn); } catch (Exception e) { throw new DAOException(e.getMessage(), e); } finally { SQLUtil.close(conn); } }
From source file:com.netflix.explorers.PropertiesGlobalModelContext.java
public PropertiesGlobalModelContext(Properties props) { this.properties = props; environmentName = props.getProperty(PROPERTY_ENVIRONMENT_NAME); currentRegion = props.getProperty(PROPERTY_CURRENT_REGION); applicationVersion = props.getProperty(PROPERTY_APPLICATION_VERSION); applicationName = props.getProperty(PROPERTY_APPLICATION_NAME); isLocal = Boolean.parseBoolean(props.getProperty(PROPERTY_IS_LOCAL, "false")); homePageUrl = props.getProperty(PROPERTY_HOME_PAGE); defaultPort = Short.parseShort(props.getProperty(PROPERTY_DEFAULT_PORT, "8080")); dataCenter = props.getProperty(PROPERTY_DATA_CENTER); defaultExplorerName = props.getProperty(PROPERTY_DEFAULT_EXPLORER); try {//from w w w. j a va2 s .c o m Map<Object, Object> dcs = ConfigurationConverter .getMap(ConfigurationConverter.getConfiguration(props).subset(PROPERTIES_PREFIX + ".dc")); for (Entry<Object, Object> dc : dcs.entrySet()) { String key = StringUtils.substringBefore(dc.getKey().toString(), "."); String attr = StringUtils.substringAfter(dc.getKey().toString(), "."); CrossLink link = links.get(key); if (link == null) { link = new CrossLink(); links.put(key, link); } BeanUtils.setProperty(link, attr, dc.getValue()); } } catch (Exception e) { LOG.error("Exception ", e); throw new RuntimeException(e); } }
From source file:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java
/** * other object compile/* w w w . j a v a 2s. co m*/ * * @param actionType * @param objType * @param objName * @param userDB */ public static String otherObjectCompile(PublicTadpoleDefine.QUERY_DDL_TYPE actionType, String objType, String objName, UserDBDAO userDB) throws Exception { // ? DEBUG? ? ? ?. //TODO: DAO? ? ? ?? . Map<String, String> paramMap = new HashMap<String, String>(); if (StringUtils.contains(objName, '.')) { //?? ?? ... paramMap.put("schema_name", StringUtils.substringBefore(objName, ".")); paramMap.put("object_name", SQLUtil.makeIdentifierName(userDB, StringUtils.substringAfter(objName, "."))); paramMap.put("full_name", SQLUtil.makeIdentifierName(userDB, objName)); } else { // ? . paramMap.put("schema_name", userDB.getSchema()); paramMap.put("object_name", SQLUtil.makeIdentifierName(userDB, objName)); paramMap.put("full_name", userDB.getSchema() + "." + SQLUtil.makeIdentifierName(userDB, objName)); } if (PublicTadpoleDefine.QUERY_DDL_TYPE.JAVA == actionType) { //Java object ? ? . return otherObjectCompile(actionType, objType, paramMap, userDB, false); } else { return otherObjectCompile(actionType, objType, paramMap, userDB, userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT); } }
From source file:com.aeells.hibernate.profiling.HibernateProfilingInterceptor.java
private void logProfileCall(final ProceedingJoinPoint call, final List<Object> models, final long duration) { if (models != null && !models.isEmpty()) { LOGGER.trace(new StringBuilder( StringUtils.substringBefore(call.getSignature().getDeclaringType().getSimpleName(), "$")) .append("|").append(call.getSignature().getName()).append("|") .append(getClassNameAndPersistentIds(models)).append(duration)); }/*from ww w . j av a2s . c o m*/ }