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.enonic.cms.core.portal.datasource.handler.context.GetHttpContextHandler.java
private Element createHttpElement(final HttpServletRequest request) { final Element httpEl = new Element("http"); if (request != null) { httpEl.setAttribute("action", request.getMethod()); httpEl.addContent(new Element("user-agent").setText(request.getHeader("user-agent"))); httpEl.addContent(new Element("client-ip").setText(request.getRemoteAddr())); httpEl.addContent(new Element("referer").setText(request.getHeader("referer"))); // accept final Element acceptElem = new Element("accept"); httpEl.addContent(acceptElem);//from w ww. j a v a 2 s .c o m // language final String acceptLanguage = request.getHeader("accept-language"); if (acceptLanguage != null) { final String[] languages = StringUtils.split(acceptLanguage, ","); for (String languageStr : languages) { if (languageStr.indexOf(";") > 0) { final Element langElem = new Element("language"); langElem.setText(languageStr.substring(0, languageStr.indexOf(";"))); langElem.setAttribute("q", languageStr.substring(languageStr.indexOf(";") + 3)); acceptElem.addContent(langElem); } else { acceptElem.addContent(new Element("language").setText(languageStr)); } } } } return httpEl; }
From source file:com.google.code.fqueue.util.TestJVMMonitor.java
public void testMonitor() { String items = "fileDescriptor,load,allThreadsCount,peakThreadCount,daemonThreadCount,totalStartedThreadCount,deadLockCount,heapMemory,noHeapMemory,memory,classCount,GCTime,memoryPoolCollectionUsage,memoryPoolUsage,memoryPoolPeakUsage"; // String items = "memoryPoolPeakUsage"; long start = System.currentTimeMillis(); if (items != null) { String[] itemList = StringUtils.split(items, ","); for (int i = 0, len = itemList.length; i < len; i++) { String data = JVMMonitor.getMonitorStats(itemList[i]); System.out.println(data); }/*from w w w . jav a 2 s .c o m*/ } System.out.println("?JVM?" + (System.currentTimeMillis() - start)); }
From source file:com.xx_dev.apn.proxy.utils.HostNamePortUtil.java
public static int getPort(HttpRequest httpRequest) { int originalPort = 80; if (httpRequest.getMethod().equals(HttpMethod.CONNECT)) { originalPort = 443;/*from w w w.ja v a2 s.c o m*/ } String originalHostHeader = httpRequest.headers().get(HttpHeaders.Names.HOST); if (StringUtils.isBlank(originalHostHeader) && httpRequest.getMethod().equals(HttpMethod.CONNECT)) { originalHostHeader = httpRequest.getUri(); } if (StringUtils.isNotBlank(originalHostHeader)) { if (StringUtils.split(originalHostHeader, ": ").length == 2) { originalPort = Integer.parseInt(StringUtils.split(originalHostHeader, ": ")[1]); } } else { String uriStr = httpRequest.getUri(); try { URI uri = URI.create(uriStr); if (uri.getPort() > 0) { originalPort = uri.getPort(); } } catch (IllegalArgumentException e) { logger.error(e.getMessage(), e); originalPort = -1; } } return originalPort; }
From source file:com.pureinfo.srm.config.workflow.function.ProductGuarder.java
protected boolean checkPass(ArkContent _content, IUser _user, Object[] _args) throws PureException { if (_args.length != 1) throw new PureException(PureException.INVALID_REQUEST, "args must have two arguments!"); IContentMgr mgr = ArkContentHelper.getContentMgrOf(Product.class); Product product = (Product) mgr.lookupById4Edit(_content.getId()); if ("null".equals(_args[0])) { WfProcess process = WorkflowHelper.getProductProcess(product.getProductForm(), product.getPublicationLevel()); return process != null ? true : false; }// w ww. j a va 2 s . c om String[] acts = StringUtils.split((String) _args[0], "|"); for (int i = 0; i < acts.length; i++) { if (WorkflowHelper.checkProductRole(product.getProductForm(), product.getPublicationLevel(), acts[i], ((SRMUser) _user).getRolesList())) return true; } return false; }
From source file:com.jaeksoft.searchlib.util.map.SourceField.java
public SourceField(String name, char separator) { names = StringUtils.split(name, separator); this.separator = separator; }
From source file:com.gzj.tulip.load.ResourceRef.java
public static ResourceRef toResourceRef(Resource folder) throws IOException { ResourceRef rr = new ResourceRef(folder, null, null); String[] modifiers = null;/*from ww w . j av a 2 s . c om*/ Resource rosePropertiesResource = rr.getInnerResource("META-INF/rose.properties"); if (rosePropertiesResource.exists()) { if (logger.isDebugEnabled()) { logger.debug("found rose.properties: " + rosePropertiesResource.getURI()); } InputStream in = rosePropertiesResource.getInputStream(); rr.properties.load(in); in.close(); String attrValue = rr.properties.getProperty("rose"); if (attrValue == null) { attrValue = rr.properties.getProperty("Rose"); } if (attrValue != null) { modifiers = StringUtils.split(attrValue, ", ;\n\r\t"); if (logger.isDebugEnabled()) { logger.debug("modifiers[by properties][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } } // if (modifiers == null) { if (!"jar".equals(rr.getProtocol())) { modifiers = new String[] { "**" }; if (logger.isDebugEnabled()) { logger.debug("modifiers[by default][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } else { JarFile jarFile = new JarFile(rr.getResource().getFile()); Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); String attrValue = attributes.getValue("rose"); if (attrValue == null) { attrValue = attributes.getValue("Rose"); } if (attrValue != null) { modifiers = StringUtils.split(attrValue, ", ;\n\r\t"); if (logger.isDebugEnabled()) { logger.debug("modifiers[by manifest.mf][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } } } } rr.setModifiers(modifiers); return rr; }
From source file:com.sinosoft.one.mvc.scanning.ResourceRef.java
public static ResourceRef toResourceRef(Resource folder) throws IOException { ResourceRef rr = new ResourceRef(folder, null, null); String[] modifiers = null;/*from w w w . j av a 2s . c om*/ Resource mvcPropertiesResource = rr.getInnerResource("META-INF/mvc.properties"); if (mvcPropertiesResource.exists()) { if (logger.isDebugEnabled()) { logger.debug("found mvc.properties: " + mvcPropertiesResource.getURI()); } InputStream in = mvcPropertiesResource.getInputStream(); rr.properties.load(in); in.close(); String attrValue = rr.properties.getProperty("mvc"); if (attrValue == null) { attrValue = rr.properties.getProperty("Mvc"); } if (attrValue != null) { modifiers = StringUtils.split(attrValue, ", ;\n\r\t"); if (logger.isDebugEnabled()) { logger.debug("modifiers[by properties][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } } // if (modifiers == null) { if (!"jar".equals(rr.getProtocol())) { modifiers = new String[] { "**" }; if (logger.isDebugEnabled()) { logger.debug("modifiers[by default][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } else { JarFile jarFile = new JarFile(rr.getResource().getFile()); Manifest manifest = jarFile.getManifest(); if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); String attrValue = attributes.getValue("mvc"); if (attrValue == null) { attrValue = attributes.getValue("Mvc"); } if (attrValue != null) { modifiers = StringUtils.split(attrValue, ", ;\n\r\t"); if (logger.isDebugEnabled()) { logger.debug("modifiers[by manifest.mf][" + rr.getResource().getURI() + "]=" + Arrays.toString(modifiers)); } } } } } rr.setModifiers(modifiers); return rr; }
From source file:fr.dutra.tools.maven.deptree.core.DotParser.java
private void parseFirstLine() { String str = StringUtils.substringBetween(this.lines.get(0), "\""); String[] tokens = StringUtils.split(str, ':'); if (tokens.length != 4) { throw new IllegalStateException( "Wrong number of tokens: " + tokens.length + " for first line (4 expected)"); }//w w w .j a v a 2 s .c o m final Node node = new Node(tokens[0], tokens[1], tokens[2], null, tokens[3], null, null, false); root = node; nodes.put(str, node); lineIndex++; }
From source file:com.mycompany.sonar.reference.FooLanguage.java
/** * {@inheritDoc}/*from w w w.jav a 2 s . c o m*/ */ @Override public String[] getFileSuffixes() { String[] suffixes = filterEmptyStrings(settings.getStringArray(ExamplePlugin.FILE_SUFFIXES_KEY)); if (suffixes.length == 0) { suffixes = StringUtils.split(ExamplePlugin.DEFAULT_FILE_SUFFIXES, ","); } return suffixes; }
From source file:com.cyclopsgroup.waterview.ui.action.ChangeLocale.java
/** * Overwrite or implement method execute() * * @see com.cyclopsgroup.waterview.Action#execute(com.cyclopsgroup.waterview.RuntimeData, com.cyclopsgroup.waterview.ActionContext) *//*from w ww. ja va 2 s . c o m*/ public void execute(RuntimeData data, ActionContext context) throws Exception { String localeName = data.getParameters().getString("locale_name"); if (StringUtils.isEmpty(localeName)) { data.getSessionContext().remove(RuntimeData.LOCALE_NAME); } else { String[] countryLanguage = StringUtils.split(localeName, '|'); Locale locale = new Locale(countryLanguage[1], countryLanguage[0]); data.getSessionContext().put(RuntimeData.LOCALE_NAME, locale); } }