public void resource()

in src/main/java/org/apache/sling/contentparser/testutils/mapsupport/ContentElementHandler.java [37:63]


    public void resource(String path, Map<String, Object> properties) {
        if (StringUtils.equals(path, "/")) {
            root = new ContentElement(null, properties);
        }
        else {
            if (root == null) {
                throw new ContentElementHandlerException("Root resource not set.");
            }
            Matcher matcher = PATH_PATTERN.matcher(path);
            if (!matcher.matches()) {
                throw new ContentElementHandlerException("Unexpected path:" + path);
            }
            String relativeParentPath = StringUtils.stripStart(matcher.group(1), "/");
            String name = matcher.group(4);
            ContentElement parent;
            if (StringUtils.isEmpty(relativeParentPath)) {
                parent = root;
            }
            else {
                parent = root.getChild(relativeParentPath);
            }
            if (parent == null) {
                throw new ContentElementHandlerException("Parent '" + relativeParentPath + "' does not exist.");
            }
            parent.getChildren().put(name, new ContentElement(name, properties));
        }
    }