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:com.thruzero.common.core.map.StringMap.java
/** * Initialized from a series of pipe-separated key value pairs. * <p>/* w ww.ja v a2 s.c o m*/ * Example: * * <pre> * <code> * StringMap map = new StringMap("key1|val1", "key2|val2"); * </code> * </pre> */ public StringMap(final String... keyValuePairs) { if (keyValuePairs != null) { for (String string : keyValuePairs) { String[] keyValue = StringUtils.split(string, '|'); if (keyValue.length != 2) { throw new RuntimeException( "* ERROR: Each key value pair must be separated by the pipe character. This key value pair was not: " + string); } put(keyValue[0], keyValue[1]); } } }
From source file:de.micromata.tpsb.doc.renderer.RendererClassUtils.java
private static void addRencerCps(List<String> cps) { String tpsbcp = LocalSettings.get().get("genome.tpsb.rendercp"); if (StringUtils.isBlank(tpsbcp) == true) { return;// w w w . java 2 s . co m } String[] pathes = StringUtils.split(tpsbcp, ','); for (String path : pathes) { cps.add(StringUtils.trim(path)); } }
From source file:com.mingo.query.util.QueryUtils.java
/** * Gets db name from composite query id. * * @param compositeQueryId composite query id * @return db name//w w w.j a v a 2 s. c o m */ public static String getDbName(String compositeQueryId) { String[] elements = StringUtils.split(compositeQueryId, "."); return getElementByPosition(elements, NUMBER_OF_ELEMENTS, DB_NAME_POSITION); }
From source file:com.techcavern.wavetact.eventListeners.FunMsgListener.java
@Override public void onMessage(MessageEvent event) throws Exception { boolean funmsg = false; Record rec = DatabaseUtils.getChannelProperty(IRCUtils.getNetworkNameByNetwork(event.getBot()), event.getChannel().getName(), "funmsg"); if (rec != null && rec.getValue(Channelproperty.CHANNELPROPERTY.VALUE).equalsIgnoreCase("true")) funmsg = true;/* ww w .ja v a 2 s.co m*/ final boolean funmsg2 = funmsg; class process implements Runnable { public void run() { String commandchar = IRCUtils.getCommandChar(event.getBot(), event.getChannel()); if (commandchar == null) { return; } if (PermUtils.getPermLevel(event.getBot(), event.getUser().getNick(), event.getChannel()) > -2 && !event.getMessage().startsWith(commandchar)) { String[] message = StringUtils.split(event.getMessage(), " "); for (String arg : message) { try { arg = Colors.removeFormattingAndColors(arg); if (arg.toLowerCase().replaceAll("o+", "o").replaceAll("0+", "o").contains("yolo") && funmsg2) { if (IRCUtils.checkIfCanKick(event.getChannel(), event.getBot(), event.getUser())) { IRCUtils.sendKick(event.getBot().getUserBot(), event.getUser(), event.getBot(), event.getChannel(), "YOLO"); } else { IRCUtils.sendAction(event.getUser(), event.getBot(), event.getChannel(), "kicks " + IRCUtils.noPing(event.getUser().getNick()) + " (YOLO)", ""); } return; } Record autourlRecord = DatabaseUtils.getChannelProperty( IRCUtils.getNetworkNameByNetwork(event.getBot()), event.getChannel().getName(), "autourl"); boolean autourl = autourlRecord != null && autourlRecord.getValue(CHANNELPROPERTY.VALUE).equalsIgnoreCase("true"); Record ignorehttpRecord = DatabaseUtils.getChannelProperty( IRCUtils.getNetworkNameByNetwork(event.getBot()), event.getChannel().getName(), "ignorehttp"); boolean ignorehttp = ignorehttpRecord != null && ignorehttpRecord.getValue(CHANNELPROPERTY.VALUE).equalsIgnoreCase("true"); if (ignorehttp && !arg.startsWith("https://") && !arg.startsWith("http://")) { arg = "http://" + arg; } if ((funmsg2 || autourl) && Registry.urlValidator.isValid(arg)) { try { Document doc = Jsoup.connect(arg).userAgent(Registry.USER_AGENT).get(); if (doc.location().contains("stop-irc-bullying.eu") && funmsg2) { if (IRCUtils.checkIfCanKick(event.getChannel(), event.getBot(), event.getUser())) { IRCUtils.sendKick(event.getBot().getUserBot(), event.getUser(), event.getBot(), event.getChannel(), "? \\ ()/ ? [https://goo.gl/Tkb9dh]"); } else { IRCUtils.sendAction(event.getUser(), event.getBot(), event.getChannel(), "kicks " + IRCUtils.noPing(event.getUser().getNick()) + " (? \\ ()/ ?) [https://goo.gl/Tkb9dh]", ""); } /** * My apologies to those using this site responsibly. But in my experience, this site has been linked numerous times for entertainment purposes * In fact, I have yet to notice a time when it is linked for its intended purpose. And if you are using this site for its intended purpose, please think of * better of way of expressing how you feel. Linking a generic site rarely solves any problems. Instead explain to the person how and why they offended you. If * they ignore you, then you ignore them. */ } else if (autourl) { String title = doc.title(); if (!title.isEmpty()) { IRCUtils.sendMessage(event.getBot(), event.getChannel(), "[" + IRCUtils.noPing(event.getUser().getNick()) + "] " + title, ""); } } } catch (Exception e) { e.printStackTrace(); } } } catch (Exception e) { e.printStackTrace(); } } } } } Registry.threadPool.execute(new process()); }
From source file:com.alliander.osgp.dto.valueobjects.smartmetering.CosemObisCodeDto.java
public CosemObisCodeDto(final byte[] code) { if (code.length == 6) { this.a = code[0] & 0xFF; this.b = code[1] & 0xFF; this.c = code[2] & 0xFF; this.d = code[3] & 0xFF; this.e = code[4] & 0xFF; this.f = code[5] & 0xFF; } else {//from w w w . j a va2 s . com final String logicalName = new String(code, StandardCharsets.UTF_8); final String tags[] = StringUtils.split(logicalName, '.'); this.a = Integer.parseInt(tags[0]); this.b = Integer.parseInt(tags[1]); this.c = Integer.parseInt(tags[2]); this.d = Integer.parseInt(tags[3]); this.e = Integer.parseInt(tags[4]); this.f = Integer.parseInt(tags[5]); } }
From source file:edu.illinois.cs.cogcomp.wikifier.utils.io.InFile.java
public static List<String> aggressiveTokenize(String s) { if (s == null) return null; return Arrays.asList(StringUtils.split(s, " \n\t,./<>?;':\"[]{}\\|`~!@#$%^&*()_+-=")); // List<String> res= Lists.newArrayList(); // StringTokenizer st=new StringTokenizer(s," \n\t,./<>?;':\"[]{}\\|`~!@#$%^&*()_+-="); // while(st.hasMoreTokens()) // res.add(st.nextToken()); // return res; }
From source file:net.gtaun.wl.race.dialog.CodeEditorDialog.java
public CodeEditorDialog(Player player, EventManager eventManager, AbstractDialog parent, RaceServiceImpl service, String title, String code, Consumer<String> onCompleteHandler) { super(player, eventManager); setParentDialog(parent);//from ww w . ja v a 2 s.c o m this.onCompleteHandler = onCompleteHandler; if (code == null) code = ""; codeLines = new ArrayList<>(Arrays.asList(StringUtils.split(code, '\n'))); stringSet = service.getLocalizedStringSet().getStringSet(player); setCaption(() -> stringSet.format("Dialog.CodeEditorDialog.Caption", title, codeLines.size())); }
From source file:ch.cyberduck.core.sftp.SFTPQuotaFeature.java
@Override public Space get() throws BackgroundException { final ThreadLocal<Space> quota = new ThreadLocal<Space>() { @Override/* www .java 2s. c o m*/ protected Space initialValue() { return new Space(0L, Long.MAX_VALUE); } }; final Path home = new SFTPHomeDirectoryService(session).find(); new SFTPCommandFeature(session).send(String.format("df -Pk %s | awk '{print $3, $4}'", home.getAbsolute()), new DisabledProgressListener(), new TranscriptListener() { @Override public void log(final Type request, final String output) { switch (request) { case response: final String[] numbers = StringUtils.split(output, ' '); if (numbers.length == 2) { try { quota.set(new Space(Long.valueOf(numbers[0]) * 1000L, Long.valueOf(numbers[1]) * 1000L)); } catch (NumberFormatException e) { log.warn(String.format("Ignore line %s", output)); } } else { log.warn(String.format("Ignore line %s", output)); } } } }); return quota.get(); }
From source file:com.quancheng.saluki.core.grpc.client.GrpcClientStrategy.java
private GrpcProtocolClient<Object> buildProtoClient(GrpcURL refUrl) { boolean isGeneric = refUrl.getParameter(Constants.GENERIC_KEY, Boolean.FALSE); boolean isGrpcStub = refUrl.getParameter(Constants.GRPC_STUB_KEY, Boolean.FALSE); if (isGeneric) { String[] methodNames = StringUtils.split(refUrl.getParameter(Constants.METHODS_KEY), ","); int retries = refUrl.getParameter((Constants.METHOD_RETRY_KEY), 0); Map<String, Integer> methodRetries = cacheRetries(methodNames, retries); return new GenericProxyClient<Object>(methodRetries, refUrl); } else {//from w w w. j av a 2s. c o m if (isGrpcStub) { String stubClassName = refUrl.getParameter(Constants.INTERFACECLASS_KEY); try { @SuppressWarnings({ "rawtypes", "unchecked" }) Class<? extends AbstractStub> stubClass = (Class<? extends AbstractStub>) ReflectUtils .name2class(stubClassName); return new GrpcStubClient<Object>(stubClass); } catch (ClassNotFoundException e) { throw new IllegalArgumentException("grpc stub client the class must exist in classpath", e); } } else { String[] methodNames = StringUtils.split(refUrl.getParameter(Constants.METHODS_KEY), ","); int retries = refUrl.getParameter((Constants.METHOD_RETRY_KEY), 0); String interfaceName = refUrl.getServiceInterface(); Map<String, Integer> methodRetries = cacheRetries(methodNames, retries); return new DefaultProxyClient<Object>(interfaceName, methodRetries, refUrl); } } }
From source file:com.mowitnow.lawnmower.service.InputService.java
private static void checkInput(String input) { try {//from ww w .j a v a2 s. c o m logger.log(null); Preconditions.checkArgument(StringUtils.isNotBlank(input), "Empty input is not allowed."); String lines[] = StringUtils.split(input, System.getProperty("line.separator")); Preconditions.checkArgument((lines.length % 2) == 1, "The number of input lines must be odd."); Preconditions.checkArgument(lines[0].matches("[0-9]+ [0-9]+"), "Lawn size is invalid."); for (int i = 1; i < lines.length - 1; i = i + 2) { Preconditions.checkArgument(lines[i].matches("[0-9]+ [0-9]+ [NESW]"), "Invalid position or direction for mower " + (i + 1) / 2 + "."); Preconditions.checkArgument(lines[i + 1].matches("[DGA]*"), "Invalid command for mower " + (i + 1) / 2 + "."); } } catch (IllegalArgumentException iex) { logger.log(iex.getMessage()); } }