Android Open Source - senhancelib Boolean Properties






From Project

Back to project page senhancelib.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project senhancelib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * /*  www  .j  ava2s . co  m*/
 */
package de.uos.nbp;

import java.util.HashMap;

/**
 * This is very simple. Just used to store simple boolean
 * values against some form of key.
 * 
 * Used because a raw hash map requires testing for key existence
 * and then testing for boolean value, which clutters code.
 * 
 * A BooleanProperty can have 3 states: true, false or undefined.
 * 
 * TODO: Is this the best way to do this, actually?
 * 
 * @author rmuil
 *
 */
public class BooleanProperties<T> extends HashMap<T, Boolean> {

  private static final long serialVersionUID = 2858090367270077089L;
  
  /**
   * Returns true if and only if the provided key is present AND true.
   * @param key
   * @return true iff key is present AND true
   */
  public boolean isTrue (T key) {
    boolean retVal = false;
    
    if (this.containsKey(key) &&
      this.get(key)) {
      retVal = true;
    }
    return retVal;
  }
  
  /**
   * Returns true if and only if the provided key is present AND false.
   * @param key
   * @return true iff key is present AND false
   */
  public boolean isFalse (T key) {
    boolean retVal = false;
    
    if (this.containsKey(key) &&
      !this.get(key)) {
      retVal = true;
    }
    return retVal;
  }
  
  /**
   * Returns true if and only the provided key has not been set (is not present).
   * @param key
   * @return true iff key is absent
   */
  public boolean isUndefined (T key) {
    return !this.containsKey(key);
  }
}




Java Source Code List

de.uos.nbp.BooleanProperties.java
de.uos.nbp.Utils.java
de.uos.nbp.senhance.DataLogger.java
de.uos.nbp.senhance.ECGCsvReader.java
de.uos.nbp.senhance.EventLoggingActivity.java
de.uos.nbp.senhance.EventSequenceAdapter.java
de.uos.nbp.senhance.EventTag.java
de.uos.nbp.senhance.LoggerApplication.java
de.uos.nbp.senhance.SDLogger.java
de.uos.nbp.senhance.bluetooth.BluetoothPacketConnection.java
de.uos.nbp.senhance.bluetooth.BluetoothService.java
de.uos.nbp.senhance.bluetooth.DeviceListActivity.java
de.uos.nbp.senhance.bluetooth.FramedPacketConnection.java
de.uos.nbp.senhance.bluetooth.PacketConnectionHandler.java
de.uos.nbp.senhance.bluetooth.PacketConnection.java
de.uos.nbp.senhance.datasource.ControlSource.java
de.uos.nbp.senhance.datasource.DataSink.java
de.uos.nbp.senhance.datasource.DataSourceBase.java
de.uos.nbp.senhance.datasource.DataSource.java
de.uos.nbp.senhance.datasource.DummySourceThread.java