Java Code Examples for org.apache.commons.lang.StringUtils#strip()
The following examples show how to use
org.apache.commons.lang.StringUtils#strip() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StringTagger.java From iaf with Apache License 2.0 | 6 votes |
/** * Returns the first value as a <code>String</code>. * In case of a single value, it returns that value. In case of multiple values, * it returns the * Use {@link #get} to get the list of values as a <code>String</code><br> * Use {@link #Values} to get a list of multi-values as a <code>Vector</code>.<br> * @param token the key of the value to retrieve */ public String Value(String token) { String val; Vector tmp=(Vector)multitokens.get(token); if (tmp!=null && tmp.size()>0) { val=(String)tmp.elementAt(0); if (val!=null) { val = StringUtils.strip(val,"\""); // added stripping daniel return val; } else { return null; } } else { return null; } }
Example 2
Source File: SonosGenericBindingProvider.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
private void parseAndAddBindingConfig(Item item, String bindingConfigs) throws BindingConfigParseException { String bindingConfig = StringUtils.substringBefore(bindingConfigs, ","); String bindingConfigTail = StringUtils.substringAfter(bindingConfigs, ","); SonosBindingConfig newConfig = new SonosBindingConfig(); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); while (StringUtils.isNotBlank(bindingConfigTail)) { bindingConfig = StringUtils.substringBefore(bindingConfigTail, ","); bindingConfig = StringUtils.strip(bindingConfig); bindingConfigTail = StringUtils.substringAfter(bindingConfigTail, ","); parseBindingConfig(newConfig, item, bindingConfig); addBindingConfig(item, newConfig); } }
Example 3
Source File: PhpElementsUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Get class by shortcut namespace, on a scoped namespace * @param project current project * @param classNameScope Namespace fo search "\Foo\Foo", "Foo\Foo", "Foo\Foo\", last "\*" is stripped * @param className Class name inside namespace also fqn is supported * @return PhpClass matched */ public static PhpClass getClassInsideNamespaceScope(@NotNull Project project, @NotNull String classNameScope, @NotNull String className) { if(className.startsWith("\\")) { return PhpElementsUtil.getClassInterface(project, className); } // strip class name we namespace String strip = StringUtils.strip(classNameScope, "\\"); int i = strip.lastIndexOf("\\"); if(i <= 0) { return PhpElementsUtil.getClassInterface(project, className); } PhpClass phpClass = PhpElementsUtil.getClassInterface(project, strip.substring(0, i) + "\\" + StringUtils.strip(className, "\\")); if(phpClass != null) { return phpClass; } return PhpElementsUtil.getClassInterface(project, className); }
Example 4
Source File: UseAliasForm.java From idea-php-annotation-plugin with MIT License | 6 votes |
private void onOK() { String classText = StringUtils.strip(textClassName.getText(), "\\"); if(!PhpNameUtil.isValidNamespaceFullName(classText)) { JOptionPane.showMessageDialog(this, "Invalid class name"); return; } String alias = textAlias.getText(); if(!PhpNameUtil.isValidNamespaceFullName(alias)) { JOptionPane.showMessageDialog(this, "Invalid alias"); return; } this.useAliasOption.setClassName(classText); this.useAliasOption.setAlias(alias); this.useAliasOption.setEnabled(checkStatus.isSelected()); this.callback.ok(this.useAliasOption); dispose(); }
Example 5
Source File: SelectQuery.java From r2rml-parser with Apache License 2.0 | 6 votes |
public ArrayList<SelectField> createSelectFields(String q) { ArrayList<SelectField> results = new ArrayList<SelectField>(); int start = q.toUpperCase().indexOf("SELECT") + 7; int end = q.toUpperCase().indexOf("FROM"); List<String> fields = splitFields(q.substring(start, end)); List<String> processedFields = new ArrayList<String>(); for (int i = 0; i < fields.size(); i++) { String strippedFieldName = StringUtils.strip(fields.get(i)); if (createSelectFieldTable(strippedFieldName) != null) { processedFields.add(strippedFieldName); } } for (String field : processedFields) { SelectField f = new SelectField(); f.setName(field.trim()); f.setTable(createSelectFieldTable(field.trim())); f.setAlias(createAlias(field).trim()); log.info("Adding field with: name '" + f.getName() + "', table '" + f.getTable().getName() + "', alias '" + f.getAlias() + "'"); results.add(f); } return results; }
Example 6
Source File: FlumeLogstashV1Appender.java From logback-flume-appender with MIT License | 6 votes |
private Map<String, String> extractProperties(String propertiesAsString) { final Map<String, String> props = new HashMap<String, String>(); if (StringUtils.isNotEmpty(propertiesAsString)) { final String[] segments = propertiesAsString.split(";"); for (final String segment : segments) { final String[] pair = segment.split("="); if (pair.length == 2) { final String key = StringUtils.strip(pair[0]); final String value = StringUtils.strip(pair[1]); if (StringUtils.isNotEmpty(key) && StringUtils.isNotEmpty(value)) { props.put(key, value); } else { addWarn("Empty key or value not accepted: " + segment); } } else { addWarn("Not a valid {key}:{value} format: " + segment); } } } else { addInfo("Not overriding any flume agent properties"); } return props; }
Example 7
Source File: LogConfigUtils.java From singer with Apache License 2.0 | 5 votes |
/** * Returns the file path on local disk corresponding to a ZooKeeper server set * path. * * E.g. /discovery/service/prod => /var/serverset/discovery.service.prod */ public static String filePathFromZKPath(String serverSetZKPath) { MorePreconditions.checkNotBlank(serverSetZKPath); String filename = serverSetZKPath.replace('/', '.'); filename = StringUtils.strip(filename, "."); // strip any leading or trailing dots. return new File(DEFAULT_SERVERSET_DIR, filename).getPath(); }
Example 8
Source File: GlobalNamespaceLoader.java From idea-php-drupal-symfony2-bridge with MIT License | 5 votes |
@NotNull private static Collection<String> getGlobalNamespacesInner(@NotNull Project project) { Collection<String> namespaces = new HashSet<>(); for (PhpClass phpClass : PhpIndex.getInstance(project).getAllSubclasses("Drupal\\Component\\Annotation\\AnnotationInterface")) { String namespaceName = StringUtils.strip(phpClass.getNamespaceName(), "\\"); if(namespaceName.endsWith("Annotation")) { namespaces.add(namespaceName); } } return namespaces; }
Example 9
Source File: ZookeeperConnector.java From secor with Apache License 2.0 | 5 votes |
protected String getCommittedOffsetGroupPath() { if (Strings.isNullOrEmpty(mCommittedOffsetGroupPath)) { String stripped = StringUtils.strip(mConfig.getKafkaZookeeperPath(), "/"); mCommittedOffsetGroupPath = getOffsetGroupPath("offsets"); } return mCommittedOffsetGroupPath; }
Example 10
Source File: ElUtil.java From telekom-workflow-engine with MIT License | 5 votes |
/** * After trimming the input, removes two characters from the start and one from the end and returns the result. */ public static String removeBrackets( String condition ){ String value = StringUtils.strip( condition ); if( value != null && value.length() >= 3 ){ return value.substring( 2, value.length() - 1 ); } return value; }
Example 11
Source File: KeycloakOauthPolicy.java From apiman-plugins with Apache License 2.0 | 5 votes |
private String getRawAuthToken(ApiRequest request) { String rawToken = StringUtils.strip(request.getHeaders().get(AUTHORIZATION_KEY)); if (rawToken != null && StringUtils.startsWithIgnoreCase(rawToken, BEARER)) { rawToken = StringUtils.removeStartIgnoreCase(rawToken, BEARER); } else { rawToken = request.getQueryParams().get(ACCESS_TOKEN_QUERY_KEY); } return rawToken; }
Example 12
Source File: DocumentTypePropertyParser.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
@Override public String parse(String value) { if (value == null) { return null; } return StringUtils.strip(value, "\""); }
Example 13
Source File: Rt2HisOnHive.java From indexr with Apache License 2.0 | 5 votes |
private static String getHiveTablePartitionColumn(String createSql) { String partitionSql = fetchByRegx(createSql, "PARTITIONED BY\\s?\\([^)]+\\)"); String colDef = StringUtils.removeStart(partitionSql, "PARTITIONED BY").trim(); colDef = StringUtils.removeStart(colDef, "("); colDef = StringUtils.removeEnd(colDef, ")"); if (colDef.split(",").length > 1) { throw new IllegalStateException(String.format("%s contains more than one partition column", createSql)); } String colName = fetchByRegx(colDef, "`.+`"); return StringUtils.strip(colName, "`"); }
Example 14
Source File: ZookeeperConnector.java From secor with Apache License 2.0 | 5 votes |
protected String getLastSeenOffsetGroupPath() { if (Strings.isNullOrEmpty(mLastSeenOffsetGroupPath)) { String stripped = StringUtils.strip(mConfig.getKafkaZookeeperPath(), "/"); mLastSeenOffsetGroupPath = getOffsetGroupPath("lastSeen"); } return mLastSeenOffsetGroupPath; }
Example 15
Source File: TableInfo.java From BigDataPlatform with GNU General Public License v3.0 | 5 votes |
static String[] findCols(String lines) { System.out.println(lines); String[] ns = lines.split(","); String[] re = new String[ns.length]; for (int j = 0; j < ns.length; j++) { re[j] = StringUtils.strip(ns[j], "`"); } return re; }
Example 16
Source File: Rt2HisOnHive.java From indexr with Apache License 2.0 | 4 votes |
private static SegmentSchema getSchema(String createSql) { String regx = "`\\w+` \\w+ COMMENT '.*'"; Pattern pattern = Pattern.compile(regx); Matcher matcher = pattern.matcher(createSql); List<ColumnSchema> columnSchemas = new ArrayList<>(); while (matcher.find()) { String colStr = matcher.group().trim(); colStr = colStr.substring(0, colStr.indexOf("COMMENT")); String[] strs = colStr.trim().split(" ", 2); String colName = StringUtils.strip(strs[0], "`"); String colType = strs[1].trim(); SQLType indexrType; switch (colType.toUpperCase()) { case "INT": indexrType = SQLType.INT; break; case "BIGINT": indexrType = SQLType.BIGINT; break; case "FLOAT": indexrType = SQLType.FLOAT; break; case "DOUBLE": indexrType = SQLType.DOUBLE; break; case "STRING": indexrType = SQLType.VARCHAR; break; case "DATE": indexrType = SQLType.DATE; break; case "TIMESTAMP": indexrType = SQLType.DATETIME; break; default: throw new IllegalStateException("unsupported hive type " + colType); } columnSchemas.add(new ColumnSchema(colName, indexrType)); } return new SegmentSchema(columnSchemas); }
Example 17
Source File: RelatedDatableRangeFacetDescription.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private Datable getDatable(String datableAsString) { String value = StringUtils.strip(datableAsString, "\""); return new Datable(value); }
Example 18
Source File: DatableRangeFacetDescription.java From timbuctoo with GNU General Public License v3.0 | 4 votes |
private Datable getDatable(String datableAsString) { String value = StringUtils.strip(datableAsString, "\""); return new Datable(value); }
Example 19
Source File: OldHintParser.java From tddl5 with Apache License 2.0 | 4 votes |
private static Map<String, Object> simpleParser(String tddlHint) { Map<String, Object> result = new HashMap<String, Object>(3); boolean inArray = false; int start = 0; for (int i = 0; i < tddlHint.length(); i++) { char ch = tddlHint.charAt(i); switch (ch) { case '}': case ',': if (!inArray) { String part = tddlHint.substring(start, i); String[] values = StringUtils.split(part, ':'); if (values.length != 2) { throw new OptimizerException("hint syntax error : " + part); } String key = StringUtils.strip(values[0]); String value = StringUtils.strip(values[1]); if (value.charAt(0) == '[' && value.charAt(value.length() - 1) == ']') { // 处理数组 value = value.substring(1, value.length() - 1);// 去掉前后[] String[] vv = StringUtils.split(value, ','); List<String> list = new ArrayList<String>(); for (String v : vv) { v = StringUtils.remove(v, "\""); v = StringUtils.remove(v, "\'"); list.add(v); } result.put(key, list); } else { if (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'') { result.put(key, value.substring(1, value.length() - 1));// 去掉前后'号 } else { result.put(key, value); } } start = i + 1;// 跳到下一个 } break; case '[': inArray = true; break; case ']': inArray = false; break; case '{': start = i + 1; break; default: break; } } return result; }
Example 20
Source File: BudgetRequestImportServiceImpl.java From kfs with GNU Affero General Public License v3.0 | 4 votes |
/** * @see org.kuali.kfs.module.bc.document.service.BudgetRequestImportService#processImportFile(java.io.InputStream, java.lang.String, * java.lang.String, java.lang.String) */ @Transactional public List processImportFile(InputStream fileImportStream, String principalId, String fieldSeperator, String textDelimiter, String fileType, Integer budgetYear) throws IOException { List fileErrorList = new ArrayList(); deleteBudgetConstructionMoveRecords(principalId); BudgetConstructionRequestMove budgetConstructionRequestMove = new BudgetConstructionRequestMove(); BufferedReader fileReader = new BufferedReader(new InputStreamReader(fileImportStream)); int currentLine = 1; while (fileReader.ready()) { String line = StringUtils.strip(fileReader.readLine()); boolean isAnnualFile = (fileType.equalsIgnoreCase(RequestImportFileType.ANNUAL.toString())) ? true : false; if (StringUtils.isNotBlank(line)) { budgetConstructionRequestMove = ImportRequestFileParsingHelper.parseLine(line, fieldSeperator, textDelimiter, isAnnualFile); // check if there were errors parsing the line if (budgetConstructionRequestMove == null) { fileErrorList.add(BCConstants.REQUEST_IMPORT_FILE_PROCESSING_ERROR_MESSAGE_GENERIC + " " + currentLine + "."); // clean out table since file processing has stopped deleteBudgetConstructionMoveRecords(principalId); return fileErrorList; } String lineValidationError = validateLine(budgetConstructionRequestMove, currentLine, isAnnualFile); if ( StringUtils.isNotEmpty(lineValidationError) ) { fileErrorList.add(lineValidationError); // clean out table since file processing has stopped deleteBudgetConstructionMoveRecords(principalId); return fileErrorList; } // set default values if (StringUtils.isBlank(budgetConstructionRequestMove.getSubAccountNumber())) { budgetConstructionRequestMove.setSubAccountNumber(KFSConstants.getDashSubAccountNumber()); } if (StringUtils.isBlank(budgetConstructionRequestMove.getFinancialSubObjectCode())) { budgetConstructionRequestMove.setFinancialSubObjectCode(KFSConstants.getDashFinancialSubObjectCode()); } //set object type code Collection<String> revenueObjectTypesParamValues = BudgetParameterFinder.getRevenueObjectTypes(); Collection<String> expenditureObjectTypesParamValues = BudgetParameterFinder.getExpenditureObjectTypes(); ObjectCode objectCode = getObjectCode(budgetConstructionRequestMove, budgetYear); if (objectCode != null) { if ( expenditureObjectTypesParamValues.contains(objectCode.getFinancialObjectTypeCode()) ) { budgetConstructionRequestMove.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode()); // now using type from object code table //budgetConstructionRequestMove.setFinancialObjectTypeCode(optionsService.getOptions(budgetYear).getFinObjTypeExpenditureexpCd()); } else if ( revenueObjectTypesParamValues.contains(objectCode.getFinancialObjectTypeCode()) ) { budgetConstructionRequestMove.setFinancialObjectTypeCode(objectCode.getFinancialObjectTypeCode()); // now using type from object code table //budgetConstructionRequestMove.setFinancialObjectTypeCode(optionsService.getOptions(budgetYear).getFinObjectTypeIncomecashCode()); } } //check for duplicate key exception, since it requires a different error message Map searchCriteria = new HashMap(); searchCriteria.put("principalId", principalId); searchCriteria.put("chartOfAccountsCode", budgetConstructionRequestMove.getChartOfAccountsCode()); searchCriteria.put("accountNumber", budgetConstructionRequestMove.getAccountNumber()); searchCriteria.put("subAccountNumber", budgetConstructionRequestMove.getSubAccountNumber()); searchCriteria.put("financialObjectCode", budgetConstructionRequestMove.getFinancialObjectCode()); searchCriteria.put("financialSubObjectCode", budgetConstructionRequestMove.getFinancialSubObjectCode()); if ( this.businessObjectService.countMatching(BudgetConstructionRequestMove.class, searchCriteria) != 0 ) { LOG.error("Move table store error, import aborted"); fileErrorList.add("Duplicate Key for " + budgetConstructionRequestMove.getErrorLinePrefixForLogFile()); fileErrorList.add("Move table store error, import aborted"); deleteBudgetConstructionMoveRecords(principalId); return fileErrorList; } try { budgetConstructionRequestMove.setPrincipalId(principalId); importRequestDao.save(budgetConstructionRequestMove, false); } catch (RuntimeException e) { LOG.error("Move table store error, import aborted"); fileErrorList.add("Move table store error, import aborted"); return fileErrorList; } } currentLine++; } return fileErrorList; }