Commit 67a8b968 authored by Ricki Hirner's avatar Ricki Hirner

Add GroupMembership property

parent 40aef8e2
/*
* Copyright © 2013 – 2016 Ricki Hirner (bitfire web engineering).
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*/
package at.bitfire.dav4android.property;
import android.text.TextUtils;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import at.bitfire.dav4android.Constants;
import at.bitfire.dav4android.Property;
import at.bitfire.dav4android.PropertyFactory;
import at.bitfire.dav4android.XmlUtils;
public class GroupMembership implements Property {
public static final Name NAME = new Name(XmlUtils.NS_WEBDAV, "group-membership");
public List<String> hrefs = new LinkedList<>();
@Override
public String toString() {
return "hrefs=[" + TextUtils.join(", ", hrefs) + "]";
}
public static class Factory implements PropertyFactory {
@Override
public Name getName() {
return NAME;
}
@Override
public GroupMembership create(XmlPullParser parser) {
GroupMembership membership = new GroupMembership();
try {
// <!ELEMENT addressbook-home-set (DAV:href*)>
final int depth = parser.getDepth();
int eventType = parser.getEventType();
while (!(eventType == XmlPullParser.END_TAG && parser.getDepth() == depth)) {
if (eventType == XmlPullParser.START_TAG && parser.getDepth() == depth+1 &&
XmlUtils.NS_WEBDAV.equals(parser.getNamespace()) && "href".equals(parser.getName()))
membership.hrefs.add(parser.nextText());
eventType = parser.next();
}
} catch(XmlPullParserException|IOException e) {
Constants.log.error("Couldn't parse <group-membership>", e);
return null;
}
return membership;
}
}
}
......@@ -12,6 +12,7 @@ at.bitfire.dav4android.property.DisplayName$Factory
at.bitfire.dav4android.property.GetContentType$Factory
at.bitfire.dav4android.property.GetCTag$Factory
at.bitfire.dav4android.property.GetETag$Factory
at.bitfire.dav4android.property.GroupMembership$Factory
at.bitfire.dav4android.property.ResourceType$Factory
at.bitfire.dav4android.property.SupportedAddressData$Factory
at.bitfire.dav4android.property.SupportedCalendarComponentSet$Factory
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment