List of usage examples for org.apache.commons.lang StringUtils substringAfter
public static String substringAfter(String str, String separator)
Gets the substring after the first occurrence of a separator.
From source file:com.kylinolap.common.util.HadoopUtil.java
/** * e.g. "hbase:kylin-local.corp.ebay.com:2181:/hbase-unsecure" *///from ww w .ja va 2s .com public static Configuration newHBaseConfiguration(String url) { Configuration conf = HBaseConfiguration.create(); if (StringUtils.isEmpty(url)) return conf; // chop off "hbase:" if (url.startsWith("hbase:") == false) throw new IllegalArgumentException("hbase url must start with 'hbase:' -- " + url); url = StringUtils.substringAfter(url, "hbase:"); if (StringUtils.isEmpty(url)) return conf; // case of "hbase:domain.com:2181:/hbase-unsecure" Pattern urlPattern = Pattern.compile("([\\w\\d\\-.]+)[:](\\d+)(?:[:](.*))?"); Matcher m = urlPattern.matcher(url); if (m.matches() == false) throw new IllegalArgumentException("HBase URL '" + url + "' is invalid, expected url is like '" + "hbase:domain.com:2181:/hbase-unsecure" + "'"); logger.debug("Creating hbase conf by parsing -- " + url); String quorum = m.group(1); try { InetAddress.getByName(quorum); } catch (UnknownHostException e) { throw new IllegalArgumentException("Zookeeper quorum is invalid: " + quorum + "; urlString=" + url, e); } conf.set(HConstants.ZOOKEEPER_QUORUM, quorum); String port = m.group(2); conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, port); String znodePath = m.group(3) == null ? "" : m.group(3); if (StringUtils.isEmpty(znodePath) == false) conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodePath); // reduce rpc retry conf.set(HConstants.HBASE_CLIENT_PAUSE, "3000"); conf.set(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "5"); conf.set(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, "60000"); // conf.set(ScannerCallable.LOG_SCANNER_ACTIVITY, "true"); return conf; }
From source file:com.parasoft.xtest.reports.jenkins.ParasoftDetailBuilder.java
@Override public Object createDetails(String link, AbstractBuild<?, ?> owner, AnnotationContainer container, String defaultEncoding, String displayName) { if (link.startsWith("link.")) { //$NON-NLS-1$ String suffix = StringUtils.substringAfter(link, "link."); //$NON-NLS-1$ String[] fromToStrings = StringUtils.split(suffix, "."); //$NON-NLS-1$ if (fromToStrings.length == 2) { return createParasoftSourceDetail(owner, container, defaultEncoding, fromToStrings[0], fromToStrings[1]);/* ww w . j a v a2 s. co m*/ } return null; } if (link.startsWith("doc.")) { //$NON-NLS-1$ String sAnalzerRuleId = StringUtils.substringAfter(link, "doc."); //$NON-NLS-1$ String[] splitted = sAnalzerRuleId.split("\\|"); //$NON-NLS-1$ if (splitted.length != 2) { Logger.getLogger().warn("Wrong url with analyzer and ruleId, cannot parse: " + sAnalzerRuleId); //$NON-NLS-1$ return null; } return new RuleDocumentation(owner, splitted[0], splitted[1]); } return super.createDetails(link, owner, container, defaultEncoding, displayName); }
From source file:com.xyz.util.PropertyFilter.java
/** * //from ww w .ja va 2 s . c o m * @param filterName EQ_S_NAME * @param value */ public PropertyFilter(final String filterName, final Object value) { String matchTypeCode = StringUtils.substringBefore(filterName, "_"); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode.toUpperCase()); } catch (RuntimeException e) { throw new IllegalArgumentException("filter??,.", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); propertyNames = StringUtils.split(propertyNameStr, PropertyFilter.OR_SEPARATOR); this.value = value; }
From source file:com.hangum.tadpole.rdb.erd.core.utils.TDBDataHandler.java
/** * ?? Table? ./*from ww w .ja v a2 s . co m*/ * * @param userDB * @param tableDao * @throws Exception */ public static List<TableColumnDAO> getColumns(UserDBDAO userDB, TableDAO tableDao) throws Exception { List<TableColumnDAO> returnColumns = new ArrayList<TableColumnDAO>(); Map<String, String> mapParam = new HashMap<String, String>(); mapParam.put("db", userDB.getDb()); String strTableName = ""; if (userDB.getDBDefine() == DBDefine.SQLite_DEFAULT) strTableName = tableDao.getSysName(); else strTableName = tableDao.getName(); if (userDB.getDBDefine() == DBDefine.ALTIBASE_DEFAULT) { mapParam.put("user", StringUtils.substringBefore(strTableName, ".")); mapParam.put("table", StringUtils.substringAfter(strTableName, ".")); } else { mapParam.put("schema", tableDao.getSchema_name()); mapParam.put("table", strTableName); } if (userDB.getDBDefine() == DBDefine.TAJO_DEFAULT) { returnColumns = new TajoConnectionManager().tableColumnList(userDB, mapParam); } else if (userDB.getDBDefine() == DBDefine.POSTGRE_DEFAULT) { if ("".equals(mapParam.get("schema")) || null == mapParam.get("schema")) { mapParam.put("schema", "public"); } SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); returnColumns = sqlClient.queryForList("tableColumnList", mapParam); //$NON-NLS-1$ } else { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); returnColumns = sqlClient.queryForList("tableColumnList", mapParam); //$NON-NLS-1$ } if (DBDefine.SQLite_DEFAULT == userDB.getDBDefine()) { try { SqlMapClient sqlClient = TadpoleSQLManager.getInstance(userDB); List<SQLiteForeignKeyListDAO> foreignKeyList = sqlClient.queryForList("tableForeignKeyList", //$NON-NLS-1$ mapParam); for (SQLiteForeignKeyListDAO fkeydao : foreignKeyList) { for (TableColumnDAO dao : returnColumns) { if (dao.getName().equals(fkeydao.getFrom())) { if (PublicTadpoleDefine.isPK(dao.getKey())) { dao.setKey("MUL"); } else { dao.setKey("FK"); } } } } } catch (Exception e) { logger.error("not found foreignkey for " + tableDao.getName()); } } // if find the keyword is add system quote. for (TableColumnDAO td : returnColumns) { td.setTableDao(tableDao); td.setSysName(SQLUtil.makeIdentifierName(userDB, td.getField())); } returnColumns = DBAccessCtlManager.getInstance().getColumnFilter(tableDao, returnColumns, userDB); return returnColumns; }
From source file:com.googlecode.jtiger.modules.ecside.preferences.TableProperties.java
public static InputStream getInputStream(String preferencesLocation, WebContext context) throws IOException { if (preferencesLocation.startsWith("WEB-INF")) { preferencesLocation = "/" + preferencesLocation; }/*from w w w. j ava2 s. c o m*/ if (preferencesLocation.startsWith("/WEB-INF")) { String path = context.getRealPath("/WEB-INF"); String name = StringUtils.substringAfter(preferencesLocation, "/WEB-INF/"); return new FileInputStream(path + "/" + name); } return TableProperties.class.getResourceAsStream(preferencesLocation); }
From source file:com.ultrapower.eoms.common.plugin.ecside.preferences.TableProperties.java
public static InputStream getInputStream(String preferencesLocation,WebContext context) throws IOException { if (preferencesLocation.startsWith("WEB-INF")) { preferencesLocation="/"+preferencesLocation; }//from w w w.j a v a2s .c o m if (preferencesLocation.startsWith("/WEB-INF")) { String path = context.getRealPath("/WEB-INF"); String name = StringUtils.substringAfter(preferencesLocation, "/WEB-INF/"); return new FileInputStream(path + "/" + name); } return TableProperties.class.getResourceAsStream(preferencesLocation); }
From source file:com.google.resting.component.impl.URLContext.java
private void constructContextPath(String restUrl) { this.targetDomain = StringUtils.substringBetween(restUrl, URL_SEPARATOR, SEPARATOR); this.contextPath = StringUtils.substringAfter(restUrl, targetDomain); if (restUrl.startsWith(RequestConstants.HTTPS)) this.isSecureInvocation = true; removeEnd();// w ww.j a v a 2s. c o m // System.out.println("url is "+targetDomain); // System.out.println("context path is "+contextPath); }
From source file:com.amalto.core.history.accessor.AttributeAccessor.java
public AttributeAccessor(DOMAccessor parent, String xpath, MutableDocument document) { this.parent = parent; this.xpath = StringUtils.substringBefore(xpath, "/@"); //$NON-NLS-1$ this.attributeName = StringUtils.substringAfter(xpath, "@"); //$NON-NLS-1$ this.document = document; }
From source file:it.openutils.mgnlaws.magnolia.init.ClasspathPropertiesInitializer.java
@Override public boolean loadPropertiesFile(String rootPath, String location) { if (StringUtils.startsWith(location, CLASSPATH_PREFIX)) { String resource = StringUtils.substringAfter(location, CLASSPATH_PREFIX); InputStream propertiesInputStream = getClass().getResourceAsStream(resource); if (propertiesInputStream == null) { log.debug("Configuration file not found with classpath [{}]", resource); //$NON-NLS-1$ return false; }/* w w w . j a v a2 s. c o m*/ try { SystemProperty.getProperties().load(propertiesInputStream); log.info("Loading configuration at {}", location);//$NON-NLS-1$ } catch (Exception e) { log.error(e.getMessage(), e); return false; } finally { IOUtils.closeQuietly(propertiesInputStream); } return true; } else { return super.loadPropertiesFile(rootPath, location); } }
From source file:com.streamsets.pipeline.lib.parser.log.CEFParser.java
@Override public Field getExtFormatVersion(String val) { int cefVersion = Integer.parseInt(StringUtils.substringAfter(val, ":")); return Field.create(cefVersion); }