Changeset 6424


Ignore:
Timestamp:
06/01/10 09:32:35 (9 years ago)
Author:
callan
Message:

Handle very nasty null reference sources and remove System.err logging in favour of slf4j.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/ome-xml/src/ome/xml/r201004/OMEModelImpl.java

    r6183 r6424  
    3030import java.util.Map.Entry; 
    3131 
     32import org.slf4j.Logger; 
     33import org.slf4j.LoggerFactory; 
     34 
    3235/** 
    3336 * @author callan 
     
    4548  private Map<OMEModelObject, List<Reference>> references = 
    4649    new HashMap<OMEModelObject, List<Reference>>(); 
     50 
     51  /** Logger for this class. */ 
     52  private static final Logger LOGGER = 
     53    LoggerFactory.getLogger(OMEModelImpl.class); 
    4754 
    4855  /* (non-Javadoc) 
     
    101108    { 
    102109      OMEModelObject a = entry.getKey(); 
     110      if (a == null) { 
     111        List<Reference> references = entry.getValue(); 
     112        if (references == null) { 
     113          LOGGER.error("Null reference to null object, continuing."); 
     114          continue; 
     115        } 
     116        LOGGER.error("Null reference to {} objects, continuing.", 
     117                     references.size()); 
     118        unhandledReferences += references.size(); 
     119      } 
    103120      for (Reference reference : entry.getValue()) { 
    104121        String referenceID = reference.getID(); 
    105122        OMEModelObject b = getModelObject(referenceID); 
    106123        if (b == null) { 
    107           System.err.println(String.format( 
    108               "%s reference to %s missing from object hierarchy.", 
    109               a, referenceID)); 
     124          LOGGER.warn("{} reference to {} missing from object hierarchy.", 
     125                      a, referenceID); 
    110126          unhandledReferences++; 
    111127          continue; 
Note: See TracChangeset for help on using the changeset viewer.