Splits the string and returns an array. @param string string to be split @return array
(final String string)
| 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 | } |