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.jingleold; 018 019/** 020 * The "action" in the jingle packet, as an enum. 021 * 022 * Changed to reflect XEP-166 rev: 20JUN07 023 * 024 * @author Jeff Williams 025 */ 026public enum JingleActionEnum { 027 028 UNKNOWN("unknown"), 029 CONTENT_ACCEPT("content-accept"), 030 CONTENT_ADD("content-add"), 031 CONTENT_MODIFY("content-modify"), 032 CONTENT_REMOVE("content-remove"), 033 SESSION_ACCEPT("session-accept"), 034 SESSION_INFO("session-info"), 035 SESSION_INITIATE("session-initiate"), 036 SESSION_TERMINATE("session-terminate"), 037 TRANSPORT_INFO("transport-info"); 038 039 private final String actionCode; 040 041 JingleActionEnum(String inActionCode) { 042 actionCode = inActionCode; 043 } 044 045 /** 046 * Returns the String value for an Action. 047 */ 048 049 @Override 050 public String toString() { 051 return actionCode; 052 } 053 054 /** 055 * Returns the Action enum for a String action value. 056 * 057 * @param inActionCode the action code. 058 * @return the jingle action. 059 */ 060 public static JingleActionEnum getAction(String inActionCode) { 061 for (JingleActionEnum jingleAction : JingleActionEnum.values()) { 062 if (jingleAction.actionCode.equals(inActionCode)) { 063 return jingleAction; 064 } 065 } 066 return null; 067 } 068 069}