List of usage examples for org.apache.commons.lang3 StringUtils split
public static String[] split(final String str, final String separatorChars)
Splits the provided text into an array, separators specified.
From source file:de.jcup.egradle.core.util.LinkToTypeConverter.java
private LinkData handleMethod(LinkData data, String methodOrPropertyPart) { String[] methodPartArray = StringUtils.split(methodOrPropertyPart, "()"); if (methodPartArray == null || methodPartArray.length == 0) { return data; }// w w w.j a v a 2 s . c o m String methodName = methodPartArray[0]; if (methodName == null) { return data; } data.subName = methodName; return handleMethodParameters(data, methodPartArray); }
From source file:com.monarchapis.driver.servlet.ApiRequest.java
/** * Returns the true client IP address. If the request went through a reverse * proxy, then the X-Forwarded-For header is used to determine the client IP * address. Otherwise, the remote address of the request is used. * /*from w w w. j a v a 2s. c o m*/ * @return The IP address as a string. */ public String getIpAddress() { String ipAddress = StringUtils.trimToNull(getHeader("X-Forwarded-For")); // If there is an X-Forwarded-For header, pull the first IP in the comma // separated list. return (ipAddress != null) ? StringUtils.split(ipAddress, ',')[0].trim() : getRemoteAddr(); }
From source file:com.nesscomputing.httpserver.log.file.FileRequestLog.java
@Override public void log(final Request request, final Response response) { final String requestUri = request.getRequestURI(); for (String blackListEntry : blackList) { if (StringUtils.startsWith(requestUri, blackListEntry)) { return; }/*from w ww . ja va 2 s.c o m*/ } final PrintWriter requestLogWriter = requestLogWriterHolder.get(); if (requestLogWriter != null) { synchronized (this) { for (Iterator<String> it = logFields.iterator(); it.hasNext();) { // Parse out fields that have parameters e.g. header:X-Trumpet-Track, and print String[] chunks = StringUtils.split(it.next(), ":"); final LogField field = knownFields.get(chunks[0]); if (chunks.length == 1) { requestLogWriter.print(ObjectUtils.toString(field.log(request, response, null))); } else if (chunks.length == 2) { requestLogWriter.print(ObjectUtils.toString(field.log(request, response, chunks[1]))); } if (it.hasNext()) { requestLogWriter.print("\t"); } } requestLogWriter.println(); } } }
From source file:net.ontopia.topicmaps.db2tm.SynchronizationServlet.java
@Override public void init(ServletConfig config) throws ServletException { super.init(config); log.info("Initializing synchronization servlet."); try {//from w w w . j ava2 s . co m // no default starttime Date time = null; long delay = 180 * 1000; String timeval = config.getInitParameter("start-time"); if (timeval != null) { Date d = df.parse(timeval); Calendar c0 = Calendar.getInstance(); Calendar c = Calendar.getInstance(); c.set(Calendar.HOUR_OF_DAY, 1); c.set(Calendar.MINUTE, 0); c.add(Calendar.MILLISECOND, (int) d.getTime()); if (c.before(c0)) c.add(Calendar.HOUR_OF_DAY, 24); time = c.getTime(); log.info("Setting synchronization start time to {} ms.", time); } else { // default delay is 180 sec. delay = getLongProperty(config, "delay", delay); log.info("Setting synchronization delay to {} ms.", delay); } // default interval is 24 hours. long interval = getLongProperty(config, "interval", 1000 * 60 * 60 * 24); log.info("Setting synchronization interval to {} ms.", interval); // load relation mapping file String mapping = config.getInitParameter("mapping"); if (mapping == null) throw new OntopiaRuntimeException("Servlet init-param 'mapping' must be specified."); // get relation names (comma separated) Collection<String> relnames = null; String relations = config.getInitParameter("relations"); if (relations != null) relnames = Arrays.asList(StringUtils.split(relations, ",")); // get hold of the topic map String tmid = config.getInitParameter("topicmap"); if (tmid == null) throw new OntopiaRuntimeException("Servlet init-param 'topicmap' must be specified."); TopicMapRepositoryIF rep = NavigatorUtils.getTopicMapRepository(config.getServletContext()); TopicMapReferenceIF ref = rep.getReferenceByKey(tmid); // make sure delay is at least 10 seconds to make sure that it doesn't // start too early if (time == null) task = new SynchronizationTask(config.getServletName(), (delay < 10000 ? 10000 : delay), interval); else task = new SynchronizationTask(config.getServletName(), time, interval); task.setRelationMappingFile(mapping); task.setRelationNames(relnames); task.setTopicMapReference(ref); task.setBaseLocator(null); } catch (Exception e) { throw new ServletException(e); } }
From source file:com.github.rvesse.airline.io.printers.UsagePrinter.java
public UsagePrinter append(String value, boolean avoidNewlines) { if (value == null) return this; if (avoidNewlines) { return appendWords(arrayToList(value.split("\\s+")), avoidNewlines); } else {/* w w w . ja v a 2s. c o m*/ return appendLines(arrayToList(StringUtils.split(value, '\n')), avoidNewlines); } }
From source file:com.adobe.acs.samples.workflow.impl.SampleCQWorkflowProcess.java
/** * The method called by the AEM Workflow Engine to perform Workflow work. * * @param workItem the work item representing the resource moving through the Workflow * @param workflowSession the workflow session * @param args arguments for this Workflow Process defined on the Workflow Model (PROCESS_ARGS, argSingle, argMulti) * @throws WorkflowException when the Workflow Process step cannot complete. This will cause the WF to retry. *///from w ww . j a va 2 s. com @Override public final void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap args) throws WorkflowException { /* Get the Workflow Payload */ // Get the Workflow data (the data that is being passed through for this work item) final WorkflowData workflowData = workItem.getWorkflowData(); final String type = workflowData.getPayloadType(); // Check if the payload is a path in the JCR; The other (less common) type is JCR_UUID if (!StringUtils.equals(type, "JCR_PATH")) { return; } // Get the path to the JCR resource from the payload final String path = workflowData.getPayload().toString(); /* Get Workflow Process Arguments */ // These args are specified on the Workflow Model using this WF Process. /* Process Args */ // These are free-form textfields; the values of these may need to be parsed based on // expected in put formats String processArgs = args.get("PROCESS_ARGS", "default value"); String[] proccesArgsVals = StringUtils.split(processArgs, ","); /* Single and MultiValue args */ // Some WF Process steps support Single and MultiValue args; these are can access via named properties // Custom WF inputs stored under ./metaData/argSingle and ./metadata/argMulti String singleValue = args.get("argSingle", "not set"); String[] multiValue = args.get("argMulti", new String[] { "not set" }); log.debug("Single Value: {}", singleValue); log.debug("Multi Value: {}", Arrays.toString(multiValue)); /* Get data set in prior Workflow Steps */ String previouslySetData = this.getPersistedData(workItem, "set-in-previous-workflow-step", String.class); /* Do work on the Payload; Remember to use Sling APIs as much as possible */ ResourceResolver resourceResolver = null; try { // Get the ResourceResolver from workflow session resourceResolver = getResourceResolver(workflowSession.getSession()); // Get the resource the payload points to; Keep in mind the payload can be any resource including // a AEM WF Package which must be processes specially. Resource resource = resourceResolver.getResource(path); // Do work .... // Save data for use in a subsequent Workflow step persistData(workItem, workflowSession, "set-for-next-workflow-step", "whatever data you want"); } catch (Exception e) { // If an error occurs that prevents the Workflow from completing/continuing - Throw a WorkflowException // and the WF engine will retry the Workflow later (based on the AEM Workflow Engine configuration). log.error("Unable to complete processing the Workflow Process step", e); throw new WorkflowException("Unable to complete processing the Workflow Process step", e); } }
From source file:com.jdom.get.stuff.done.presenter.EditTaskPresenter.java
public void saveTask() { if (!validate()) { return;//from ww w . ja va 2s . c o m } String newName = view.getTaskName(); String newDescription = view.getDescription(); boolean completed = view.getCompleted(); List<String> newDependencies = getSelectedDependencies(); String tagsLine = view.getTags().trim(); Date dueDate = parseDueDate(view.getDueDate()); List<String> tags = (StringUtils.isEmpty(tagsLine)) ? Collections.<String>emptyList() : Arrays.asList(StringUtils.split(tagsLine, ' ')); model.saveTask(newName, newDescription, dueDate, completed, view.getTaskList(), newDependencies, new HashSet<String>(tags)); view.close(); }
From source file:io.github.moosbusch.lumpi.util.LumpiUtil.java
public static Class<?> getPropertyType(Class<?> type, String propertyName) { String[] propertyTokens = StringUtils.split(propertyName, "."); Class<?> result = type; for (String propertyToken : propertyTokens) { PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(result); for (PropertyDescriptor descriptor : descriptors) { if (StringUtils.equalsIgnoreCase(propertyToken, descriptor.getName())) { result = descriptor.getPropertyType(); break; } else { result = null;//from w w w .ja va2 s . c o m } } } return result; }
From source file:com.norconex.importer.handler.tagger.impl.DeleteTagger.java
@Override protected void loadHandlerFromXML(XMLConfiguration xml) throws IOException { String fieldsStr = xml.getString("[@fields]", StringUtils.join(fieldsToRemove, ",")); if (StringUtils.isNotBlank(fieldsStr)) { LOG.warn("Configuring fields to delete via the \"fields\" " + "attribute is now deprecated. Now use the <fields> " + "element instead."); }//from w w w .j a v a2s. c om String fieldsElement = xml.getString("fields", StringUtils.join(fieldsToRemove, ",")); if (StringUtils.isNotBlank(fieldsElement)) { fieldsStr = fieldsElement; } String[] configFields = StringUtils.split(fieldsStr, ","); for (String field : configFields) { addField(field.trim()); } setFieldsRegex(xml.getString("fieldsRegex", fieldsRegex)); }
From source file:co.runrightfast.vertx.orientdb.OrientDBPoolConfig.java
/** * * @return/*from ww w. j a v a 2s. c o m*/ */ public String getDatabaseNameFromDatabaseUrl() { final String url = StringUtils.split(databaseUrl, ':')[1]; final int startIndex = url.lastIndexOf('/') + 1; return url.substring(startIndex); }