001/** 002 * 003 * Copyright the original author or authors 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 java.util.Calendar; 020 021/** 022 * Defines the possible field options for a subscribe options form as defined 023 * by <a href="http://xmpp.org/extensions/xep-0060.html#registrar-formtypes-subscribe">Section 16.4.2</a>. 024 * 025 * @author Robin Collier 026 */ 027public enum SubscribeOptionFields 028{ 029 /** 030 * Whether an entity wants to receive or disable notifications 031 * 032 * <p><b>Value: boolean</b></p> 033 */ 034 deliver, 035 036 /** 037 * Whether an entity wants to receive digests (aggregations) of 038 * notifications or all notifications individually. 039 * 040 * <p><b>Value: boolean</b></p> 041 */ 042 digest, 043 044 /** 045 * The minimum number of seconds between sending any two notifications digests 046 * 047 * <p><b>Value: int</b></p> 048 */ 049 digest_frequency, 050 051 /** 052 * 053 * <p><b>Value: {@link Calendar}</b></p> 054 */ 055 expire, 056 057 /** 058 * Whether an entity wants to receive an XMPP message body in addition to 059 * the payload format. 060 * 061 * <p><b>Value: boolean</b></p> 062 */ 063 include_body, 064 065 /** 066 * The presence states for which an entity wants to receive notifications. 067 * 068 * <p><b>Value: {@link PresenceState}</b></p> 069 */ 070 show_values, 071 072 /** 073 * 074 * 075 * <p><b>Value: </b></p> 076 */ 077 subscription_type, 078 079 /** 080 * 081 * <p><b>Value: </b></p> 082 */ 083 subscription_depth; 084 085 public String getFieldName() 086 { 087 if (this == show_values) 088 return "pubsub#" + toString().replace('_', '-'); 089 return "pubsub#" + toString(); 090 } 091 092 static public SubscribeOptionFields valueOfFromElement(String elementName) 093 { 094 String portion = elementName.substring(elementName.lastIndexOf('#' + 1)); 095 096 if ("show-values".equals(portion)) 097 return show_values; 098 else 099 return valueOf(portion); 100 } 101}