List of usage examples for org.apache.commons.lang3 StringUtils split
public static String[] split(final String str)
Splits the provided text into an array, using whitespace as the separator.
From source file:com.evolveum.midpoint.repo.sql.query2.restriction.FullTextRestriction.java
@Override public Condition interpret() throws QueryException { // TODO implement multiple values if (filter.getValues().size() != 1) { throw new QueryException("FullText filter currently supports only a single string"); }//w ww .j a v a 2s .c o m String text = filter.getValues().iterator().next(); String normalized = getContext().getPrismContext().getDefaultPolyStringNormalizer().normalize(text); String[] words = StringUtils.split(normalized); List<Condition> conditions = new ArrayList<>(words.length); for (String word : words) { conditions.add(createWordQuery(word)); } if (conditions.isEmpty()) { return createWordQuery(""); // original behavior -> match all records (TODO return something like 'empty condition') } else if (conditions.size() == 1) { return conditions.get(0); } else { return getContext().getHibernateQuery().createAnd(conditions); } }
From source file:gov.nih.nci.caintegrator.application.study.MatchScoreComparator.java
/** * Returns the keywords as a <code>List</code>. * @param keywordsString a string with keywords seperated by spaces. * @return the keywords./*w ww. j a v a2 s. c o m*/ */ public List<String> convertStringToList(String keywordsString) { if (keywordsString != null) { return Arrays.asList(StringUtils.split(keywordsString)); } else { return Collections.emptyList(); } }
From source file:eu.popgen.canephora.parsers.plink.BIMReader.java
BIMRecord readRecord() throws IOException { String line = this.in.readLine(); if (line == null) { return null; }//from w w w . j a v a 2 s.com String[] toks = StringUtils.split(line); BIMRecord rec = new BIMRecord(Integer.parseInt(toks[0]), toks[1], Float.parseFloat(toks[2]), Integer.parseInt(toks[3]), toks[4].charAt(0), toks[5].charAt(0)); return rec; }
From source file:net.douglasthrift.bigscreenbot.Settings.java
public List<String> getListProperty(String key, List<String> defaultValue) { String value = getProperty(key); if (value != null) return Arrays.asList(StringUtils.split(value)); else// w w w.jav a 2s .com return defaultValue; }
From source file:blue.lapis.pore.command.PoreCommandCallable.java
@Override public CommandResult process(CommandSource source, String arguments) throws CommandException { // TODO: Label if (getHandle().execute(PoreCommandSender.of(source), getHandle().getLabel(), StringUtils.split(arguments))) { return CommandResult.success(); } else {// w w w . j av a 2 s. co m return CommandResult.empty(); } }
From source file:com.goodhuddle.huddle.service.impl.SearchServiceImpl.java
@Override public org.springframework.data.domain.Page<WebsiteEntity> searchWebsite(SearchWebsiteRequest request) { List<WebsiteEntity> matches = new ArrayList<>(); // poor man's search until implemented properly String phrase = request.getSearchPhrase(); String[] terms = phrase != null ? StringUtils.split(phrase.toLowerCase()) : null; List<WebsiteEntity> entities = new ArrayList<>(); entities.addAll(pageRepository.findByHuddle(huddleService.getHuddle())); entities.addAll(blogRepository.findByHuddle(huddleService.getHuddle())); entities.addAll(blogPostRepository.findAll()); for (WebsiteEntity entity : entities) { if (matches(terms, entity.getTitle()) || matches(terms, entity.getUrl())) { matches.add(entity);/* w ww. j a v a 2 s. c om*/ } } int start = request.getPage() * request.getSize(); int end = Math.min(start + request.getSize(), matches.size()); return new PageImpl<>(matches.subList(start, end), new PageRequest(request.getPage(), request.getSize()), matches.size()); }
From source file:net.douglasthrift.bigscreenbot.Settings.java
public List<String> setListProperty(String key, Collection<String> value) { String oldValue = (String) setProperty(key, StringUtils.join(value, ' ')); if (oldValue != null) return Arrays.asList(StringUtils.split(oldValue)); else// ww w. ja v a 2s . c o m return null; }
From source file:net.sf.jabb.util.stat.TimePeriod.java
/** * Parse strings like '1 hour', '2 days', '3 Years', '12 minute' into TimePeriod. * Short formats like '1H', '2 D', '3y' are also supported. * @param quantityAndUnit the string to be parsed * @return Both quantity and unit/*from ww w. jav a 2s . co m*/ */ static public TimePeriod from(String quantityAndUnit) { String trimed = quantityAndUnit.trim(); String allExceptLast = trimed.substring(0, trimed.length() - 1); if (StringUtils.isNumericSpace(allExceptLast)) { // short format long quantity = Long.parseLong(allExceptLast.trim()); TimePeriodUnit unit = TimePeriodUnit.from(Character.toUpperCase(trimed.charAt(trimed.length() - 1))); return new TimePeriod(quantity, unit); } else { String[] durationAndUnit = StringUtils.split(trimed); Long duration = Long.valueOf(durationAndUnit[0]); TimePeriodUnit unit = TimePeriodUnit.from(durationAndUnit[1]); return new TimePeriod(duration, unit); } }
From source file:blue.lapis.pore.command.PoreCommandCallable.java
@Override public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException { // TODO: Label return getHandle().tabComplete(PoreCommandSender.of(source), getHandle().getLabel(), StringUtils.split(arguments)); }
From source file:com.msopentech.odatajclient.engine.data.metadata.edm.v4.TermDeserializer.java
@Override protected Term doDeserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { final Term term = new Term(); for (; jp.getCurrentToken() != JsonToken.END_OBJECT; jp.nextToken()) { final JsonToken token = jp.getCurrentToken(); if (token == JsonToken.FIELD_NAME) { if ("Name".equals(jp.getCurrentName())) { term.setName(jp.nextTextValue()); } else if ("Type".equals(jp.getCurrentName())) { term.setType(jp.nextTextValue()); } else if ("BaseTerm".equals(jp.getCurrentName())) { term.setBaseTerm(jp.nextTextValue()); } else if ("DefaultValue".equals(jp.getCurrentName())) { term.setDefaultValue(jp.nextTextValue()); } else if ("Nullable".equals(jp.getCurrentName())) { term.setNullable(BooleanUtils.toBoolean(jp.nextTextValue())); } else if ("MaxLength".equals(jp.getCurrentName())) { term.setMaxLength(jp.nextTextValue()); } else if ("Precision".equals(jp.getCurrentName())) { term.setPrecision(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("Scale".equals(jp.getCurrentName())) { term.setScale(BigInteger.valueOf(jp.nextLongValue(0L))); } else if ("SRID".equals(jp.getCurrentName())) { term.setSrid(jp.nextTextValue()); } else if ("AppliesTo".equals(jp.getCurrentName())) { for (String split : StringUtils.split(jp.nextTextValue())) { term.getAppliesTo().add(CSDLElement.valueOf(split)); }//from w w w. j av a 2s . c o m } else if ("Annotation".equals(jp.getCurrentName())) { jp.nextToken(); term.setAnnotation(jp.getCodec().readValue(jp, Annotation.class)); } } } return term; }