Source code for /engineering/autohit-2003/src/autohit/common/channels/Atom.javaOriginal file Atom.java
   1 /**
   2  * AUTOHIT 2003
   3  * Copyright Erich P Gatejen (c) 1989,1997,2003,2004
   4  * 
   5  * This program is free software; you can redistribute it and/or modify 
   6  * it under the terms of the GNU General Public License as published by 
   7  * the Free Software Foundation; either version 2 of the License, or (at
   8  * your option) any later version.
   9  * This program is distributed in the hope that it will be useful, but
  10  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12  * more details.
  13  * 
  14  * You should have received a copy of the GNU General Public License along
  15  * with this program; if not, write to the Free Software Foundation, Inc.,
  16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  17  *
  18  * Additional license information can be found in the documentation.
  19  * @author Erich P Gatejen
  20  */
  21 package autohit.common.channels;
  22 
  23 import java.io.Serializable;
  24 
  25 /**
  26  * An atom
  27  * @author Erich P. Gatejen
  28  * @version 1.0
  29  * <i>Version History</i>
  30  * <code>EPG - Rewrite - 25Apr03</code> 
  31  * 
  32  */
  33 public class Atom implements Serializable {
  34 
  35 	final static long serialVersionUID = 1;
  36 	
  37 	/**
  38 	 * Type of atom
  39 	 */
  40 	public int type;
  41 
  42 	public static final int TYPE_INVALID = 0;
  43 	public static final int TYPE_GENERIC = 1;
  44 	public static final int TYPE_EVENT = 2;
  45 	public static final int TYPE_LOG = 3;
  46 	public static final int TYPE_CONTROL = 4;
  47 
  48 	/**
  49 	 * time stamp
  50 	 */
  51 	public long stamp;
  52 
  53 	/**
  54 	 * sender ID - optional
  55 	 */
  56 	public String senderID;
  57 
  58 	/**
  59 	 * thing
  60 	 */
  61 	public Object thing;
  62 
  63 	/**
  64 	 * priority - roughly the same as from java.util.logging.Level.  Some aliases are 
  65 	 * provided for convenience.
  66 	 */
  67 	public int priority;
  68 
  69 	public final static int P_NONE = 0;
  70 	public final static int FLASH = 100;
  71 	public final static int P1 = 100;
  72 	public final static int IMMEDIATE = 200;
  73 	public final static int P2 = 200;
  74 	public final static int PRIORITY = 300;
  75 	public final static int P3 = 300;
  76 	public final static int ROUTINE = 400;
  77 	public final static int P4 = 400;
  78 	public final static int DEBUG = 500;
  79 	public final static int P5 = 500;
  80 	public final static int FLOOD = 600;
  81 	public final static int P_ALL = 600;
  82 	public final static int P_TOP = 1000;
  83 
  84 	/**
  85 	 * Numeric
  86 	 */
  87 	public int numeric;
  88 
  89 	/**
  90 	 *  Default constructor.  Default priority of ROUTINE.  Null object.
  91 	 *  Generic type.  Timestamped.
  92 	 */
  93 	public Atom() {
  94 		stamp = System.currentTimeMillis();
  95 		type = TYPE_GENERIC;
  96 		priority = ROUTINE;
  97 		thing = null;
  98 		senderID = null;
  99 	}
 100 
 101 	/**
 102 	 *  Default constructor.  Sets type only.
 103 	 * @param t the type
 104 	 */
 105 	public Atom(int t) {
 106 		type = t;
 107 		senderID = null;
 108 	}
 109 
 110 	/**
 111 	 * Constructor.  Sets everything but ID and timestamps it.
 112 	 * @param t the type
 113 	 * @param p the priority
 114 	 * @param n the numeric
 115 	 * @param o the object
 116 	 */
 117 	public Atom(int t, int p, int n, Object o) {
 118 		stamp = System.currentTimeMillis();
 119 		type = t;
 120 		priority = p;
 121 		thing = o;
 122 		numeric = n;
 123 		senderID = null;
 124 	}
 125 
 126 	/**
 127 	 * Slap a timestamp on it.
 128 	 */
 129 	public void stampit() {
 130 		stamp = System.currentTimeMillis();
 131 	}
 132 
 133 }