protected static final Logger LOG = Logger.getLogger(LinkParser.class.getName());
public static Resource parseTree(String linkFormat) {
Pattern DELIMITER = Pattern.compile("\\s*,+\\s*");
Resource root = new ResourceBase("");
if (linkFormat!=null) {
Scanner scanner = new Scanner(linkFormat);
String path = null;
while ((path = scanner.findInLine("</[^>]*>")) != null) {
// Trim </...>
path = path.substring(2, path.length() - 1);
LOG.finer(String.format("Parsing link resource: %s", path));
// Retrieve specified resource, create if necessary
Resource resource = new ResourceBase(path);
// Read link format attributes
LinkAttribute attr = null;
while (scanner.findWithinHorizon(DELIMITER, 1)==null && (attr = LinkAttribute.parse(scanner))!=null) {
resource.getAttributes().addAttribute(attr.getName(), attr.getValue());
}
root.add(resource);
}
}