View Javadoc
1   /*
2    * Licensed under the GPL License. You may not use this file except in compliance with the License.
3    * You may obtain a copy of the License at
4    *
5    *   https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
6    *
7    * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
8    * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
9    * PURPOSE.
10   */
11  package psiprobe.tools.logging.jdk;
12  
13  import java.io.File;
14  
15  import psiprobe.tools.Instruments;
16  
17  /**
18   * JDK 1.4 Logging File Handler Accessor Class.
19   */
20  public class Jdk14FileHandlerAccessor extends Jdk14HandlerAccessor {
21  
22    /** The Constant LATEST_FILE_INDEX. */
23    private static final int LATEST_FILE_INDEX = 0;
24  
25    /**
26     * Currently, we only access the latest log file with index 0.
27     */
28    @Override
29    public File getFile() {
30      File[] files = (File[]) Instruments.getField(getTarget(), "files");
31      if (files == null || files.length == 0) {
32        throw new IllegalStateException("File handler does not manage any files");
33      }
34      return files[LATEST_FILE_INDEX];
35    }
36  
37  }