Changeset 3522


Ignore:
Timestamp:
12/28/07 17:48:51 (12 years ago)
Author:
curtis
Message:

Add toString method, for debugging.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/cache/CacheEvent.java

    r3015 r3522  
    2424 
    2525package loci.formats.cache; 
     26 
     27import java.lang.reflect.Field; 
    2628 
    2729/** 
     
    98100  public int getIndex() { return index; } 
    99101 
     102  // -- Object API methods -- 
     103 
     104  public String toString() { 
     105    // scan public fields to determine type name 
     106    String sType = "unknown"; 
     107    Field[] fields = getClass().getFields(); 
     108    for (int i=0; i<fields.length; i++) { 
     109      try { 
     110        if (fields[i].getInt(null) == type) sType = fields[i].getName(); 
     111      } 
     112      catch (IllegalAccessException exc) { } 
     113      catch (IllegalArgumentException exc) { } 
     114    } 
     115    return super.toString() + 
     116      ": source=[" + source + "] type=" + sType + " index=" + index; 
     117  } 
     118 
    100119} 
Note: See TracChangeset for help on using the changeset viewer.