splitted database from account
This commit is contained in:
@ -2,6 +2,8 @@ package de.muehlencord.shared.util;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -11,7 +13,9 @@ import org.slf4j.LoggerFactory;
|
||||
*/
|
||||
public abstract class StringUtil {
|
||||
|
||||
/** the logging object */
|
||||
/**
|
||||
* the logging object
|
||||
*/
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class);
|
||||
|
||||
/**
|
||||
@ -27,7 +31,7 @@ public abstract class StringUtil {
|
||||
byte[] b = input.getBytes("UTF-8");
|
||||
return new String(b, "ISO-8859-1");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
LOGGER.debug (ex.toString(), ex);
|
||||
LOGGER.debug(ex.toString(), ex);
|
||||
throw new StringEncodingException("Cannot convert string from UTF-8 to ISO-8859-1. Reason: " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
@ -40,13 +44,13 @@ public abstract class StringUtil {
|
||||
*/
|
||||
public static String getStackTraceString(Throwable ex) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append (ex.toString());
|
||||
sb.append ("\n");
|
||||
|
||||
sb.append(ex.toString());
|
||||
sb.append("\n");
|
||||
|
||||
StackTraceElement[] stack = ex.getStackTrace();
|
||||
for (StackTraceElement currentElement : stack) {
|
||||
sb.append (currentElement.toString());
|
||||
sb.append ("\n");
|
||||
sb.append(currentElement.toString());
|
||||
sb.append("\n");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
@ -56,7 +60,7 @@ public abstract class StringUtil {
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
*
|
||||
*
|
||||
* @param length the needed length for this field
|
||||
* @param s the field to extend with blanks
|
||||
@ -68,42 +72,45 @@ public abstract class StringUtil {
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append (s);
|
||||
sb.append(s);
|
||||
while (sb.toString().length() < length) {
|
||||
sb.append (" ");
|
||||
sb.append(" ");
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the string located between the two given keywords
|
||||
*
|
||||
* @param content the string to get the value from
|
||||
* @param keyWord1 the starting keyword
|
||||
* @param keyWord2 the end keywod
|
||||
* @return the string between keyword1 and keyword2
|
||||
* @throws ParseException if the value cannot be determined - e.g. if one of the keywords is not found
|
||||
* @throws ParseException if the value cannot be determined - e.g. if one of
|
||||
* the keywords is not found
|
||||
*/
|
||||
public static String getValueBetweenKeywords(String content, String keyWord1, String keyWord2) throws ParseException {
|
||||
int pos1 = content.indexOf(keyWord1);
|
||||
if (pos1 == -1) {
|
||||
throw new ParseException("Keyword1=" + keyWord1 + " not found in content string",0);
|
||||
throw new ParseException("Keyword1=" + keyWord1 + " not found in content string", 0);
|
||||
}
|
||||
|
||||
int pos2 = content.indexOf(keyWord2, pos1);
|
||||
if (pos2 == -1) {
|
||||
throw new ParseException("Keyword2=" + keyWord2 + " not found in content string",0);
|
||||
throw new ParseException("Keyword2=" + keyWord2 + " not found in content string", 0);
|
||||
}
|
||||
String returnValue = content.substring(pos1+keyWord1.length(), pos2);
|
||||
String returnValue = content.substring(pos1 + keyWord1.length(), pos2);
|
||||
returnValue = returnValue.trim();
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns true, if given string is either null or a blank string
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return true, if s is either null or s.equals("")
|
||||
*/
|
||||
public static boolean isEmpty(String s) {
|
||||
return (s == null) || (s.equals (""));
|
||||
return (s == null) || (s.equals(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user