List of usage examples for org.apache.commons.lang StringUtils split
public static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified.
From source file:com.xwiki.authentication.ntlm.NTLMConfig.java
public Map<String, String> getMapParam(String name, Map<String, String> def, XWikiContext context) { Map<String, String> mappings = new HashMap<String, String>(); String str = getParam(name, null, context); if (!StringUtils.isEmpty(str)) { String[] fields = StringUtils.split(str, '|'); for (int i = 0; i < fields.length; i++) { String[] field = StringUtils.split(fields[i], '='); if (2 == field.length) { String key = field[0]; String value = field[1]; mappings.put(key, value); } else { LOG.error("Error parsing " + name + " attribute in xwiki.cfg: " + fields[i]); }// w w w. j a v a 2s. co m } } return mappings; }
From source file:com.intellij.plugins.haxe.model.HaxeSourceRootModel.java
@Nullable public PsiDirectory access(String packagePath) { if (this == DUMMY) return null; if ((packagePath == null) || packagePath.isEmpty()) return directory; PsiDirectory current = directory;/* www . j av a 2 s. co m*/ for (String part : StringUtils.split(packagePath, '.')) { if (current == null) break; current = current.findSubdirectory(part); } return current; }
From source file:com.adobe.acs.commons.images.transformers.impl.CropImageTransformerImpl.java
@Override public final Layer transform(final Layer layer, final ValueMap properties) { if (properties == null || properties.isEmpty()) { log.warn("Transform [ {} ] requires parameters.", TYPE); return layer; }/*from w w w . j a v a 2 s . c o m*/ log.debug("Transforming with [ {} ]", TYPE); final boolean smartBounding = properties.get(KEY_SMART_BOUNDING, true); final String[] bounds = StringUtils.split(properties.get(KEY_BOUNDS, ""), ","); if (bounds.length == NUM_BOUNDS_PARAMS) { int x = parseLength(bounds[PARAM_INDEX_X], layer.getWidth()); int y = parseLength(bounds[PARAM_INDEX_Y], layer.getHeight()); int width = parseLength(bounds[PARAM_INDEX_WIDTH], layer.getWidth()); int height = parseLength(bounds[PARAM_INDEX_HEIGHT], layer.getHeight()); Rectangle rectangle = new Rectangle(); if (smartBounding) { rectangle = this.getSmartBounds(x, y, width, height, layer.getWidth(), layer.getHeight()); } else { rectangle.setBounds(x, y, width, height); } layer.crop(rectangle); if (smartBounding && layer.getWidth() != width || layer.getHeight() != height) { log.debug("SmartBounding resulted in an image of an incorrect size (based on crop params). " + "resizing to: [ width: {}, height: {} ]", width, height); layer.resize(width, height); } } return layer; }
From source file:net.erdfelt.android.sdkfido.local.LocalAndroidPlatforms.java
/** * Attempt to find the local java sdk using the most common environment variables. * /*from w w w.j av a 2 s.c o m*/ * @return the local android java sdk directory * @throws IOException * if unable to load the default local java sdk */ public static File findLocalJavaSdk() throws IOException { StringBuilder err = new StringBuilder(); err.append("Unable to find the Local Android Java SDK Folder."); // Check Environment Variables First String envKeys[] = { "ANDROID_HOME", "ANDROID_SDK_ROOT" }; for (String envKey : envKeys) { File sdkHome = getEnvironmentVariableDir(err, envKey); if (sdkHome == null) { continue; // skip, not found on that key } LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(sdkHome); if (platforms.valid()) { return sdkHome; } } // Check Path for possible android.exe (or similar) List<String> searchBins = new ArrayList<String>(); if (SystemUtils.IS_OS_WINDOWS) { searchBins.add("adb.exe"); searchBins.add("emulator.exe"); searchBins.add("android.exe"); } else { searchBins.add("adb"); searchBins.add("emulator"); searchBins.add("android"); } String pathParts[] = StringUtils.split(System.getenv("PATH"), File.pathSeparatorChar); for (String searchBin : searchBins) { err.append("\nSearched PATH for ").append(searchBin); for (String pathPart : pathParts) { File pathDir = new File(pathPart); LOG.fine("Searching Path: " + pathDir); File bin = new File(pathDir, searchBin); if (bin.exists() && bin.isFile() && bin.canExecute()) { File homeDir = bin.getParentFile().getParentFile(); LOG.fine("Possible Home Dir: " + homeDir); LocalAndroidPlatforms platforms = new LocalAndroidPlatforms(homeDir); if (platforms.valid) { return homeDir; } } } err.append(", not found."); } throw new FileNotFoundException(err.toString()); }
From source file:com.hangum.tadpole.mongodb.core.test.ReplicaSetConnnection.java
/** * mongo db .//w w w .ja v a 2 s . c om * * @return */ public Mongo connection(String uri, int port) throws Exception { List<ServerAddress> listServerList = new ArrayList<ServerAddress>(); listServerList.add(new ServerAddress(serverurl, port)); String[] urls = StringUtils.split(SERVER_URL, ","); for (String ipPort : urls) { String[] strIpPort = StringUtils.split(ipPort, ":"); listServerList.add(new ServerAddress(strIpPort[0], Integer.parseInt(strIpPort[1]))); } Mongo m = null; // try { m = new Mongo(listServerList);//uri, port); // List<String> listDB = m.getDatabaseNames(); // for (String dbName : listDB) { // System.out.println(dbName); // } // authentication(optional) // boolean auth = db.authenticate(myUserName, myPassword); // } catch (UnknownHostException e) { // e.printStackTrace(); // } catch (MongoException e) { // e.printStackTrace(); // } return m; }
From source file:com.ultrapower.eoms.common.plugin.ecside.table.tool.PageSizeTool.java
public void rowsDisplayedDroplist() { int allRowsDisplayed = getTableModel().getLimit().getTotalRows(); int currentRowsDisplayed = getTableModel().getLimit().getCurrentRowsDisplayed(); int rowsDisplayed = getTableModel().getTable().getRowsDisplayed(); /*from ww w. ja va 2 s . c om*/ String pageSizeList=getTableModel().getTable().getPageSizeList(); String[] sizeList=null; if (pageSizeList != null) { sizeList=StringUtils.split(pageSizeList, ","); } getHtmlBuilder().select().name(getTableModel().getTableHandler().prefixWithTableId() + TableConstants.ROWS_DISPLAYED); String formId=getTableModel().getTable().getTableId(); StringBuffer onchange = new StringBuffer(); onchange.append(ECSideConstants.UTIL_FUNCTION_NAME+".changeRowsDisplayed("); onchange.append("'"+formId+"',this);"); getHtmlBuilder().onchange(onchange.toString()); getHtmlBuilder().close(); getHtmlBuilder().newline(); getHtmlBuilder().tabs(4); int i=0; int maxSize=Integer.MAX_VALUE; boolean hasDefaultSize=false; if (sizeList!=null) { for (i=0;i<sizeList.length;i++){ int size=0; String text; if (sizeList[i].trim().toLowerCase().startsWith("max:")){ try{ if (maxSize==Integer.MAX_VALUE ){ maxSize=new Integer(sizeList[i].substring(4)).intValue(); } }catch (Exception e) { maxSize=Integer.MAX_VALUE; } continue; }else if (allRowsDisplayed<maxSize && "all".equalsIgnoreCase(sizeList[i].trim())){ size=allRowsDisplayed; text=getTableModel().getMessages().getMessage(PreferencesConstants.TOOLBAR_PAGE_ALL); }else{ try{ size=Integer.parseInt(sizeList[i].trim()); text=String.valueOf(size); }catch(Exception ei){ continue; } } if (!hasDefaultSize) { hasDefaultSize=size==currentRowsDisplayed; } if (size<=maxSize){ getHtmlBuilder().option().value(String.valueOf(size)); if (currentRowsDisplayed == size) { getHtmlBuilder().selected(); } getHtmlBuilder().close(); getHtmlBuilder().append(text); getHtmlBuilder().optionEnd(); } } } if (i==0 || !hasDefaultSize){ // default rows if (rowsDisplayed>allRowsDisplayed){ rowsDisplayed=allRowsDisplayed; } getHtmlBuilder().option().value(String.valueOf(rowsDisplayed)); if (currentRowsDisplayed == rowsDisplayed) { getHtmlBuilder().selected(); } getHtmlBuilder().close(); getHtmlBuilder().append(String.valueOf(rowsDisplayed)); getHtmlBuilder().optionEnd(); } getHtmlBuilder().newline(); getHtmlBuilder().tabs(4); getHtmlBuilder().selectEnd(); }
From source file:co.marcin.novaguilds.command.admin.config.CommandAdminConfigGet.java
@Override public void execute(CommandSender sender, String[] args) throws Exception { if (args.length == 0) { command.getUsageMessage().send(sender); return;/*from w w w . ja v a2s. c o m*/ } String path = args[0]; String value = ""; Map<VarKey, String> vars = new HashMap<>(); FileConfiguration config = plugin.getConfigManager().getConfig(); if (!config.contains(path)) { Message.CHAT_INVALIDPARAM.send(sender); return; } if (config.isConfigurationSection(path)) { int depth = 1; String lastSection = null; vars.put(VarKey.DEPTH, ""); vars.put(VarKey.KEY, path); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.vars(vars).send(sender); for (String string : config.getConfigurationSection(path).getKeys(true)) { String[] prefixSplit = StringUtils.split(string, "."); String prefix = StringUtils.contains(string, ".") ? StringUtils.removeEnd(string, "." + prefixSplit[prefixSplit.length - 1]) : string; if (lastSection != null && !prefix.startsWith(lastSection)) { depth--; lastSection = null; } String space = ""; for (int i = 0; i < depth; i++) { space += " "; } vars.put(VarKey.DEPTH, space); if (config.isConfigurationSection(path + "." + string)) { depth++; lastSection = string; vars.put(VarKey.KEY, prefixSplit[prefixSplit.length - 1]); Message.CHAT_ADMIN_CONFIG_GET_LIST_SECTION.vars(vars).send(sender); } else { //key vars.put(VarKey.KEY, StringUtils.removeStart(string, prefix + ".")); Message.CHAT_ADMIN_CONFIG_GET_LIST_KEY.vars(vars).send(sender); } } } else { if (config.isList(path)) { value = StringUtils.join(config.getStringList(path), " "); } else { value = config.getString(path); } } vars.put(VarKey.KEY, path); vars.put(VarKey.VALUE, value); if (!value.isEmpty()) { Message.CHAT_ADMIN_CONFIG_GET_SINGLE.vars(vars).send(sender); } }
From source file:io.dropwizard.hystrix.path.tracker.filters.impl.PathTrackerFilter.java
private String identifyPath(String requestUri) { String[] decomposedApi = StringUtils.split(requestUri, "/"); return decomposedApi[decomposedApi.length - 1]; }
From source file:info.magnolia.voting.voters.ExtensionVoter.java
public void setAllow(String allow) { this.allow = StringUtils.split(allow, ','); }
From source file:com.github.pmerienne.trident.state.cassandra.CassandraConfig.java
private void createDao() { String[] contactPoints = StringUtils.split(this.getContactPoints(), ","); Cluster cluster;//from w w w . ja v a 2 s. co m String username = this.getUsername(); String password = this.getPassword(); if (StringUtils.isNotBlank(username) && StringUtils.isNotBlank(password)) { cluster = Cluster.builder().addContactPoints(contactPoints).withPort(this.getPort()) .withCredentials(username, password).build(); } else { cluster = Cluster.builder().addContactPoints(contactPoints).withPort(this.getPort()).build(); } Session session = cluster.connect(this.getKeyspace()); dao = new CassandraDao(session); }