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.jingle.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 <alvaro.saurin@gmail.com>
026 */
027public abstract class ContentInfo {
028
029    /**
030     * Audio content info messages.
031     *
032     * @author Alvaro Saurin <alvaro.saurin@gmail.com>
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        public String toString() {
053            return value;
054        }
055
056        /**
057         * Returns the MediaInfo constant associated with the String value.
058         */
059        public static ContentInfo fromString(String value) {
060            value = value.toLowerCase(Locale.US);
061            if (value.equals("busy")) {
062                return BUSY;
063            } else if (value.equals("hold")) {
064                return HOLD;
065            } else if (value.equals("mute")) {
066                return MUTE;
067            } else if (value.equals("queued")) {
068                return QUEUED;
069            } else if (value.equals("ringing")) {
070                return RINGING;
071            } else {
072                return null;
073            }
074        }
075    }
076}