Android Open Source - lifx-wear-test L F X Target






From Project

Back to project page lifx-wear-test.

License

The source code is released under:

Apache License

If you think the Android project lifx-wear-test 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

//
//  LFXTarget.java
//  LIFX/*from  ww  w .  j  a  v a2  s  . co m*/
//
//  Created by Jarrod Boyes on 24/03/14.
//  Copyright (c) 2014 LIFX Labs. All rights reserved.
//

package lifx.java.android.entities.internal;

public class LFXTarget
{
  public enum LFXTargetType
  {
    BROADCAST,
    DEVICE,
    TAG,
  };
  
  private LFXTargetType targetType;
  private String deviceID;
  private String tag;

  public LFXTargetType getTargetType()
  {
    return targetType;
  }
  
  public String getTag()
  {
    return tag;
  }
  
  public String getDeviceID()
  {
    return deviceID;
  }
  
  public static LFXTarget getBroadcastTarget()
  {
    LFXTarget target = new LFXTarget();
    target.targetType = LFXTargetType.BROADCAST;
    return target;
  }

  public static LFXTarget getDeviceTargetWithDeviceID( String deviceID)
  {
    LFXTarget target = new LFXTarget();
    target.targetType = LFXTargetType.DEVICE;
    target.deviceID = deviceID;
    return target;
  }

  public static LFXTarget getTagTargetWithTag( String tag)
  {
    LFXTarget target = new LFXTarget();
    target.targetType = LFXTargetType.TAG;
    target.tag = tag;
    return target;
  }

  public String toString()
  {
    return "" + getStringValue();
  }

  public String getStringValue()
  {
    switch( targetType)
    {
      case BROADCAST:
        return "*";
      case TAG:
        return "#" + tag;
      case DEVICE:
        return deviceID;
    }
    
    return "Unknown Target Type";
  }

  public static LFXTarget getTargetWithString( String stringValue)
  {  
    if( stringValue.contains( "*"))
    {
      return getBroadcastTarget();
    }
    
    if( stringValue.contains( "#"))
    {
      String tagString = stringValue.substring( stringValue.indexOf( '#') + 1);
      return getTagTargetWithTag( tagString);
    }
    else
    {
      return getDeviceTargetWithDeviceID( stringValue);
    }
  }

  public boolean equals( LFXTarget aTarget)
  {
    if( aTarget == null)
    {
      return false;
    }
    
    if( this.targetType != aTarget.targetType)
    {
      return false;
    }
    
    switch( targetType)
    {
      case BROADCAST:
        return true;
      case DEVICE:
        return deviceID.equals( aTarget.deviceID);
      case TAG:
        return tag.equals( aTarget.tag);
    }
    
    return false;
  }
}




Java Source Code List

de.dp.lifxtest.app.LightsFragment.java
de.dp.lifxtest.app.MasterActivity.java
lifx.java.android.client.LFXClient.java
lifx.java.android.constant.LFXSDKConstants.java
lifx.java.android.entities.LFXHSBKColor.java
lifx.java.android.entities.LFXLightTarget.java
lifx.java.android.entities.LFXTypes.java
lifx.java.android.entities.internal.LFXBinaryPath.java
lifx.java.android.entities.internal.LFXBinaryTargetID.java
lifx.java.android.entities.internal.LFXBinaryTypes.java
lifx.java.android.entities.internal.LFXDeviceMapping.java
lifx.java.android.entities.internal.LFXGatewayDescriptor.java
lifx.java.android.entities.internal.LFXMessageObservationDescriptor.java
lifx.java.android.entities.internal.LFXMessage.java
lifx.java.android.entities.internal.LFXSiteID.java
lifx.java.android.entities.internal.LFXTagMapping.java
lifx.java.android.entities.internal.LFXTarget.java
lifx.java.android.entities.internal.structle.LxProtocolDevice.java
lifx.java.android.entities.internal.structle.LxProtocolLight.java
lifx.java.android.entities.internal.structle.LxProtocolSensor.java
lifx.java.android.entities.internal.structle.LxProtocolWan.java
lifx.java.android.entities.internal.structle.LxProtocolWifi.java
lifx.java.android.entities.internal.structle.LxProtocol.java
lifx.java.android.entities.internal.structle.Lx.java
lifx.java.android.entities.internal.structle.StructleTypes.java
lifx.java.android.internal.LFXWiFiObserver.java
lifx.java.android.light.LFXLightCollection.java
lifx.java.android.light.LFXLight.java
lifx.java.android.light.LFXTaggedLightCollection.java
lifx.java.android.light.internal.LFXAllLightsCollection.java
lifx.java.android.network_context.LFXNetworkContext.java
lifx.java.android.network_context.internal.routing_table.LFXRoutingTable.java
lifx.java.android.network_context.internal.transport_manager.LFXTransportManager.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXGatewayConnection.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXSocketGeneric.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXSocketTCP.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXSocketUDP.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXTCPGatewayConnection.java
lifx.java.android.network_context.internal.transport_manager.gateway_connection.LFXUDPGatewayConnection.java
lifx.java.android.network_context.internal.transport_manager.lan.LFXLANTransportManager.java
lifx.java.android.network_context.internal.transport_manager.lan.gateway_discovery.LFXGatewayDiscoveryController.java
lifx.java.android.network_context.internal.transport_manager.lan.gateway_discovery.LFXGatewayDiscoveryTableEntry.java
lifx.java.android.util.LFXByteUtils.java
lifx.java.android.util.LFXLog.java
lifx.java.android.util.LFXNetworkUtils.java
lifx.java.android.util.LFXTimerUtils.java