
org.bimserver.utils.StringUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pluginbase Show documentation
Show all versions of pluginbase Show documentation
Base project for BIMserver plugin development. Some plugins mights also need the Shared library
The newest version!
package org.bimserver.utils;
/******************************************************************************
* Copyright (C) 2009-2016 BIMserver.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see {@literal }.
*****************************************************************************/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.Charsets;
public class StringUtils {
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtils.class);
public static StringBuilder stripEnd(StringBuilder sb, String needle) {
if (needle.length() > sb.length()) {
return sb;
}
if (sb.substring(sb.length() - (needle.length())).equals(needle)) {
sb.delete(sb.length() - needle.length(), sb.length());
}
return sb;
}
public static String fill(String startValue, int length, String token) {
return fill(new StringBuilder(startValue), length, token).toString();
}
public static StringBuilder fill(StringBuilder startValue, int length, String token) {
while (startValue.length() < length) {
startValue.append(token);
}
return startValue;
}
public static void main(String[] args) {
String in = "Dit is een 'test',ik snap er nix van,dit moet 'ge,split' worden";
int lastIndex = 0;
while (lastIndex < in.length()) {
int newIndex = nextString(in, lastIndex);
String value = in.substring(lastIndex, newIndex-1);
System.out.println(value);
lastIndex = newIndex;
}
}
public static int nextString(String in, int start) {
int parentheses = 0;
int quotes = 0;
char c;
int length = in.length();
int escapeMode = 0;
for (int i=start; i items, String quotation, String separation) {
StringBuilder sb = new StringBuilder();
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy