FileDocCategorySizeDatePackage
SaturatedMode.javaAPI DocAzureus 3.0.3.43985Mon Jul 30 21:09:18 BST 2007com.aelitis.azureus.core.speedmanager.impl.v2

SaturatedMode

public class SaturatedMode extends Object implements Comparable
Created on May 21, 2007 Created by Alan Snyder Copyright (C) 2007 Aelitis, All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AELITIS, SAS au capital de 63.529,40 euros 8 Allee Lenotre, La Grille Royale, 78600 Le Mesnil le Roi, France.

Fields Summary
public static final SaturatedMode
AT_LIMIT
public static final SaturatedMode
HIGH
public static final SaturatedMode
MED
public static final SaturatedMode
LOW
public static final SaturatedMode
NONE
private final String
name
private final float
percentCapacity
Constructors Summary
private SaturatedMode(String _name, float _percent)


         
        name = _name;
        percentCapacity = _percent;
    
Methods Summary
public intcompareTo(com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedMode satMode)

param
satMode the SaturatedMode to be compared.
return
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.


        if( percentCapacity < satMode.getThreshold() ){
            return -1;
        }
        else if( percentCapacity > satMode.getThreshold() ){
            return +1;
        }

        return 0;
    
public intcompareTo(java.lang.Object obj)

param
obj the Object to be compared.
return
a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
throws
ClassCastException if the specified object's type prevents it from being compared to this Object.


        if( !(obj instanceof SaturatedMode) ){
            throw new ClassCastException("Only comparable to SaturatedMode class.");
        }
        SaturatedMode casted = (SaturatedMode) obj;
        return compareTo(casted);
    
public static com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedModegetSaturatedMode(int currentRate, int limit)
From the currentRate and limit determine the mode.

param
currentRate -
param
limit -
return
- SaturatedMode


        //unlimited mode has this value as zero.
        if(limit==0){
            //put a value in so it will not stay in downloading mode.
            limit = SMConst.START_DOWNLOAD_RATE_MAX;    
        }

        float percent = (float)currentRate/(float)limit;

        if( percent > AT_LIMIT.getThreshold() ){
            return AT_LIMIT;
        }
        else if( percent > HIGH.getThreshold() ){
            return HIGH;
        }
        else if( percent > MED.getThreshold() ){
            return MED;
        }
        else if( percent > LOW.getThreshold() ){
            return LOW;
        }

        return NONE;
    
private floatgetThreshold()

        return percentCapacity;
    
public booleanisGreater(com.aelitis.azureus.core.speedmanager.impl.v2.SaturatedMode mode)

param
mode
return

        if( this.compareTo(mode)>0 ){
            return true;
        }
        return false;
    
public java.lang.StringtoString()

        return name;