ServiceStateTest.java
1011 Bytes
package com.bsth;
public class ServiceStateTest {
public static void main(String[] args) {
System.out.println("运营状态:" + getService(603979776));
System.out.println("上下行:" + getUpOrDown(603979776));
}
/**
* 获取运营状态
*
* @return -1无效 0运营 1未运营
*/
public static byte getService(long serviceState) {
if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000)
return -1;
return (byte) (((serviceState & 0x02000000) == 0x02000000) ? 1 : 0);
}
/**
* 王通 2016/6/29 9:23:24 获取车辆线路上下行
*
* @return -1无效 0上行 1下行
*/
public static byte getUpOrDown(long serviceState) {
if ((serviceState & 0x00020000) == 0x00020000 || (serviceState & 0x80000000) == 0x80000000
|| (serviceState & 0x01000000) == 0x01000000 || (serviceState & 0x08000000) == 0x08000000)
return -1;
return (byte) (((serviceState & 0x10000000) == 0x10000000) ? 1 : 0);
}
}