1 /** 2 * All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); 3 * you may not use this file except in compliance with the License. 4 * You may obtain a copy of the License at 5 * 6 * http://www.apache.org/licenses/LICENSE-2.0 7 * 8 * Unless required by applicable law or agreed to in writing, software 9 * distributed under the License is distributed on an "AS IS" BASIS, 10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 * See the License for the specific language governing permissions and 12 * limitations under the License. 13 */ 14 package org.jivesoftware.smackx.pubsub; 15 16 import java.util.Calendar; 17 18 /** 19 * Defines the possible field options for a subscribe options form as defined 20 * by <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-subscribe">Section 16.4.2</a>. 21 * 22 * @author Robin Collier 23 */ 24 public enum SubscribeOptionFields 25 { 26 /** 27 * Whether an entity wants to receive or disable notifications 28 * 29 * <p><b>Value: boolean</b></p> 30 */ 31 deliver, 32 33 /** 34 * Whether an entity wants to receive digests (aggregations) of 35 * notifications or all notifications individually. 36 * 37 * <p><b>Value: boolean</b></p> 38 */ 39 digest, 40 41 /** 42 * The minimum number of seconds between sending any two notifications digests 43 * 44 * <p><b>Value: int</b></p> 45 */ 46 digest_frequency, 47 48 /** 49 * The DateTime at which a leased subsscription will end ro has ended. 50 * 51 * <p><b>Value: {@link Calendar}</b></p> 52 */ 53 expire, 54 55 /** 56 * Whether an entity wants to receive an XMPP message body in addition to 57 * the payload format. 58 * 59 * <p><b>Value: boolean</b></p> 60 */ 61 include_body, 62 63 /** 64 * The presence states for which an entity wants to receive notifications. 65 * 66 * <p><b>Value: {@link PresenceState}</b></p> 67 */ 68 show_values, 69 70 /** 71 * 72 * 73 * <p><b>Value: </b></p> 74 */ 75 subscription_type, 76 77 /** 78 * 79 * <p><b>Value: </b></p> 80 */ 81 subscription_depth; 82 getFieldName()83 public String getFieldName() 84 { 85 if (this == show_values) 86 return "pubsub#" + toString().replace('_', '-'); 87 return "pubsub#" + toString(); 88 } 89 valueOfFromElement(String elementName)90 static public SubscribeOptionFields valueOfFromElement(String elementName) 91 { 92 String portion = elementName.substring(elementName.lastIndexOf('#' + 1)); 93 94 if ("show-values".equals(portion)) 95 return show_values; 96 else 97 return valueOf(portion); 98 } 99 } 100