List<String> resultList = new ArrayList<String>();
String[] original = super.getHeaderValues(headerName);
for (int i = 0; i < original.length; i++) {
String current = original[i];
resultList.add(current);
AcceptHeaderEntry headerEntry;
try {
headerEntry = new AcceptHeaderEntry(current);
} catch (InvalidPatternException e) {
log.warn(e.toString());
continue;
}
MediaRange range = headerEntry.getRange();
if (range.getAsterixCount() > 0) {
continue;
}
StringBuffer buffer = new StringBuffer(40);
buffer.append("application/xml; stylesheet=");
try {
buffer.append(URLEncoder.encode(range.toString(), "utf-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
buffer.append("; q=");
buffer.append(headerEntry.getQ() * 0.9f);
resultList.add(buffer.toString());
}
return resultList.toArray(new String[resultList.size()]);
} else {
return super.getHeaderValues(headerName);