public int compareTo(Package<?, ?> o) {
   int comparison = 0;
   if (this.getId() != null && o.getId() != null) {
     comparison = this.getId().compareTo(o.getId());
   } else {
     if (this.getName() != null && o.getName() != null) {
       comparison = this.getName().compareTo(o.getName());
     }
   }
   return comparison;
 }
 @SuppressWarnings("unchecked")
 public static synchronized void copyDataBase(IDataBase sourceDataBase, IDataBase targetDataBase) {
   Collector.initialize(targetDataBase);
   List<Package> sourcePackages = sourceDataBase.find(Package.class);
   for (Package sourcePackage : sourcePackages) {
     List<Class> sourceClasses = sourcePackage.getChildren();
     for (Class sourceClass : sourceClasses) {
       Collector.collectAccess(sourceClass.getName(), sourceClass.getAccess());
       collectEfferentAndAfferent(sourceClass, sourcePackages);
       List<Class> sourceInnerClasses = sourceClass.getInnerClasses();
       for (Class sourceInnerClass : sourceInnerClasses) {
         Collector.collectInnerClass(sourceInnerClass.getName(), sourceClass.getName());
         Method sourceOuterMethod = sourceClass.getOuterMethod();
         if (sourceOuterMethod != null) {
           Collector.collectOuterClass(
               sourceInnerClass.getName(),
               sourceClass.getName(),
               sourceOuterMethod.getName(),
               sourceOuterMethod.getDescription());
         }
       }
       // Collector.collectSource(sourceClass.getName(), "source");
       List<Method> sourceMethods = sourceClass.getChildren();
       for (Method sourceMethod : sourceMethods) {
         Collector.collectComplexity(
             sourceClass.getName(),
             sourceMethod.getName(),
             sourceMethod.getDescription(),
             sourceMethod.getComplexity());
         Collector.collectAccess(
             sourceClass.getName(),
             sourceMethod.getName(),
             sourceMethod.getDescription(),
             sourceMethod.getAccess());
         List<Line> sourceLines = sourceMethod.getChildren();
         for (Line sourceLine : sourceLines) {
           Collector.collectLine(
               sourceClass.getName(),
               sourceMethod.getName(),
               sourceMethod.getDescription(),
               Integer.valueOf((int) sourceLine.getNumber()));
           for (int i = 0; i < sourceLine.getCounter(); i++) {
             Collector.collectCoverage(
                 sourceClass.getName(),
                 sourceMethod.getName(),
                 sourceMethod.getDescription(),
                 (int) sourceLine.getNumber());
           }
         }
       }
     }
   }
 }
 @SuppressWarnings("unchecked")
 private static synchronized void collectEfferentAndAfferent(Class klass, List<Package> packages) {
   List<Efferent> efferents = klass.getEfferent();
   for (Efferent efferent : efferents) {
     String efferentPackage = Toolkit.replaceAll(efferent.getName(), "<e:", "");
     efferentPackage = Toolkit.replaceAll(efferent.getName(), ">", "");
     for (Package pakkage : packages) {
       List<Class> children = pakkage.getChildren();
       for (Class child : children) {
         List<Afferent> afferents = child.getAfferent();
         for (Afferent afferent : afferents) {
           String afferentPackage = Toolkit.replaceAll(afferent.getName(), "<a:", "");
           afferentPackage = Toolkit.replaceAll(afferent.getName(), ">", "");
           if (efferentPackage.equals(afferentPackage)) {
             Collector.collectEfferentAndAfferent(klass.getName(), child.getName());
           }
         }
       }
     }
   }
 }
 /**
  * Dumps the database to the output stream.
  *
  * @param dataBase the database to dump
  * @param criteria the criteria to match if the data for the composite must be written to the
  *     output
  */
 @SuppressWarnings("unchecked")
 public static synchronized void dump(IDataBase dataBase, ICriteria criteria, String message) {
   if (message != null) {
     logger.warn(message);
   }
   try {
     Object object = dataBase.find(Project.class, Toolkit.hash(Project.class.getName()));
     logger.info(object.toString());
     Project<?, ?> project =
         (Project<?, ?>) dataBase.find(Project.class, Toolkit.hash(Project.class.getName()));
     if (project != null) {
       logger.warn("Project : " + project.getName());
     }
   } catch (Exception e) {
     logger.error("Exception dumping the data for the project object.", e);
   }
   try {
     List<Package> packages = dataBase.find(Package.class);
     for (Package<?, ?> pakkage : packages) {
       log(
           criteria,
           pakkage,
           1,
           pakkage.getId()
               + " : "
               + pakkage.getName()
               + ", coverage : "
               + pakkage.getCoverage()
               + ", complexity : "
               + pakkage.getComplexity()
               + ", stability : "
               + pakkage.getStability());
       for (Class<?, ?> klass : ((List<Class<?, ?>>) pakkage.getChildren())) {
         log(
             criteria,
             klass,
             2,
             " : id : "
                 + klass.getId()
                 + " : name : "
                 + klass.getName()
                 + " : coverage : "
                 + klass.getCoverage()
                 + ", complexity : "
                 + klass.getComplexity()
                 + ", outer class : "
                 + klass.getOuterClass()
                 + ", outer method : "
                 + klass.getOuterMethod()
                 + ", lines : "
                 + klass.getChildren().size()
                 + ", inner classes : "
                 + klass.getInnerClasses());
         List<Efferent> efferents = klass.getEfferent();
         List<Afferent> afferents = klass.getAfferent();
         for (Efferent efferent : efferents) {
           log(criteria, efferent, 4, efferent.getName());
         }
         for (Afferent afferent : afferents) {
           log(criteria, afferent, 4, afferent.getName());
         }
         for (Method<?, ?> method : ((List<Method<?, ?>>) klass.getChildren())) {
           log(
               criteria,
               method,
               3,
               method.getId()
                   + " : name : "
                   + method.getName()
                   + " : description : "
                   + method.getDescription()
                   + " : coverage : "
                   + method.getCoverage()
                   + ", complexity : "
                   + method.getComplexity()
                   + ", start time : "
                   + method.getStartTime()
                   + ", end time : "
                   + method.getEndTime());
           for (Line<?, ?> line : ((List<Line<?, ?>>) method.getChildren())) {
             log(
                 criteria,
                 line,
                 4,
                 line.getId()
                     + " : number : "
                     + line.getNumber()
                     + ", counter : "
                     + line.getCounter());
           }
         }
       }
     }
   } catch (Exception e) {
     logger.error("Exception dumping the data for the database.", e);
   }
 }