001/* Base class for data capsules. 002 003 Copyright (c) 1997-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 */ 028package ptolemy.data; 029 030import ptolemy.data.type.BaseType; 031import ptolemy.data.type.Type; 032 033////////////////////////////////////////////////////////////////////////// 034//// EventToken 035 036/** 037 A token representing a pure event. 038 039 @author Steve Neuendorffer 040 @version $Id$ 041 @since Ptolemy II 0.2 042 @Pt.ProposedRating Red (neuendor) 043 @Pt.AcceptedRating Red (neuendor) 044 */ 045public class EventToken extends Token { 046 public EventToken() { 047 } 048 049 /** Override the base class method to check whether the value of this 050 * token is equal to that of the argument. 051 * Since this base token class does not have any state, this method 052 * returns true if the argument is an instance of Token, but not an 053 * instance of a subclass of Token or any other classes. 054 * @param object An instance of Object. 055 * @return True if the argument is an instance of Token, but not an 056 * instance of a subclass of Token or any other classes. 057 */ 058 @Override 059 public boolean equals(Object object) { 060 if (object == null) { 061 return false; 062 } 063 if (object.getClass() == getClass()) { 064 return true; 065 } 066 067 return false; 068 } 069 070 /** Return the type of this token. 071 * @return BaseType.GENERAL 072 */ 073 @Override 074 public Type getType() { 075 return BaseType.EVENT; 076 } 077 078 /** Return a hash code value for this token. Since the equals() method 079 * in this base Token class returns true for all instances of Token, 080 * all instances of Token must have the same hash code. To achieve this, 081 * this method simply returns the value 0. 082 * @return The integer 0. 083 */ 084 @Override 085 public int hashCode() { 086 return 0; 087 } 088 089 /** Return the value of this token as a string that can be parsed 090 * by the expression language to recover a token with the same value. 091 * This method should be overridden by derived classes. 092 * In this base class, return the String "present" to indicate 093 * that an event is present. 094 * @return The String "present". 095 */ 096 @Override 097 public String toString() { 098 return "present"; 099 } 100}