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.navercorp.pinpoint.web.service.SpanServiceImpl.java
private void transitionSqlId(final List<Align> spans) { this.transitionAnnotation(spans, new AnnotationReplacementCallback() { @Override/*from www. jav a 2 s . co m*/ public void replacement(Align align, List<AnnotationBo> annotationBoList) { AnnotationBo sqlIdAnnotation = findAnnotation(annotationBoList, AnnotationKey.SQL_ID.getCode()); if (sqlIdAnnotation == null) { return; } if (metaDataFilter != null && metaDataFilter.filter(align, MetaData.SQL)) { AnnotationBo annotationBo = metaDataFilter.createAnnotationBo(align, MetaData.SQL); annotationBoList.add(annotationBo); return; } // value of sqlId's annotation contains multiple values. final IntStringStringValue sqlValue = (IntStringStringValue) sqlIdAnnotation.getValue(); final int sqlId = sqlValue.getIntValue(); final String sqlParam = sqlValue.getStringValue1(); final List<SqlMetaDataBo> sqlMetaDataList = sqlMetaDataDao.getSqlMetaData(align.getAgentId(), align.getAgentStartTime(), sqlId); final int size = sqlMetaDataList.size(); if (size == 0) { String errorMessage = "SQL-ID not found sqlId:" + sqlId; AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), errorMessage); annotationBoList.add(api); } else if (size == 1) { final SqlMetaDataBo sqlMetaDataBo = sqlMetaDataList.get(0); if (StringUtils.isEmpty(sqlParam)) { AnnotationBo sqlMeta = new AnnotationBo(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql()); annotationBoList.add(sqlMeta); // AnnotationBo checkFail = checkIdentifier(spanAlign, sqlMetaDataBo); // if (checkFail != null) { // // fail // annotationBoList.add(checkFail); // return; // } AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(sqlMetaDataBo.getSql())); annotationBoList.add(sql); } else { logger.debug("sqlMetaDataBo:{}", sqlMetaDataBo); final String outputParams = sqlParam; List<String> parsedOutputParams = outputParameterParser.parseOutputParameter(outputParams); logger.debug("outputPrams:{}, parsedOutputPrams:{}", outputParams, parsedOutputParams); String originalSql = sqlParser.combineOutputParams(sqlMetaDataBo.getSql(), parsedOutputParams); logger.debug("outputPrams{}, originalSql:{}", outputParams, originalSql); AnnotationBo sqlMeta = new AnnotationBo(AnnotationKey.SQL_METADATA.getCode(), sqlMetaDataBo.getSql()); annotationBoList.add(sqlMeta); AnnotationBo sql = new AnnotationBo(AnnotationKey.SQL.getCode(), StringUtils.trim(originalSql)); annotationBoList.add(sql); } } else { // TODO need improvement String collisionSqlIdCodeMessage = collisionSqlIdCodeMessage(sqlId, sqlMetaDataList); AnnotationBo api = new AnnotationBo(AnnotationKey.SQL.getCode(), collisionSqlIdCodeMessage); annotationBoList.add(api); } // add if bindValue exists final String bindValue = sqlValue.getStringValue2(); if (StringUtils.isNotEmpty(bindValue)) { AnnotationBo bindValueAnnotation = new AnnotationBo(AnnotationKey.SQL_BINDVALUE.getCode(), bindValue); annotationBoList.add(bindValueAnnotation); } } }); }
From source file:com.ottogroup.bi.asap.resman.node.ProcessingNodeManager.java
/** * Instantiates a pipeline on remote processing nodes * @param deploymentProfile provides information on what and how to distribute the pipeline within the cluster * @return// w ww . ja v a 2 s . c om * @throws RequiredInputMissingException */ public PipelineDeploymentProfile instantiatePipeline(final PipelineDeploymentProfile deploymentProfile) throws RequiredInputMissingException { /////////////////////////////////////////////////////// // validate input if (deploymentProfile == null) throw new RequiredInputMissingException("Missing required deployment profile"); // /////////////////////////////////////////////////////// for (final ProcessingNode pn : this.processingNodes.values()) { try { pn.instantiatePipeline(deploymentProfile.getConfiguration()); deploymentProfile.addProcessingNode(StringUtils.lowerCase(StringUtils.trim(pn.getId()))); } catch (RemoteClientConnectionFailedException | IOException e) { logger.error("Failed to deploy pipeline '" + deploymentProfile.getId() + "' on processing node '" + pn.getId() + "'. Error: " + e.getMessage()); } } return deploymentProfile; }
From source file:com.anrisoftware.globalpom.format.degree.DegreeSexagesimalFormat.java
private Direction parseDirectionSave(String string) { string = StringUtils.trim(string); return isEmpty(string) ? N : Direction.valueOf(string.toUpperCase()); }
From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineManager.java
/** * Returns true if a {@link MicroPipeline} for the given identifier exists otherwise * it returns false// ww w . j a v a2s.c o m * @param pipelineId * @return */ public boolean hasPipeline(final String pipelineId) { return this.pipelines.containsKey(StringUtils.lowerCase(StringUtils.trim(pipelineId))); }
From source file:com.sonicle.webtop.core.util.ZPushManager.java
private List<LastsyncRecord> parseLastsyncOutput(List<String> lines) { ArrayList<LastsyncRecord> items = new ArrayList<>(); int lineNo = 0, dataLine = -1; for (String line : lines) { lineNo++;//from w w w. j av a 2 s . c om if (StringUtils.containsIgnoreCase(line, "Device id") && StringUtils.containsIgnoreCase(line, "Synchronized user") && StringUtils.containsIgnoreCase(line, "Last sync time")) { dataLine = lineNo + 2; } if ((dataLine != -1) && (lineNo >= dataLine) && !StringUtils.isBlank(StringUtils.trim(line))) { String[] tokens = StringUtils.split(line, " ", 3); String device = StringUtils.trim(tokens[0]); String user = StringUtils.trim(tokens[1]); String lastSync = StringUtils.trim(StringUtils.left(tokens[2], 16)); items.add(new LastsyncRecord(device, user, "never".equalsIgnoreCase(lastSync) ? null : lastSync)); } } return items; }
From source file:com.ottogroup.bi.spqr.pipeline.MicroPipelineValidator.java
/** * Validates a single {@link MicroPipelineComponentConfiguration} * @param componentCfg// ww w .jav a 2 s . c o m * @param queueIdentifiers previously extracted queue identifiers * @param componentIdentifiers previously extracted component identifiers * @return */ protected MicroPipelineValidationResult validateComponent( final MicroPipelineComponentConfiguration componentCfg, final Set<String> queueIdentifiers, final Set<String> componentIdentifiers) { /////////////////////////////////////////////////////////////////////////////////// // component and its id, name, version and type for neither being null empty if (componentCfg == null) return MicroPipelineValidationResult.MISSING_COMPONENT_CONFIGURATION; if (StringUtils.isBlank(componentCfg.getId())) return MicroPipelineValidationResult.MISSING_COMPONENT_ID; if (StringUtils.isBlank(componentCfg.getName())) return MicroPipelineValidationResult.MISSING_COMPONENT_NAME; if (StringUtils.isBlank(componentCfg.getVersion())) return MicroPipelineValidationResult.MISSING_COMPONENT_VERSION; if (componentCfg.getType() == null) return MicroPipelineValidationResult.MISSING_COMPONENT_TYPE; // /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // convert id to trimmed lower-case representation and check if it is unique String tempId = StringUtils.lowerCase(StringUtils.trim(componentCfg.getId())); if (componentIdentifiers.contains(tempId)) return MicroPipelineValidationResult.NON_UNIQUE_COMPONENT_ID; // /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// // validate queue settings for specific component types if (componentCfg.getType() == MicroPipelineComponentType.SOURCE) { // source component must reference a destination queue only - source queue references are not permitted if (StringUtils.isNotBlank(componentCfg.getFromQueue())) return MicroPipelineValidationResult.NOT_PERMITTED_SOURCE_QUEUE_REF; // the identifier of the destination queue must neither be null nor empty if (StringUtils.isBlank(componentCfg.getToQueue())) return MicroPipelineValidationResult.MISSING_DESTINATION_QUEUE; // the identifier of the destination queue must reference an existing queue String destinationQueueId = StringUtils.lowerCase(StringUtils.trim(componentCfg.getToQueue())); if (!queueIdentifiers.contains(destinationQueueId)) return MicroPipelineValidationResult.UNKNOWN_DESTINATION_QUEUE; } else if (componentCfg.getType() == MicroPipelineComponentType.DIRECT_RESPONSE_OPERATOR || componentCfg.getType() == MicroPipelineComponentType.DELAYED_RESPONSE_OPERATOR) { // operators must reference source and destination queues alike - both variable values must not be empty if (StringUtils.isBlank(componentCfg.getFromQueue())) return MicroPipelineValidationResult.MISSING_SOURCE_QUEUE; if (StringUtils.isBlank(componentCfg.getToQueue())) return MicroPipelineValidationResult.MISSING_DESTINATION_QUEUE; // the identifier of the source queue must reference an existing queue String sourceQueueId = StringUtils.lowerCase(StringUtils.trim(componentCfg.getFromQueue())); if (!queueIdentifiers.contains(sourceQueueId)) return MicroPipelineValidationResult.UNKNOWN_SOURCE_QUEUE; // the identifier of the destination queue must reference an existing queue String destinationQueueId = StringUtils.lowerCase(StringUtils.trim(componentCfg.getToQueue())); if (!queueIdentifiers.contains(destinationQueueId)) return MicroPipelineValidationResult.UNKNOWN_DESTINATION_QUEUE; } else if (componentCfg.getType() == MicroPipelineComponentType.EMITTER) { // emitter component must reference a source queue only - destination queue references are not permitted if (StringUtils.isNotBlank(componentCfg.getToQueue())) return MicroPipelineValidationResult.NOT_PERMITTED_DESTINATION_QUEUE_REF; // the identifier of the source queue must neither be null nor empty if (StringUtils.isBlank(componentCfg.getFromQueue())) return MicroPipelineValidationResult.MISSING_SOURCE_QUEUE; // the identifier of the destination queue must reference an existing queue String destinationQueueId = StringUtils.lowerCase(StringUtils.trim(componentCfg.getFromQueue())); if (!queueIdentifiers.contains(destinationQueueId)) return MicroPipelineValidationResult.UNKNOWN_SOURCE_QUEUE; } // return true if no error could be derived from component configuration return MicroPipelineValidationResult.OK; }
From source file:com.ottogroup.bi.streaming.runtime.StreamingAppRuntime.java
/** * Validates the {@link CommandLine} and prints out possible errors to the given {@link OutputStream} * @param cl/* w w w .j a va2s . co m*/ * @param outputStream * @return */ protected boolean validateCommandLine(final CommandLine cl, final OutputStream outputStream) throws IOException { if (outputStream == null) throw new IOException("Missing required output stream\n"); if (cl == null) { outputStream.write(MSG_EMPTY_COMMAND_LINE); return false; } if (!cl.hasOption(CLI_CONFIG_FILE)) { outputStream.write(MSG_MISSING_CFG_FILE_REF); return false; } final String cfgFileRef = cl.getOptionValue(CLI_CONFIG_FILE); if (StringUtils.isBlank(cfgFileRef)) { outputStream.write(MSG_MISSING_CFG_FILE_REF); return false; } final File file = new File(StringUtils.trim(cfgFileRef)); if (!file.isFile()) { outputStream.write(MSG_REF_CFG_FILE_NOT_EXISTS); return false; } return true; }
From source file:com.tech.utils.CustomCollectionUtil.java
/** * Converts comma separated value string to set of long values * // w w w . j a v a2 s . com * @param csvString * @param seperator * @return itemSet */ public static Set<String> convertStringToSetString(String csvStr, String fieldSeperator) { Set<String> itemSet = new HashSet<String>(); if (StringUtils.isNotEmpty(csvStr) && StringUtils.isNotBlank(csvStr)) { String[] itemsArray = StringUtils.split(csvStr, fieldSeperator); if (itemsArray != null && itemsArray.length > 0) { for (int i = 0; i < itemsArray.length; i++) { if (StringUtils.isNotEmpty(itemsArray[i]) && StringUtils.isNotBlank(itemsArray[i])) { itemSet.add(StringUtils.trim(itemsArray[i])); } } } } return itemSet; }
From source file:com.ottogroup.bi.asap.pipeline.MicroPipelineManager.java
/** * Shuts down the referenced pipeline//from w w w. j ava 2 s.com * @param pipelineId * @throws RequiredInputMissingException */ public String shutdownPipeline(final String pipelineId) throws RequiredInputMissingException { ////////////////////////////////////////////////////////////// // validate input if (StringUtils.isBlank(pipelineId)) throw new RequiredInputMissingException("Missing required pipeline identifier"); // ////////////////////////////////////////////////////////////// String pid = StringUtils.lowerCase(StringUtils.trim(pipelineId)); if (this.microPipelines.containsKey(pid)) { MicroPipeline pipeline = this.microPipelines.remove(pid); if (pipeline != null) { pipeline.shutdown(); if (logger.isDebugEnabled()) logger.debug("Pipeline '" + pipelineId + "' successfully shut down"); } } return pid; }
From source file:com.ottogroup.bi.asap.operator.json.aggregator.JsonContentAggregatorResult.java
/** * Evaluates the referenced aggregated value against the provided value and saves the larger one * @param field/* ww w . j av a2 s .co m*/ * @param fieldValue * @param value * @throws RequiredInputMissingException */ public void evalMaxAggregatedValue(final String field, final String fieldValue, final long value) throws RequiredInputMissingException { /////////////////////////////////////////////////////////////////////////////////////////// // validate provided input if (StringUtils.isBlank(field)) throw new RequiredInputMissingException("Missing required input for parameter 'field'"); if (StringUtils.isBlank(fieldValue)) throw new RequiredInputMissingException("Missing required input for parameter 'fieldValue'"); // /////////////////////////////////////////////////////////////////////////////////////////// String fieldKey = StringUtils.lowerCase(StringUtils.trim(field)); String fieldValueKey = StringUtils.lowerCase(StringUtils.trim(fieldValue)); Map<String, Long> fieldAggregationValues = this.aggregatedValues.get(fieldKey); if (fieldAggregationValues == null) fieldAggregationValues = new HashMap<>(); long aggregationValue = (fieldAggregationValues.containsKey(fieldValueKey) ? fieldAggregationValues.get(fieldValueKey) : Integer.MIN_VALUE); if (value > aggregationValue) { fieldAggregationValues.put(fieldValue, value); this.aggregatedValues.put(fieldKey, fieldAggregationValues); } }