001/**
002 *
003 * Copyright 2015 Florian Schmaus
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.jivesoftware.smackx.pubsub;
018
019import org.jivesoftware.smackx.disco.Feature;
020import org.jivesoftware.smackx.disco.Feature.Support;
021import org.jivesoftware.smackx.pubsub.packet.PubSub;
022
023/**
024 * The features a PubSub service may provides. Some are optional or recommended, while others are required.
025 *
026 * @author Florian Schmaus
027 * @see <a href="http://www.xmpp.org/extensions/xep-0060.html#features">XEP-60 ยง 10</a>
028 *
029 */
030public enum PubSubFeature implements CharSequence {
031
032    access_authorize(Support.optional),
033    access_open(Support.optional),
034    access_presence(Support.optional),
035    access_roster(Support.optional),
036    access_whitelist(Support.optional),
037    auto_create(Support.optional),
038    auto_subscribe(Support.recommended),
039    collections(Support.optional),
040    config_node(Support.recommended),
041    create_and_configure(Support.recommended),
042    create_nodes(Support.recommended),
043    delete_items(Support.recommended),
044    delete_nodes(Support.recommended),
045    get_pending(Support.optional),
046    item_ids(Support.recommended),
047    last_published(Support.recommended),
048    leased_subscription(Support.optional),
049    manage_subscriptions(Support.optional),
050    member_affiliation(Support.recommended),
051    meta_data(Support.recommended),
052    modify_affiliations(Support.optional),
053    multi_collection(Support.optional),
054    multi_subscribe(Support.optional),
055    outcast_affiliation(Support.recommended),
056    persistent_items(Support.recommended),
057    presence_notifications(Support.optional),
058    presence_subscribe(Support.recommended),
059    publish(Support.required),
060    publish_options(Support.optional),
061    publish_only_affiliation(Support.optional),
062    publisher_affiliation(Support.recommended),
063    purge_nodes(Support.optional),
064    retract_items(Support.optional),
065    retrieve_affiliations(Support.recommended),
066    retrieve_default(Support.recommended),
067    retrieve_default_sub(Support.optional),
068    retrieve_items(Support.recommended),
069    retrieve_subscriptions(Support.recommended),
070    subscribe(Support.required),
071    subscription_options(Support.optional),
072    subscriptions_notifications(Support.optional),
073    instant_nodes(Support.recommended),
074    filtered_notifications(Support.recommended),
075    ;
076
077    private final String feature;
078    private final String qualifiedFeature;
079    private final Feature.Support support;
080
081    PubSubFeature(Feature.Support support) {
082        this.feature = name().replace('_', '-');
083        this.qualifiedFeature = PubSub.NAMESPACE + '#' + this.feature;
084        this.support = support;
085    }
086
087    public String getFeatureName() {
088        return feature;
089    }
090
091    @Override
092    public String toString() {
093        return qualifiedFeature;
094    }
095
096    public Feature.Support support() {
097        return support;
098    }
099
100    @Override
101    public int length() {
102        return qualifiedFeature.length();
103    }
104
105    @Override
106    public char charAt(int index) {
107        return qualifiedFeature.charAt(index);
108    }
109
110    @Override
111    public CharSequence subSequence(int start, int end) {
112        return qualifiedFeature.subSequence(start, end);
113    }
114
115}