MCPcopy Create free account
hub / github.com/apache/tomcat / sortAttributes

Method sortAttributes

java/org/apache/catalina/util/DOMWriter.java:165–193  ·  view source on GitHub ↗

Returns a sorted list of attributes. @param attrs The map to sort @return a sorted attribute array

(NamedNodeMap attrs)

Source from the content-addressed store, hash-verified

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}

Callers 1

printMethod · 0.95

Calls 3

getLengthMethod · 0.65
getLocalNameMethod · 0.65
compareToMethod · 0.65

Tested by

no test coverage detected