AdHocCommandNote.java

  1. /**
  2.  *
  3.  * Copyright 2005-2007 Jive Software.
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.jivesoftware.smackx.commands;

  18. /**
  19.  * Notes can be added to a command execution response. A note has a type and value.
  20.  *
  21.  * @author Gabriel Guardincerri
  22.  */
  23. public class AdHocCommandNote {

  24.     private Type type;
  25.     private String value;

  26.     /**
  27.      * Creates a new adhoc command note with the specified type and value.
  28.      *
  29.      * @param type the type of the note.
  30.      * @param value the value of the note.
  31.      */
  32.     public AdHocCommandNote(Type type, String value) {
  33.         this.type = type;
  34.         this.value = value;
  35.     }

  36.     /**
  37.      * Returns the value or message of the note.
  38.      *
  39.      * @return the value or message of the note.
  40.      */
  41.     public String getValue() {
  42.         return value;
  43.     }

  44.     /**
  45.      * Return the type of the note.
  46.      *
  47.      * @return the type of the note.
  48.      */
  49.     public Type getType() {
  50.         return type;
  51.     }

  52.     /**
  53.      * Represents a note type.
  54.      */
  55.     public enum Type {

  56.         /**
  57.          * The note is informational only. This is not really an exceptional
  58.          * condition.
  59.          */
  60.         info,

  61.         /**
  62.          * The note indicates a warning. Possibly due to illogical (yet valid)
  63.          * data.
  64.          */
  65.         warn,

  66.         /**
  67.          * The note indicates an error. The text should indicate the reason for
  68.          * the error.
  69.          */
  70.         error
  71.     }

  72. }