]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.api/src/org/argeo/api/gcr/Content.java
1 package org
.argeo
.api
.gcr
;
6 * A semi-structured content, with attributes, within a hierarchical structure.
8 public interface Content
extends Iterable
<Content
>, Map
<String
, Object
> {
12 // Iterable<String> keys();
14 <A
> A
get(String key
, Class
<A
> clss
) throws IllegalArgumentException
;
16 // ContentSession getSession();
21 default <A
> A
adapt(Class
<A
> clss
) throws IllegalArgumentException
{
22 throw new IllegalArgumentException("Cannot adapt content " + this + " to " + clss
.getName());
25 default <C
extends AutoCloseable
> C
open(Class
<C
> clss
) throws Exception
, IllegalArgumentException
{
26 throw new IllegalArgumentException("Cannot open content " + this + " as " + clss
.getName());
32 default String
attr(String key
) {
33 return get(key
, String
.class);
36 default String
attr(Object key
) {
37 return key
!= null ?
attr(key
.toString()) : attr(null);
40 default <A
> A
get(Object key
, Class
<A
> clss
) {
41 return key
!= null ?
get(key
.toString(), clss
) : get(null, clss
);
45 * EXPERIMENTAL UNSUPPORTED
47 default boolean hasText() {
51 default String
getText() {
52 throw new UnsupportedOperationException();