⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventtype.java

📁 关于 RFID 读写器的相关内容
💻 JAVA
字号:
/*
 * Copyright (C) 2007 ETH Zurich
 *
 * This file is part of Fosstrak (www.fosstrak.org).
 *
 * Fosstrak is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software Foundation.
 *
 * Fosstrak is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Fosstrak; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

package org.fosstrak.reader.rprm.core;

import java.lang.reflect.Field;
import java.util.Vector;

/**
 * This class contains all events that occur in the reader protocol.
 * @author Markus Vitalini
 */
public final class EventType {

   /**
    * The constructor of the EventType. It is private because EventType is a
    * utility class.
    */
   private EventType() {

   }

   // event types

   /**
    * evGlimpsed.
    */
   public static final String EV_GLIMPSED = "evGlimpsed";

   /**
    * evNew.
    */
   public static final String EV_NEW = "evNew";

   /**
    * evUnknown.
    */
   public static final String EV_UNKNOWN = "evUnknown";

   /**
    * evObserved.
    */
   public static final String EV_OBSERVED = "evObserved";

   /**
    * evLost.
    */
   public static final String EV_LOST = "evLost";

   /**
    * evPurged.
    */
   public static final String EV_PURGED = "evPurged";

   // states

   /**
    * isUnknown.
    */
   public static final String ST_IS_UNKNOWN = "isUnknown";

   /**
    * isObserved.
    */
   public static final String ST_IS_OBSERVED = "isObserved";

   /**
    * isLost.
    */
   public static final String ST_IS_LOST = "isLost";

   /**
    * isGlimpsed.
    */
   public static final String ST_IS_GLIMPSED = "isGlimpsed";

   /**
    * Returns all supported event types.
    * @return A Vector with all supported event types
    */
   public static Vector getSupportedTypes() {

      Vector supportedEventTypes = new Vector();

      Class c = EventType.class;
      Field[] fields = c.getFields();

      String fieldName;
      Field tempField;
      String tempString;

      for (int i = 0; i < fields.length; i++) {

         try {
            fieldName = fields[i].getName();
            tempField = c.getField(fieldName);
            tempString = (String) tempField.get(c);
            supportedEventTypes.add(tempString);
         } catch (Exception e) {
            supportedEventTypes = new Vector();
            return supportedEventTypes;
         }

      }

      return supportedEventTypes;

   }

   /**
    * Checks if a event type is contained in this class.
    * @param type
    *           The event type to check
    * @return 'ture' if the event type is in this class, otherwise 'false'
    */
   public static boolean contains(final String type) {
      
      Class c = EventType.class;
      Field[] fields = c.getFields();

      String fieldName;
      Field tempField;
      String tempString;

      for (int i = 0; i < fields.length; i++) {

         try {
            fieldName = fields[i].getName();
            tempField = c.getField(fieldName);
            tempString = (String) tempField.get(c);
            if (tempString.toUpperCase().equals(type.toUpperCase())) {
               return true;
            }
         } catch (Exception e) {
            return false;
         }

      }

      return false;

   }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -