psmith      2003/06/24 15:32:52

  Modified:    src/java/org/apache/log4j/chainsaw EventContainer.java
                        ChainsawCyclicBufferTableModel.java
  Log:
  Modifications to allow detection of when a Cyclic style buffer is being
  used.
  
  Revision  Changes    Path
  1.8       +6 -0      
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/EventContainer.java
  
  Index: EventContainer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/EventContainer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- EventContainer.java       17 Jun 2003 20:06:50 -0000      1.7
  +++ EventContainer.java       24 Jun 2003 22:32:52 -0000      1.8
  @@ -74,6 +74,12 @@
     void clearModel();
   
     /**
  +   * Returns true if this model is Cyclic (bounded) or not 
  +   * @return true/false
  +   */
  +  public boolean isCyclic();
  +  
  +  /**
      * Locates a row number, starting from startRow, containing the text
      * within any column
      * @param startRow
  
  
  
  1.17      +24 -2     
jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java
  
  Index: ChainsawCyclicBufferTableModel.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-log4j-sandbox/src/java/org/apache/log4j/chainsaw/ChainsawCyclicBufferTableModel.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ChainsawCyclicBufferTableModel.java       16 Jun 2003 07:24:40 -0000      1.16
  +++ ChainsawCyclicBufferTableModel.java       24 Jun 2003 22:32:52 -0000      1.17
  @@ -86,6 +86,8 @@
    */
   class ChainsawCyclicBufferTableModel extends AbstractTableModel
     implements EventContainer {
  +  private boolean cyclic;
  +  private final int INITIAL_CAPACITY = 1024;
     final List unfilteredList;
     final List filteredList;
     private static final DateFormat DATE_FORMATTER =
  @@ -104,12 +106,13 @@
     int uniqueRow;
   
     public ChainsawCyclicBufferTableModel(boolean isCyclic, int bufferSize) {
  +    this.cyclic = isCyclic;
       if (isCyclic) {
         unfilteredList = new CyclicBufferList(bufferSize);
         filteredList = new CyclicBufferList(bufferSize);
       } else {
  -      unfilteredList = new ArrayList();
  -      filteredList = new ArrayList();
  +      unfilteredList = new ArrayList(INITIAL_CAPACITY);
  +      filteredList = new ArrayList(INITIAL_CAPACITY);
       }
     }
   
  @@ -618,4 +621,23 @@
         notifyCountListeners();
       }
     }
  +  /**
  +   * Returns true if this model is Cyclic (bounded) or not 
  +   * @return true/false
  +   */
  +  public boolean isCyclic() {
  +    return cyclic;
  +  }
  +
  +  /**
  +   * @return
  +   */
  +  protected int getMaxSize() {
  +    if(!isCyclic()){
  +      throw new IllegalStateException("You cannot call getMaxSize() when the model 
is not cyclic");
  +    }
  +    return ((CyclicBufferList)unfilteredList).getMaxSize();
  +  }
  +
  +
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to