// RFC4918 (WebDav) value used as CR class
collection, //
- // RFC3744 (ACL) properties uase as CR attr
+ // RFC3744 (ACL) properties used as CR attr
owner, //
group, //
+
+ // RFC3253 (versioning) properties used as CR attr
+ checkedOut("checked-out"), //
+ checkedIn("checked-in"), //
//
;
public final static String WEBDAV_NAMESPACE_URI = "DAV:";
public final static String WEBDAV_DEFAULT_PREFIX = "D";
+ private final String localName;
+
+ private DName(String localName) {
+ assert localName != null;
+ this.localName = localName;
+ }
+
+ private DName() {
+ this.localName = null;
+ }
+
+ @Override
+ public String localName() {
+ if (localName != null)
+ return localName;
+ else
+ return name();
+ }
+
@Override
public String getNamespace() {
return WEBDAV_NAMESPACE_URI;
return name();
}
+ /**
+ * A {@link QName} corresponding to this definition. Calls
+ * {@link #createQName()} by default, but it could return a cached value.
+ */
default QName qName() {
- return new ContentName(getNamespace(), localName(), getDefaultPrefix());
+ return createQName();
}
+ /**
+ * A prefixed representation of this qualified name within the provided
+ * {@link NamespaceContext}.
+ */
default String get(NamespaceContext namespaceContext) {
return namespaceContext.getPrefix(getNamespace()) + ":" + localName();
}
- /** This qualified named with its default prefix. If it is unqualified this method should be overridden, or QNamed.Unqualified be used. */
+ /**
+ * Create a {@link QName} corresponding on this definition. Can typically be
+ * used to cache the {@link QName} in enums.
+ */
+ default QName createQName() {
+ return new ContentName(getNamespace(), localName(), getDefaultPrefix());
+ }
+
+ /**
+ * This qualified named with its default prefix. If it is unqualified this
+ * method should be overridden, or QNamed.Unqualified be used.
+ */
default String get() {
return getDefaultPrefix() + ":" + localName();
}
+ /** The namespace URI of this qualified name. */
String getNamespace();
+ /**
+ * The default prefix of this qualified name, as expected to be found in
+ * {@link RuntimeNamespaceContext}.
+ */
String getDefaultPrefix();
+ /** Compares to a plain {@link QName}. */
+ default boolean equals(QName qName) {
+ return qName().equals(qName);
+ }
+
/** To be used by enums without namespace (typically XML attributes). */
static interface Unqualified extends QNamed {
@Override
}
public COMPOSITION eq(QNamed attr, Object value) {
- addConstraint(new Eq(attr.qName(), value));
+ return eq(attr.qName(), value);
+ }
+
+ public COMPOSITION isDefined(QName attr) {
+ addConstraint(new IsDefined(attr));
return composition;
}
+ public COMPOSITION isDefined(QNamed attr) {
+ return isDefined(attr.qName());
+ }
+
/*
* UTILITIES
*/
}
+ public static class IsDefined implements Constraint {
+ final QName prop;
+
+ public IsDefined(QName prop) {
+ super();
+ this.prop = prop;
+ }
+
+ public QName getProp() {
+ return prop;
+ }
+ }
+
public static class IsContentClass implements Constraint {
final QName[] contentClasses;