sb.append(" ");
}
String prefix = sb.toString();
- out.println(prefix + content.getName());
- for (QName key : content.keySet()) {
- out.println(prefix + " " + key + "=" + content.get(key));
- }
+ String txt = "";
if (printText) {
if (content.hasText()) {
- out.println("<![CDATA[" + content.getText().trim() + "]]>");
+ final int MAX_LENGTH = 64;
+ txt = content.getText().trim();
+ if (txt.length() > MAX_LENGTH)
+ txt = txt.substring(0, 64) + " ...";
+ txt = " : " + txt;
}
}
+ out.println(prefix + content.getName() + txt);
+ for (QName key : content.keySet()) {
+ out.println(prefix + " " + key + "=" + content.get(key));
+ }
}
// public static <T> boolean isString(T t) {
throw new IllegalArgumentException("Path " + path + " contains //");
}
+ /** The last element of a path. */
+ public static String lastPathElement(String path) {
+ if (path.charAt(path.length() - 1) == '/')
+ throw new IllegalArgumentException("Path " + path + " cannot end with '/'");
+ int index = path.lastIndexOf('/');
+ if (index < 0)
+ return path;
+ return path.substring(index + 1);
+ }
+
/*
* DIRECTORY
*/