Advertisement
X39

SOFTUO_SettingsNodeCollection

X39
Oct 31st, 2012
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. package x39.Settings;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class SOFTUO_SettingsNodeCollection {
  7.  
  8.     private int _validIndex;
  9.     private int _actualIndex;
  10.     private List<SettingsNode> _list;
  11.    
  12.     protected SOFTUO_SettingsNodeCollection(){
  13.         _validIndex = -1;
  14.         _actualIndex = -1;
  15.         _list = new ArrayList<SettingsNode>();
  16.        
  17.     }
  18.    
  19.     public void up(int i){
  20.         _actualIndex -= i;
  21.         if(_actualIndex < 0 || i < 0)
  22.             _actualIndex = 0;
  23.     }
  24.     public void up(){up(1);}
  25.     public void down(SettingsNode node){
  26.         if(_validIndex > -1)
  27.             _list.get(_actualIndex).addChild(node);
  28.         _actualIndex++;
  29.         _validIndex = _actualIndex;
  30.         if(_list.size() < _validIndex + 1)
  31.             _list.add(node);
  32.         else
  33.             _list.set(_actualIndex, node);
  34.     }
  35.     public boolean down(){
  36.         if(_actualIndex == _validIndex)
  37.             return false;
  38.         _actualIndex--;
  39.         return true;
  40.     }
  41.    
  42.     public SettingsNode getNode(){
  43.         if(_validIndex <= -1)
  44.             return null;
  45.         return _list.get(_actualIndex);
  46.     }
  47.    
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement