Returns a sorted list of attributes. @param attrs The map to sort @return a sorted attribute array
(NamedNodeMap attrs)
| 163 | * @return a sorted attribute array |
| 164 | */ |
| 165 | private Attr[] sortAttributes(NamedNodeMap attrs) { |
| 166 | if (attrs == null) { |
| 167 | return new Attr[0]; |
| 168 | } |
| 169 | |
| 170 | int len = attrs.getLength(); |
| 171 | Attr[] array = new Attr[len]; |
| 172 | for (int i = 0; i < len; i++) { |
| 173 | array[i] = (Attr) attrs.item(i); |
| 174 | } |
| 175 | for (int i = 0; i < len - 1; i++) { |
| 176 | String name = array[i].getLocalName(); |
| 177 | int index = i; |
| 178 | for (int j = i + 1; j < len; j++) { |
| 179 | String curName = array[j].getLocalName(); |
| 180 | if (curName.compareTo(name) < 0) { |
| 181 | name = curName; |
| 182 | index = j; |
| 183 | } |
| 184 | } |
| 185 | if (index != i) { |
| 186 | Attr temp = array[i]; |
| 187 | array[i] = array[index]; |
| 188 | array[index] = temp; |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | return array; |
| 193 | } |
| 194 | } |
no test coverage detected