public StatementMetric[] flushMetrics(){
  rwLock.acquireWriteLock();
  try {
    boolean isEmpty=false;
    if (currentLastElement == -1) {
      isEmpty=true;
    }
    if (isReportInactive) {
      for (int i=0; i <= currentLastElement; i++) {
        if (statementNames[i] != null) {
          metrics[i]=new StatementMetric(engineURI,statementNames[i]);
        }
      }
    }
    if ((currentLastElement > -1) && (!removedStatementNames.isEmpty())) {
      for (int i=0; i <= currentLastElement; i++) {
        if (removedStatementNames.contains(statementNames[i])) {
          statementNames[i]=null;
        }
      }
    }
    while ((currentLastElement != -1) && (statementNames[currentLastElement] == null)) {
      currentLastElement--;
    }
    if (isEmpty) {
      return null;
    }
    StatementMetric[] newMetrics=new StatementMetric[metrics.length];
    StatementMetric[] oldMetrics=metrics;
    metrics=newMetrics;
    return oldMetrics;
  }
  finally {
    rwLock.releaseWriteLock();
  }
}

public StatementMetric [ ] flushMetrics ( ) { rwLock . acquireWriteLock ( ) ; try { boolean isEmpty = false ; if ( currentLastElement == - 1 ) { isEmpty = true ; } if ( isReportInactive ) { for ( int i = 0 ; i <= currentLastElement ; i ++ ) { if ( statementNames [ i ] != null ) { metrics [ i ] = new StatementMetric ( engineURI , statementNames [ i ] ) ; } } } if ( ( currentLastElement > - 1 ) && ( ! removedStatementNames . isEmpty ( ) ) ) { for ( int i = 0 ; i <= currentLastElement ; i ++ ) { if ( removedStatementNames . contains ( statementNames [ i ] ) ) { statementNames [ i ] = null ; } } } while ( ( currentLastElement != - 1 ) && ( statementNames [ currentLastElement ] == null ) ) { currentLastElement -- ; } if ( isEmpty ) { return null ; } StatementMetric [ ] newMetrics = new StatementMetric [ metrics . length ] ; StatementMetric [ ] oldMetrics = metrics ; metrics = newMetrics ; return oldMetrics ; } finally { rwLock . releaseWriteLock ( ) ; } }
flushes the existing metrics via array copy and swap . < p > may report all statements ( empty and non - empty slots ) and thereby null values . < p > returns null to indicate no reports to do .
