001/* 002 * 003 * Copyright 2015-2025 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 filtered_notifications(Support.recommended), 046 get_pending(Support.optional), 047 instant_nodes(Support.recommended), 048 item_ids(Support.recommended), 049 last_published(Support.recommended), 050 leased_subscription(Support.optional), 051 manage_subscriptions(Support.optional), 052 member_affiliation(Support.recommended), 053 meta_data(Support.recommended), 054 modify_affiliations(Support.optional), 055 multi_collection(Support.optional), 056 multi_items(Support.optional), 057 multi_subscribe(Support.optional), 058 outcast_affiliation(Support.recommended), 059 persistent_items(Support.recommended), 060 presence_notifications(Support.optional), 061 presence_subscribe(Support.recommended), 062 publish(Support.recommended), 063 publish_options(Support.optional), 064 publish_only_affiliation(Support.optional), 065 publisher_affiliation(Support.recommended), 066 publish_node_full(Support.optional), 067 purge_nodes(Support.optional), 068 retract_items(Support.optional), 069 retrieve_affiliations(Support.recommended), 070 retrieve_default(Support.recommended), 071 retrieve_default_sub(Support.optional), 072 retrieve_items(Support.recommended), 073 retrieve_subscriptions(Support.recommended), 074 subscribe(Support.recommended), 075 subscription_options(Support.optional), 076 subscription_notifications(Support.optional), 077 ; 078 079 private final String feature; 080 private final String qualifiedFeature; 081 private final Feature.Support support; 082 083 PubSubFeature(Feature.Support support) { 084 this.feature = name().replace('_', '-'); 085 this.qualifiedFeature = PubSub.NAMESPACE + '#' + this.feature; 086 this.support = support; 087 } 088 089 public String getFeatureName() { 090 return feature; 091 } 092 093 @Override 094 public String toString() { 095 return qualifiedFeature; 096 } 097 098 public Feature.Support support() { 099 return support; 100 } 101 102 @Override 103 public int length() { 104 return qualifiedFeature.length(); 105 } 106 107 @Override 108 public char charAt(int index) { 109 return qualifiedFeature.charAt(index); 110 } 111 112 @Override 113 public CharSequence subSequence(int start, int end) { 114 return qualifiedFeature.subSequence(start, end); 115 } 116 117}