import java.io.Closeable;
import java.io.IOException;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
*/
List<QName> getContentClasses();
+ default void addContentClasses(QName... contentClass) {
+ throw new UnsupportedOperationException("Adding content classes to " + getPath() + " is not supported");
+ }
+
/** AND */
default boolean isContentClass(QName... contentClass) {
List<QName> contentClasses = getContentClasses();
return false;
}
+ /*
+ * SIBLINGS
+ */
+
+ default int getSiblingIndex() {
+ return 1;
+ }
+
/*
* DEFAULT METHODS
*/
throw new UnsupportedOperationException("Cannot write content " + this + " as " + clss.getName());
}
+ /*
+ * CHILDREN
+ */
+
+ default boolean hasChild(QName name) {
+ for (Content child : this) {
+ if (child.getName().equals(name))
+ return true;
+ }
+ return false;
+ }
+
+ default Content anyOrAddChild(QName name, QName... classes) {
+ Content child = anyChild(name);
+ if (child != null)
+ return child;
+ return this.add(name, classes);
+ }
+
+ /** Any child with this name, or null if there is none */
+ default Content anyChild(QName name) {
+ for (Content child : this) {
+ if (child.getName().equals(name))
+ return child;
+ }
+ return null;
+ }
+
/*
* CONVENIENCE METHODS
*/