List of usage examples for org.apache.commons.lang3 StringUtils trim
public static String trim(final String str)
Removes control characters (char <= 32) from both ends of this String, handling null by returning null .
The String is trimmed using String#trim() .
From source file:com.mirth.connect.client.ui.reference.ClassVisitor.java
private void addMethod(boolean constructor, String className, String name, String type, int modifiers, JavadocComment javadoc, List<Parameter> parameters) { String iconName = null;/*from ww w . j ava2s. c o m*/ if (ModifierSet.isPublic(modifiers)) { if (ModifierSet.isStatic(modifiers)) { iconName = IconFactory.PUBLIC_STATIC_FUNCTION_ICON; } else { iconName = IconFactory.PUBLIC_METHOD_ICON; } } else { // Don't add references for non-public methods return; } String comment = null; Map<String, String> parameterComments = new CaseInsensitiveMap(); String returnComment = constructor ? "A new " + name + " object." : null; String deprecatedComment = null; if (javadoc != null) { comment = StringUtils.trim(javadoc.getContent()); if (StringUtils.isNotBlank(comment)) { Matcher matcher = JAVADOC_ANNOTATION_PATTERN.matcher(comment); while (matcher.find() && matcher.groupCount() >= 2) { String key = matcher.group("key"); String value = convertComment(matcher.group("value")); if (key.equalsIgnoreCase("param")) { int index = value.indexOf(' '); if (index >= 0) { key = value.substring(0, index).trim(); value = value.substring(index).trim(); } else { key = value; value = ""; } parameterComments.put(key, value); } else if (key.equalsIgnoreCase("return")) { returnComment = value; } else if (key.equalsIgnoreCase("deprecated")) { deprecatedComment = value; } } comment = convertComment(comment); if (StringUtils.isNotBlank(deprecatedComment)) { comment = "<b>Deprecated.</b> <em>" + deprecatedComment + "</em><br/><br/>" + comment; } } } Parameters params = new Parameters(); if (CollectionUtils.isNotEmpty(parameters)) { for (Parameter parameter : parameters) { String parameterName = parameter.getId().getName(); params.add(parameterName, parameter.getType().toString(), parameterComments.get(parameterName)); } } Reference reference; if (constructor) { reference = new ConstructorReference(CodeTemplateContextSet.getGlobalContextSet(), null, name, name, comment, null, new CodeTemplateFunctionDefinition(name, params, type, returnComment)); } else { reference = new FunctionReference(CodeTemplateContextSet.getGlobalContextSet(), null, className, name, comment, null, new CodeTemplateFunctionDefinition(name, params, type, returnComment), inputTextList); } if (StringUtils.isNotBlank(deprecatedComment)) { reference.setDeprecated(true); } reference.setIconName(iconName); references.add(reference); }
From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java
/** * Registers a new {@link ScheduledReporter} * @param id// ww w .j a v a2s . co m * @param reporterInstance reporter instance (must have been started) * @throws RequiredInputMissingException */ public void addScheduledReporter(final String id, final ScheduledReporter reporterInstance) throws RequiredInputMissingException { //////////////////////////////////////////////////////////////// // input validation if (StringUtils.isBlank(id)) throw new RequiredInputMissingException("Missing required reporter identifier"); if (reporterInstance == null) throw new RequiredInputMissingException("Missing required reporter instance"); //////////////////////////////////////////////////////////////// this.scheduledReporters.put(StringUtils.lowerCase(StringUtils.trim(id)), reporterInstance); }
From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineManagerTest.java
/** * Test case for {@link MicroPipelineManager#executePipeline(MicroPipelineConfiguration)} being provided a * valid configuration which leads to a registered {@link MicroPipeline} instance *///from w ww. j a v a 2s. c o m @Test public void testExecutePipeline_withValidConfiguration() throws Exception { MicroPipelineConfiguration cfg = new MicroPipelineConfiguration(); cfg.setId("testExecutePipeline_withValidConfiguration"); MicroPipeline pipeline = Mockito.mock(MicroPipeline.class); Mockito.when(pipeline.getId()).thenReturn(cfg.getId()); MicroPipelineFactory factory = Mockito.mock(MicroPipelineFactory.class); Mockito.when(factory.instantiatePipeline(cfg, executorService)).thenReturn(pipeline); MicroPipelineManager manager = new MicroPipelineManager("id", factory, executorService); Assert.assertEquals("Values must be equal", StringUtils.lowerCase(StringUtils.trim(cfg.getId())), manager.executePipeline(cfg)); Assert.assertEquals("Values must be equal", 1, manager.getNumOfRegisteredPipelines()); Mockito.verify(factory).instantiatePipeline(cfg, executorService); }
From source file:com.sample.domain.entities.anagrafica.Cliente.java
@PrePersist @PreUpdate/*from w ww . ja v a 2 s . c om*/ public void normalize() { this.ragioneSociale = String.format("%s %s", StringUtils.trim(nome), StringUtils.trim(cognome)); if (this.utente != null) { this.utente.setUserId(userId); } if (this.utenteOtp != null && !this.utenteOtp.getSerialNumber().trim().isEmpty()) { this.utenteOtp.setUserId(userId); } if (this.infoMarketing != null) { this.infoMarketing.setUserId(userId); } if (this.mobileDevices != null && mobileDevices.size() > 0) { mobileDevices.forEach(e -> e.setUserId(getUserId())); } }
From source file:com.ottogroup.bi.spqr.metrics.MetricsHandler.java
/** * {@link ScheduledReporter#stop() Stops} the referenced {@link ScheduledReporter} and removes it from * map of managed scheduled reporters//from w w w. j a v a2 s.c om * @param id */ public void removeScheduledReporter(final String id) { String key = StringUtils.lowerCase(StringUtils.trim(id)); ScheduledReporter scheduledReporter = this.scheduledReporters.get(key); if (scheduledReporter != null) { scheduledReporter.stop(); this.scheduledReporters.remove(key); } }
From source file:com.ottogroup.bi.asap.pipeline.MicroPipelineManager.java
/** * Returns the referenced pipeline - used for testing purpose only ... at the moment ;-) * @param pipelineId// ww w . j a v a 2 s.c o m * @return */ protected MicroPipeline getPipeline(final String pipelineId) { return this.microPipelines.get(StringUtils.lowerCase(StringUtils.trim(pipelineId))); }
From source file:com.thinkbiganalytics.nifi.feedmgr.ConfigurationPropertyReplacer.java
/** * @param property the NifiProperty to replace * @param configProperties a Map of properties which will be looked to to match against the property key *///from w w w . j a va2s . c o m public static boolean resolveStaticConfigurationProperty(NifiProperty property, Map<String, Object> configProperties) { String value = property.getValue(); StringBuffer sb = null; if (configProperties != null && !configProperties.isEmpty()) { if (StringUtils.isNotBlank(value)) { Pattern variablePattern = Pattern.compile("\\$\\{(.*?)\\}"); Matcher matchVariablePattern = variablePattern.matcher(value); while (matchVariablePattern.find()) { if (sb == null) { sb = new StringBuffer(); } String group = matchVariablePattern.group(); int groupCount = matchVariablePattern.groupCount(); if (groupCount == 1) { String variable = matchVariablePattern.group(1); //lookup the variable //first look at configuration properties Object resolvedValue = configProperties.get(variable); if (resolvedValue != null) { matchVariablePattern.appendReplacement(sb, resolvedValue.toString()); } } } if (sb != null) { matchVariablePattern.appendTail(sb); } } } if (sb == null) { String updatedValue = resolveValue(property, configProperties); if (StringUtils.isNotBlank(updatedValue)) { sb = new StringBuffer(); sb.append(updatedValue); } } if (sb != null) { property.setValue(StringUtils.trim(sb.toString())); } return sb != null; }
From source file:com.ottogroup.bi.spqr.node.server.SPQRNodeServer.java
/** * Initializes the log4j framework by pointing it to the configuration file referenced by parameter * @param log4jConfigurationFile/* w ww . j a v a 2s .co m*/ */ protected void initializeLog4j(final String log4jConfigurationFile) { String log4jPropertiesFile = StringUtils.lowerCase(StringUtils.trim(log4jConfigurationFile)); if (StringUtils.isNoneBlank(log4jConfigurationFile)) { File log4jFile = new File(log4jPropertiesFile); if (log4jFile.isFile()) { try { PropertyConfigurator.configure(new FileInputStream(log4jFile)); } catch (FileNotFoundException e) { System.out.println("No log4j configuration found at '" + log4jConfigurationFile + "'"); } } else { System.out.println("No log4j configuration found at '" + log4jConfigurationFile + "'"); } } else { System.out.println("No log4j configuration file provided"); } }
From source file:com.norconex.commons.lang.file.ContentType.java
/** * Whether the given string matches this content type. * @param contentType the content type/*from w ww . ja va2 s . c om*/ * @return {@code true} if the given string matches this content type */ public boolean matches(String contentType) { return this.contentType.equals(StringUtils.trim(contentType)); }
From source file:com.mirth.connect.client.ui.ChannelTagDialog.java
private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed String tag = StringUtils.trim((String) tagComboBox.getSelectedItem()); if (tag == null || tag.isEmpty()) { parent.alertError(parent, "Please enter a tag"); } else {/*from w w w.j av a 2s . com*/ DefaultTableModel model = (DefaultTableModel) tagTable.getModel(); int rowCount = model.getRowCount(); for (int i = 0; i < rowCount; i++) { if (model.getValueAt(i, 0).equals(tag)) { parent.alertError(parent, "\"" + tag + "\" is already assigned to this channel"); return; } } model.addRow(new Object[] { tag }); tagTable.setRowSelectionInterval(rowCount, rowCount); dispose(); } }