X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;ds=inline;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Facr%2FAbstractContent.java;h=18c6724ace740d6a5df99e5cf43e9126cd6c9eaf;hb=4c7e1885b8bf3c93fa0919ace122e3f289a925ea;hp=b614a14cbb0702ef2723bd11e12ee0943adcb2d1;hpb=eb4cc3db3bf141c229f0f7ff929daff108bee6d2;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/acr/AbstractContent.java b/org.argeo.cms/src/org/argeo/cms/acr/AbstractContent.java index b614a14cb..18c6724ac 100644 --- a/org.argeo.cms/src/org/argeo/cms/acr/AbstractContent.java +++ b/org.argeo.cms/src/org/argeo/cms/acr/AbstractContent.java @@ -15,16 +15,22 @@ import javax.xml.namespace.QName; import org.argeo.api.acr.Content; import org.argeo.api.acr.CrName; import org.argeo.api.acr.spi.ProvidedContent; +import org.argeo.api.acr.spi.ProvidedSession; /** Partial reference implementation of a {@link ProvidedContent}. */ public abstract class AbstractContent extends AbstractMap implements ProvidedContent { + private final ProvidedSession session; + + public AbstractContent(ProvidedSession session) { + this.session = session; + } /* * ATTRIBUTES OPERATIONS */ - protected abstract Iterable keys(); - - protected abstract void removeAttr(QName key); +// protected abstract Iterable keys(); +// +// protected abstract void removeAttr(QName key); @Override public Set> entrySet() { @@ -100,6 +106,36 @@ public abstract class AbstractContent extends AbstractMap impleme collectAncestors(ancestors, content.getParent()); } + @Override + public int getDepth() { + List ancestors = new ArrayList<>(); + collectAncestors(ancestors, this); + return ancestors.size(); + } + + @Override + public String getSessionLocalId() { + return getPath(); + } + + /* + * SESSION + */ + + @Override + public ProvidedSession getSession() { + return session; + } + + /* + * TYPING + */ + + @Override + public List getTypes() { + return new ArrayList<>(); + } + /* * UTILITIES */ @@ -113,6 +149,40 @@ public abstract class AbstractContent extends AbstractMap impleme // return "content " + getPath(); // } + /* + * DEFAULTS + */ + // - no children + // - no attributes + // - cannot be modified + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } + + @Override + public Content add(QName name, QName... classes) { + throw new UnsupportedOperationException("Content cannot be added."); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Content cannot be removed."); + } + + protected Iterable keys() { + return Collections.emptySet(); + } + + @Override + public Optional get(QName key, Class clss) { + return null; + } + + protected void removeAttr(QName key) { + throw new UnsupportedOperationException("Attributes cannot be removed."); + } + /* * SUB CLASSES */