X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.api.acr%2Fsrc%2Forg%2Fargeo%2Fapi%2Facr%2FContent.java;h=4956037c8ab268dfc38e101681337e4353bce477;hb=54098df1bc3ba263dd1e3290aafa880d54d96805;hp=f52ab31b8f25223e109b4781707502f924cd5ebd;hpb=f3cb3bed85cb528d919193ce6abb2bb8d05faf03;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.api.acr/src/org/argeo/api/acr/Content.java b/org.argeo.api.acr/src/org/argeo/api/acr/Content.java index f52ab31b8..4956037c8 100644 --- a/org.argeo.api.acr/src/org/argeo/api/acr/Content.java +++ b/org.argeo.api.acr/src/org/argeo/api/acr/Content.java @@ -82,25 +82,11 @@ public interface Content extends Iterable, Map { } List res = getMultiple(key, type); return res; -// if (res == null) -// return null; -// else { -// if (res.isEmpty()) -// throw new IllegalStateException("Metadata " + key + " is not availabel as list of type " + type); -// return res.get(); -// } } /* * CONTENT OPERATIONS */ -// default CompletionStage edit(Consumer work) { -// return CompletableFuture.supplyAsync(() -> { -// work.accept(this); -// return this; -// }).minimalCompletionStage(); -// } - Content add(QName name, QName... classes); default Content add(String name, QName... classes) { @@ -242,6 +228,14 @@ public interface Content extends Iterable, Map { /* * ATTR AS STRING */ + /** + * Convenience method returning an attribute as a {@link String}. + * + * @param key the attribute name + * @return the attribute value as a {@link String} or null. + * + * @see Object#toString() + */ default String attr(QName key) { // TODO check String type? Object obj = get(key); @@ -250,21 +244,39 @@ public interface Content extends Iterable, Map { return obj.toString(); } + /** + * Convenience method returning an attribute as a {@link String}. + * + * @param key the attribute name + * @return the attribute value as a {@link String} or null. + * + * @see Object#toString() + */ default String attr(QNamed key) { return attr(key.qName()); } + /** + * Convenience method returning an attribute as a {@link String}. + * + * @param key the attribute name + * @return the attribute value as a {@link String} or null. + * + * @see Object#toString() + */ default String attr(String key) { return attr(unqualified(key)); } -// -// default String attr(Object key) { -// return key != null ? attr(key.toString()) : attr(null); -// } -// -// default A get(Object key, Class clss) { -// return key != null ? get(key.toString(), clss) : get(null, clss); -// } + + /* + * CONTEXT + */ + /** + * A content within this repository + * + * @param path either an abolute path or a path relative to this content + */ + Content getContent(String path); /* * EXPERIMENTAL UNSUPPORTED