MCPcopy Create free account
hub / github.com/BaseXdb/basex / split

Method split

basex-core/src/main/java/org/basex/core/cmd/Find.java:121–153  ·  view source on GitHub ↗

Splits the string and returns an array. @param string string to be split @return array

(final String string)

Source from the content-addressed store, hash-verified

119 * @return array
120 */
121 private static String[] split(final String string) {
122 final int l = string.length();
123 final String[] split = new String[l];
124
125 int s = 0;
126 char delim = 0;
127 final StringBuilder sb = new StringBuilder();
128 for(int i = 0; i < l; ++i) {
129 final char c = string.charAt(i);
130 if(delim == 0) {
131 if(c == '\'' || c == '"') {
132 delim = c;
133 } else if(!XMLToken.isChar(c) && c != '@' && c != '=' && c != '<' && c != '>' && c != '~') {
134 if(!sb.isEmpty()) {
135 split[s++] = sb.toString();
136 sb.setLength(0);
137 }
138 } else {
139 sb.append(c);
140 }
141 } else if(c == delim) {
142 delim = 0;
143 if(!sb.isEmpty()) {
144 split[s++] = sb.toString();
145 sb.setLength(0);
146 }
147 } else if(c != '\'' && c != '"') {
148 sb.append(c);
149 }
150 }
151 if(!sb.isEmpty()) split[s++] = sb.toString();
152 return Array.copyOf(split, s);
153 }
154}

Callers 5

queryMethod · 0.95
tableQueryMethod · 0.95
listMethod · 0.45
nameMethod · 0.45
queryLocksMethod · 0.45

Calls 7

isCharMethod · 0.95
copyOfMethod · 0.95
charAtMethod · 0.80
toStringMethod · 0.65
appendMethod · 0.65
lengthMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected