Package net.bnubot.util

Examples of net.bnubot.util.SortedProperties


      if(is == null) {
        // Failed to determine the bot version
        Out.fatalException(new FileNotFoundException(vpPath));
      }

      Properties versionprops = new SortedProperties();
      versionprops.load(is);
      is.close();

      Integer VER_SVN_REVISION_FILE = null;
      if(versionprops.containsKey(sReleaseType))
        RELEASE_TYPE = ReleaseType.valueOf((String)versionprops.get(sReleaseType));
      if(versionprops.containsKey(sVerMajor))
        VER_MAJOR = Integer.parseInt((String)versionprops.get(sVerMajor));
      if(versionprops.containsKey(sVerMinor))
        VER_MINOR = Integer.parseInt((String)versionprops.get(sVerMinor));
      if(versionprops.containsKey(sVerRevision))
        VER_REVISION = Integer.parseInt((String)versionprops.get(sVerRevision));
      if(versionprops.containsKey(sVerRelease))
        VER_RELEASE = Integer.parseInt((String)versionprops.get(sVerRelease));
      if(versionprops.containsKey(sVerSVNRevision))
        VER_SVN_REVISION_FILE = Integer.parseInt((String)versionprops.get(sVerSVNRevision));

      // From a JAR has no src folder; from Eclipse has no JAR
      if(fromJar != (revision() == null))
        throw new IllegalStateException();

      if(fromJar) {
        BUILD_DATE = new Date(Long.parseLong(versionprops.getProperty(sBuildDate)));
        VER_SVN_REVISION = VER_SVN_REVISION_FILE;
      } else {
        BUILD_DATE = new Date();
        versionprops.setProperty(sBuildDate, Long.toString(BUILD_DATE.getTime()));

        if((VER_SVN_REVISION_FILE == null) || (VER_SVN_REVISION > VER_SVN_REVISION_FILE)) {
          Out.info(CurrentVersion.class, "File version (" + VER_SVN_REVISION_FILE + ") does not match calculated (" + VER_SVN_REVISION + ").");

          RELEASE_TYPE = ReleaseType.Development;
          versionprops.setProperty(sReleaseType, RELEASE_TYPE.name());
          versionprops.setProperty(sVerSVNRevision, Integer.toString(VER_SVN_REVISION));
        }
      }

      VER = new VersionNumber(RELEASE_TYPE, VER_MAJOR, VER_MINOR, VER_REVISION, VER_RELEASE, VER_SVN_REVISION, BUILD_DATE);
      if(!fromJar)
        versionprops.store(new FileOutputStream(f), VER.toString());
      return VER;
    } catch(Exception e) {
      Out.exception(e);
      throw new IllegalStateException(e.getMessage(), e);
    }
View Full Code Here


    }
  }

  public static void setVersion(VersionNumber vnCurrent) {
    try {
      Properties versionprops = new SortedProperties();

      versionprops.setProperty(sReleaseType, vnCurrent.getReleaseType().name());
      versionprops.setProperty(sVerMajor, vnCurrent.getMajor().toString());
      versionprops.setProperty(sVerMinor, vnCurrent.getMinor().toString());
      versionprops.setProperty(sVerRevision, vnCurrent.getRevision().toString());
      versionprops.setProperty(sVerRelease, vnCurrent.getRelease().toString());
      versionprops.setProperty(sVerSVNRevision, vnCurrent.getSvnRevision().toString());
      versionprops.setProperty(sBuildDate, Long.toString(vnCurrent.getBuildDate().getTime()));

      File file = new File("src/net/bnubot/version.properties");
      versionprops.store(new FileOutputStream(file), VER.toString());
    } catch (Exception e) {
      Out.exception(e);
      throw new IllegalStateException(e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of net.bnubot.util.SortedProperties

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.