tree.addAttribute(_status, ""+status);
tree.addAttribute(_readable, status >= 200 && status < 400 ? "true" : "false");
tree.addAttribute(_exists, status >= 400 && status < 500 ? "false" : "true");
tree.addAttribute(_uri, uri.toASCIIString());
for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
if ("Last-Modified".equals(node.getAttributeValue(_name))) {
String months[] = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN",
"JUL", "AUG", "SEP", "OCT", "NOV", "DEC" };
String dateStr = node.getAttributeValue(_value);
// dateStr = Fri, 13 Mar 2009 12:12:07 GMT
// 00000000001111111111222222222
// 01234567890123456789012345678
//System.err.println("dateStr: " + dateStr);
String dayStr = dateStr.substring(5,7);
String monthStr = dateStr.substring(8,11).toUpperCase();
String yearStr = dateStr.substring(12,16);
String timeStr = dateStr.substring(17,25);
String tzStr = dateStr.substring(26,29);
int month = 0;
for (month = 0; month < 12; month++) {
if (months[month].equals(monthStr)) {
break;
}
}
tree.addAttribute(_last_modified, String.format("%1$04d-%2$02d-%3$02dT%4$s%5$s",
Integer.parseInt(yearStr), month+1, Integer.parseInt(dayStr), timeStr,
"GMT".equals(tzStr) ? "Z" : ""));
}
if ("Content-Length".equals(node.getAttributeValue(_name))) {
tree.addAttribute(_size, node.getAttributeValue(_value));
}
}
tree.startContent();
for (XdmNode node : new AxisNodes(result, Axis.CHILD, AxisNodes.SIGNIFICANT)) {
tree.addSubtree(node);
}
tree.addEndElement();
}