View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2001-2004 Open World Ltd
4   // Copyright (C) 2004 Kevin Rogers
5   //
6   // This file is part of MillScript.
7   //
8   // MillScript is free software; you can redistribute it and/or modify it under
9   // the terms of the GNU General Public License as published by the Free
10  // Software Foundation; either version 2 of the License, or (at your option)
11  // any later version.
12  //
13  // MillScript is distributed in the hope that it will be useful, but WITHOUT
14  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16  // more details.
17  //
18  // You should have received a copy of the GNU General Public License along with
19  // MillScript; if not, write to the Free Software Foundation, Inc., 59 Temple
20  // Place, Suite 330, Boston, MA  02111-1307  USA
21  ////////////////////////////////////////////////////////////////////////////////
22  package org.millscript.commons.alert;
23  
24  /**
25   * This class represents an individual culprit in a mishap. A culprit has a
26   * type and associated value, similar to a key-value pair in a map.
27   */
28  public class Culprit {
29  
30      /**
31       * The type of the culprit.
32       */
33      private final String type;
34  
35      /**
36       * The value of the culprit.
37       */
38      private final Object value;
39  
40      /**
41       * Creates a new culprit, with the specified type and value.
42       *
43       * @param   a   the culprit type
44       * @param   b   the culprit value
45       */
46      public Culprit( final String a, final Object b ) {
47          this.type = a;
48          this.value = b;
49      }
50  
51      /**
52       * Returns this culprits type.
53       *
54       * @return  this culprits type
55       */
56      public String getType() {
57          return type;
58      }
59  
60      /**
61       * Returns this culprits value.
62       *
63       * @return  this culprits value
64       */
65      public Object getValue() {
66          return value;
67      }
68  
69      /**
70       * @see java.lang.Object#toString()
71       */
72      @Override
73      public String toString() {
74          final StringBuffer buff = new StringBuffer( this.type.toUpperCase() );
75          buff.append( " : " );
76          // TODO - This needs to be kept short depending on the output target.
77          // This used to be done in MillScript using it's Output class.
78          buff.append( this.value );
79          return buff.toString();
80      }
81  
82  }