/**
  * Returns a set of versions that exist in the change-log as versions-before-changes.
  *
  * @return
  */
 public static TreeSet<Version> getVersionsInLog() {
   TreeSet<Version> ret = new TreeSet<Version>(new VersionComparator());
   for (ChangeLogItem item : getLog()) {
     ret.add(item.getVersionBeforeChange());
   }
   return ret;
 }
 /**
  * Returns the log as a string.
  *
  * @return
  */
 public static String logAsString() {
   StringBuffer sb = new StringBuffer();
   TreeMap<Version, Set<ChangeLogItem>> mapChangedInVersion = getItemsChangedInVersion();
   for (Version version : mapChangedInVersion.keySet()) {
     sb.append(verstionShortString(version)).append("\n");
     for (ChangeLogItem item : mapChangedInVersion.get(version)) {
       sb.append("\t");
       String typeString = "";
       if (item.isMajor()) typeString = typeString + "* ";
       typeString = typeString + item.getChangeType().name();
       sb.append(String.format("%-11s", typeString));
       sb.append(": ").append(item.getDescription()).append("\n");
     }
   }
   return sb.toString();
 }
  /**
   * Returns a map from a version in which changes have been performed - to the set of the changes
   * that have been performed in it.
   *
   * @return
   */
  public static TreeMap<Version, Set<ChangeLogItem>> getItemsChangedInVersion() {
    TreeMap<Version, Set<ChangeLogItem>> ret =
        new TreeMap<Version, Set<ChangeLogItem>>(new VersionComparator());
    TreeMap<Version, Version> mapNext = mapToNextVersion();
    for (ChangeLogItem item : getLog()) {
      Version changedInVersion = mapNext.get(item.getVersionBeforeChange());
      Set<ChangeLogItem> correspondingSet = null;
      if (ret.containsKey(changedInVersion)) {
        correspondingSet = ret.get(changedInVersion);
      } else {
        correspondingSet = new LinkedHashSet<ChangeLogItem>();
        ret.put(changedInVersion, correspondingSet);
      }
      correspondingSet.add(item);
    }

    return ret;
  }
 /**
  * Returns a map from version to a set of changes occurred immediately after that version (i.e.
  * occurred in a version which is a subsequent of the specified version).
  *
  * @return
  */
 public static TreeMap<Version, Set<ChangeLogItem>> getItemsByVersion() {
   TreeMap<Version, Set<ChangeLogItem>> ret =
       new TreeMap<Version, Set<ChangeLogItem>>(new VersionComparator());
   for (ChangeLogItem item : getLog()) {
     boolean setExist = false;
     Set<ChangeLogItem> set = null;
     if (ret.containsKey(item.getVersionBeforeChange())) {
       set = ret.get(item.getVersionBeforeChange());
       setExist = true;
     } else {
       set = new LinkedHashSet<ChangeLogItem>();
       setExist = false;
     }
     set.add(item);
     if (!setExist) ret.put(item.getVersionBeforeChange(), set);
   }
   return ret;
 }