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        public static ContentInfo fromString(String value) {
061            value = value.toLowerCase(Locale.US);
062            if (value.equals("busy")) {
063                return BUSY;
064            } else if (value.equals("hold")) {
065                return HOLD;
066            } else if (value.equals("mute")) {
067                return MUTE;
068            } else if (value.equals("queued")) {
069                return QUEUED;
070            } else if (value.equals("ringing")) {
071                return RINGING;
072            } else {
073                return null;
074            }
075        }
076    }
077}