package com.dy.common.mw.channel.tcp; 
 | 
  
 | 
public class PrefixedDataAvailableStatus { 
 | 
     
 | 
    public final static Integer status_rubbish = 0 ;//垃圾数据 
 | 
    public final static Integer status_break = 1 ;//断包 
 | 
    public final static Integer status_adjoin = 2 ;//粘包 
 | 
    public final static Integer status_complete = 3 ;//不断不粘 
 | 
     
 | 
    private Integer status ; 
 | 
    private Integer dataLen ; 
 | 
     
 | 
    public PrefixedDataAvailableStatus(){ 
 | 
        status = null ; 
 | 
        dataLen = null ; 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 垃圾数据 
 | 
     * @param dataLen 数据长度 
 | 
     * @return 状态 
 | 
     */ 
 | 
    @SuppressWarnings("unused") 
 | 
    public PrefixedDataAvailableStatus rubbish(Integer dataLen){ 
 | 
        this.status = status_rubbish ; 
 | 
        this.dataLen = dataLen ; 
 | 
        return this ; 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 发生断包 
 | 
     * @return 状态 
 | 
     */ 
 | 
    @SuppressWarnings("unused") 
 | 
    public PrefixedDataAvailableStatus breaked(){ 
 | 
        this.status = status_break ; 
 | 
        this.dataLen = null ; 
 | 
        return this ; 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 发生粘包 
 | 
     * @param dataLen 数据长度 
 | 
     * @return 状态 
 | 
     */ 
 | 
    @SuppressWarnings("unused") 
 | 
    public PrefixedDataAvailableStatus adjoined(Integer dataLen){ 
 | 
        this.status = status_adjoin ; 
 | 
        this.dataLen = dataLen ; 
 | 
        return this ; 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 不断包不粘包,数据正好收全 
 | 
     * @param dataLen 数据长度 
 | 
     * @return 状态 
 | 
     */ 
 | 
    @SuppressWarnings("unused") 
 | 
    public PrefixedDataAvailableStatus completed(Integer dataLen){ 
 | 
        this.status = status_complete ; 
 | 
        this.dataLen = dataLen ; 
 | 
        return this ; 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 是否垃圾数据 
 | 
     * @return 状态 
 | 
     */ 
 | 
    public boolean isRubbish(){ 
 | 
        return this.status.intValue() == status_rubbish.intValue(); 
 | 
    } 
 | 
    /** 
 | 
     * 是否断包 
 | 
     * @return 状态 
 | 
     */ 
 | 
    public boolean isBreaked(){ 
 | 
        return this.status.intValue() == status_break.intValue(); 
 | 
    } 
 | 
     
 | 
     
 | 
    /** 
 | 
     * 是否粘包 
 | 
     * @return 是否粘包 
 | 
     */ 
 | 
    public boolean isAdjoined(){ 
 | 
        return this.status.intValue() == status_adjoin.intValue(); 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 是否不断不粘 
 | 
     * @return 是否不断不粘 
 | 
     */ 
 | 
    public boolean isCompleted(){ 
 | 
        return this.status.intValue() == status_complete.intValue(); 
 | 
    } 
 | 
     
 | 
    /** 
 | 
     * 返回数据长度 
 | 
     * @return 数据长度 
 | 
     */ 
 | 
    public Integer getDataLen(){ 
 | 
        return this.dataLen ; 
 | 
    } 
 | 
     
 | 
} 
 |