List of usage examples for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY
String[] EMPTY_STRING_ARRAY
To view the source code for org.apache.commons.lang ArrayUtils EMPTY_STRING_ARRAY.
Click Source Link
String
array. From source file:loci.formats.in.KLBReader.java
@Override public String[] getUsedFiles(boolean noPixels) { FormatTools.assertId(currentId, true, 1); String[] completeFileList = new String[getSizeT() * getSizeC() * filelist.size()]; int index = 0; for (String seriesKey : filelist.keySet()) { String[][] seriesFiles = filelist.get(seriesKey); for (int timepoint = 0; timepoint < getSizeT(); timepoint++) { for (int channel = 0; channel < getSizeC(); channel++) { completeFileList[index] = seriesFiles[timepoint][channel]; index++;//from w ww .j av a2 s . c om } } } return noPixels ? ArrayUtils.EMPTY_STRING_ARRAY : completeFileList; }
From source file:com.google.gdt.eclipse.designer.core.model.property.StylePropertyEditorTest.java
private static String getStyleSource(String styleLine) { String[] styleLines = styleLine != null ? new String[] { " " + styleLine + ";" } : ArrayUtils.EMPTY_STRING_ARRAY; return getSource3( new String[] { "// filler filler filler filler filler", "// filler filler filler filler filler", "public class Test extends FlowPanel {", " public Test() {" }, styleLines, new String[] { "// filler filler filler filler filler", "// filler filler filler filler filler", " }", "}" }); }
From source file:jp.co.opentone.bsol.linkbinder.service.notice.impl.EmailNoticeServiceImpl.java
/** * ?ID??????ID???.//from w w w. j a v a 2 s .c om * * @param oldToUserIdArray ID? * @param currentUserIdArray ID? * @return ID???????ID */ private String[] subtractOldToUserIdFromCurrent(String[] oldToUserIdArray, String[] currentUserIdArray) { List<String> ret = new ArrayList<String>(); List<String> list = Arrays.asList(oldToUserIdArray); for (String currentUserId : currentUserIdArray) { if (!list.contains(currentUserId)) { ret.add(currentUserId); } } return ret.toArray(ArrayUtils.EMPTY_STRING_ARRAY); }
From source file:jp.co.opentone.bsol.linkbinder.service.notice.impl.EmailNoticeServiceImpl.java
/** * Address Correspon Group?????ID???./* w w w. j ava 2 s . co m*/ * * @param addressCorresponGroups ID?Address Correspon Group * @return ??ID */ private String[] collectUniqueUserIdOfAddressCorresponGroupList( List<AddressCorresponGroup> addressCorresponGroups) { if (addressCorresponGroups == null) { return ArrayUtils.EMPTY_STRING_ARRAY; } Set<String> uniqueIdSet = new HashSet<String>(); for (AddressCorresponGroup group : addressCorresponGroups) { if (group.getUsers() == null) { continue; } for (AddressUser user : group.getUsers()) { uniqueIdSet.add(user.getUser().getEmpNo()); } } String[] ret = uniqueIdSet.toArray(ArrayUtils.EMPTY_STRING_ARRAY); Arrays.sort(ret); return ret; }
From source file:jp.co.opentone.bsol.linkbinder.service.notice.impl.EmailNoticeServiceImpl.java
/** * PIC??????ID???.//from w w w .j a va 2 s . co m * * @param pics ID?PersonInCharge? * @return ??ID */ private String[] collectUniqueUserIdOfPersonInChargeList(List<PersonInCharge> pics) { Set<String> uniqueIdSet = new HashSet<String>(); for (PersonInCharge pic : pics) { uniqueIdSet.add(pic.getUser().getEmpNo()); } String[] ret = uniqueIdSet.toArray(ArrayUtils.EMPTY_STRING_ARRAY); Arrays.sort(ret); return ret; }
From source file:com.test.stringtest.StringUtils.java
/** * <p>Searches a String for substrings delimited by a start and end tag, * returning all matching substrings in an array.</p> * * <p>A <code>null</code> input String returns <code>null</code>. * A <code>null</code> open/close returns <code>null</code> (no match). * An empty ("") open/close returns <code>null</code> (no match).</p> * * <pre>//from w w w .j a v a 2 s . co m * StringUtils.substringsBetween("[a][b][c]", "[", "]") = ["a","b","c"] * StringUtils.substringsBetween(null, *, *) = null * StringUtils.substringsBetween(*, null, *) = null * StringUtils.substringsBetween(*, *, null) = null * StringUtils.substringsBetween("", "[", "]") = [] * </pre> * * @param str the String containing the substrings, null returns null, empty returns empty * @param open the String identifying the start of the substring, empty returns null * @param close the String identifying the end of the substring, empty returns null * @return a String Array of substrings, or <code>null</code> if no match * @since 2.3 */ public static String[] substringsBetween(String str, String open, String close) { if (str == null || isEmpty(open) || isEmpty(close)) { return null; } int strLen = str.length(); if (strLen == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } int closeLen = close.length(); int openLen = open.length(); List list = new ArrayList(); int pos = 0; while (pos < (strLen - closeLen)) { int start = str.indexOf(open, pos); if (start < 0) { break; } start += openLen; int end = str.indexOf(close, start); if (end < 0) { break; } list.add(str.substring(start, end)); pos = end + closeLen; } if (list.isEmpty()) { return null; } return (String[]) list.toArray(new String[list.size()]); }
From source file:com.test.stringtest.StringUtils.java
/** * Performs the logic for the <code>splitByWholeSeparatorPreserveAllTokens</code> methods. * * @param str the String to parse, may be <code>null</code> * @param separator String containing the String to be used as a delimiter, * <code>null</code> splits on whitespace * @param max the maximum number of elements to include in the returned * array. A zero or negative value implies no limit. * @param preserveAllTokens if <code>true</code>, adjacent separators are * treated as empty token separators; if <code>false</code>, adjacent * separators are treated as one separator. * @return an array of parsed Strings, <code>null</code> if null String input * @since 2.4/*from www .j a v a 2 s. c o m*/ */ private static String[] splitByWholeSeparatorWorker(String str, String separator, int max, boolean preserveAllTokens) { if (str == null) { return null; } int len = str.length(); if (len == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } if ((separator == null) || (EMPTY.equals(separator))) { // Split on whitespace. return splitWorker(str, null, max, preserveAllTokens); } int separatorLength = separator.length(); ArrayList substrings = new ArrayList(); int numberOfSubstrings = 0; int beg = 0; int end = 0; while (end < len) { end = str.indexOf(separator, beg); if (end > -1) { if (end > beg) { numberOfSubstrings += 1; if (numberOfSubstrings == max) { end = len; substrings.add(str.substring(beg)); } else { // The following is OK, because String.substring( beg, end ) excludes // the character at the position 'end'. substrings.add(str.substring(beg, end)); // Set the starting point for the next search. // The following is equivalent to beg = end + (separatorLength - 1) + 1, // which is the right calculation: beg = end + separatorLength; } } else { // We found a consecutive occurrence of the separator, so skip it. if (preserveAllTokens) { numberOfSubstrings += 1; if (numberOfSubstrings == max) { end = len; substrings.add(str.substring(beg)); } else { substrings.add(EMPTY); } } beg = end + separatorLength; } } else { // String.substring( beg ) goes from 'beg' to the end of the String. substrings.add(str.substring(beg)); end = len; } } return (String[]) substrings.toArray(new String[substrings.size()]); }
From source file:com.test.stringtest.StringUtils.java
/** * Performs the logic for the <code>split</code> and * <code>splitPreserveAllTokens</code> methods that do not return a * maximum array length./* w w w . j ava 2s.com*/ * * @param str the String to parse, may be <code>null</code> * @param separatorChar the separate character * @param preserveAllTokens if <code>true</code>, adjacent separators are * treated as empty token separators; if <code>false</code>, adjacent * separators are treated as one separator. * @return an array of parsed Strings, <code>null</code> if null String input */ private static String[] splitWorker(String str, char separatorChar, boolean preserveAllTokens) { // Performance tuned for 2.0 (JDK1.4) if (str == null) { return null; } int len = str.length(); if (len == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } List list = new ArrayList(); int i = 0, start = 0; boolean match = false; boolean lastMatch = false; while (i < len) { if (str.charAt(i) == separatorChar) { if (match || preserveAllTokens) { list.add(str.substring(start, i)); match = false; lastMatch = true; } start = ++i; continue; } lastMatch = false; match = true; i++; } if (match || (preserveAllTokens && lastMatch)) { list.add(str.substring(start, i)); } return (String[]) list.toArray(new String[list.size()]); }
From source file:com.test.stringtest.StringUtils.java
/** * Performs the logic for the <code>split</code> and * <code>splitPreserveAllTokens</code> methods that return a maximum array * length./*w w w . j a v a 2 s . c om*/ * * @param str the String to parse, may be <code>null</code> * @param separatorChars the separate character * @param max the maximum number of elements to include in the * array. A zero or negative value implies no limit. * @param preserveAllTokens if <code>true</code>, adjacent separators are * treated as empty token separators; if <code>false</code>, adjacent * separators are treated as one separator. * @return an array of parsed Strings, <code>null</code> if null String input */ private static String[] splitWorker(String str, String separatorChars, int max, boolean preserveAllTokens) { // Performance tuned for 2.0 (JDK1.4) // Direct code is quicker than StringTokenizer. // Also, StringTokenizer uses isSpace() not isWhitespace() if (str == null) { return null; } int len = str.length(); if (len == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } List list = new ArrayList(); int sizePlus1 = 1; int i = 0, start = 0; boolean match = false; boolean lastMatch = false; if (separatorChars == null) { // Null separator means use whitespace while (i < len) { if (Character.isWhitespace(str.charAt(i))) { if (match || preserveAllTokens) { lastMatch = true; if (sizePlus1++ == max) { i = len; lastMatch = false; } list.add(str.substring(start, i)); match = false; } start = ++i; continue; } lastMatch = false; match = true; i++; } } else if (separatorChars.length() == 1) { // Optimise 1 character case char sep = separatorChars.charAt(0); while (i < len) { if (str.charAt(i) == sep) { if (match || preserveAllTokens) { lastMatch = true; if (sizePlus1++ == max) { i = len; lastMatch = false; } list.add(str.substring(start, i)); match = false; } start = ++i; continue; } lastMatch = false; match = true; i++; } } else { // standard case while (i < len) { if (separatorChars.indexOf(str.charAt(i)) >= 0) { if (match || preserveAllTokens) { lastMatch = true; if (sizePlus1++ == max) { i = len; lastMatch = false; } list.add(str.substring(start, i)); match = false; } start = ++i; continue; } lastMatch = false; match = true; i++; } } if (match || (preserveAllTokens && lastMatch)) { list.add(str.substring(start, i)); } return (String[]) list.toArray(new String[list.size()]); }
From source file:com.test.stringtest.StringUtils.java
/** * <p>Splits a String by Character type as returned by * <code>java.lang.Character.getType(char)</code>. Groups of contiguous * characters of the same type are returned as complete tokens, with the * following exception: if <code>camelCase</code> is <code>true</code>, * the character of type <code>Character.UPPERCASE_LETTER</code>, if any, * immediately preceding a token of type <code>Character.LOWERCASE_LETTER</code> * will belong to the following token rather than to the preceding, if any, * <code>Character.UPPERCASE_LETTER</code> token. * @param str the String to split, may be <code>null</code> * @param camelCase whether to use so-called "camel-case" for letter types * @return an array of parsed Strings, <code>null</code> if null String input * @since 2.4/*from w ww . j a v a 2 s .c o m*/ */ private static String[] splitByCharacterType(String str, boolean camelCase) { if (str == null) { return null; } if (str.length() == 0) { return ArrayUtils.EMPTY_STRING_ARRAY; } char[] c = str.toCharArray(); List list = new ArrayList(); int tokenStart = 0; int currentType = Character.getType(c[tokenStart]); for (int pos = tokenStart + 1; pos < c.length; pos++) { int type = Character.getType(c[pos]); if (type == currentType) { continue; } if (camelCase && type == Character.LOWERCASE_LETTER && currentType == Character.UPPERCASE_LETTER) { int newTokenStart = pos - 1; if (newTokenStart != tokenStart) { list.add(new String(c, tokenStart, newTokenStart - tokenStart)); tokenStart = newTokenStart; } } else { list.add(new String(c, tokenStart, pos - tokenStart)); tokenStart = pos; } currentType = type; } list.add(new String(c, tokenStart, c.length - tokenStart)); return (String[]) list.toArray(new String[list.size()]); }