001/** 002 * 003 * Copyright 2003-2006 Jive Software. 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.media; 018 019import java.util.Locale; 020 021/** 022 * Content info. Content info messages are complementary messages that can be 023 * transmitted for informing of events like "busy", "ringtone", etc. 024 * 025 * @author Alvaro Saurin 026 */ 027public abstract class ContentInfo { 028 029 /** 030 * Audio content info messages. 031 * 032 * @author Alvaro Saurin 033 */ 034 public static class Audio extends ContentInfo { 035 036 public static final ContentInfo.Audio BUSY = new ContentInfo.Audio("busy"); 037 038 public static final ContentInfo.Audio HOLD = new ContentInfo.Audio("hold"); 039 040 public static final ContentInfo.Audio MUTE = new ContentInfo.Audio("mute"); 041 042 public static final ContentInfo.Audio QUEUED = new ContentInfo.Audio("queued"); 043 044 public static final ContentInfo.Audio RINGING = new ContentInfo.Audio("ringing"); 045 046 private String value; 047 048 public Audio(String value) { 049 this.value = value; 050 } 051 052 @Override 053 public String toString() { 054 return value; 055 } 056 057 /** 058 * Returns the MediaInfo constant associated with the String value. 059 * 060 * @param value the input string. 061 * @return the content info. 062 */ 063 public static ContentInfo fromString(String value) { 064 value = value.toLowerCase(Locale.US); 065 if (value.equals("busy")) { 066 return BUSY; 067 } else if (value.equals("hold")) { 068 return HOLD; 069 } else if (value.equals("mute")) { 070 return MUTE; 071 } else if (value.equals("queued")) { 072 return QUEUED; 073 } else if (value.equals("ringing")) { 074 return RINGING; 075 } else { 076 return null; 077 } 078 } 079 } 080}