* ServiceExceptions with codes get bumped to the top of the list.
*/
List codes = new ArrayList();
List noCodes = new ArrayList();
for (int i = 0; i < value.length; i++) {
ServiceException exception = (ServiceException) value[i].getValue();
if (exception.getCode() != null && exception.getCode().length() != 0 ) {
codes.add(exception);
} else {
noCodes.add(exception);
}
}
/*
* Now chain them.
*/
ServiceException firstException = null;
ServiceException recentException = null;
for (int i = 0; i < codes.size(); i++) {
ServiceException exception = (ServiceException) codes.get(i);
if (firstException == null) {
firstException = exception;
recentException = exception;
} else {
recentException.setNext(exception);
recentException = exception;
}
}
codes = null;
for (int i = 0; i < noCodes.size(); i++) {
ServiceException exception = (ServiceException) noCodes.get(i);
if (firstException == null) {
firstException = exception;
recentException = exception;
} else {
recentException.setNext(exception);