001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee; 020 021import java.io.IOException; 022 023import lucee.loader.TP; 024import lucee.loader.util.Util; 025 026/** 027 * returns th current built in version 028 */ 029public class Version { 030 031 private static int version=-1; 032 private static long created=-1; 033 034 035 /** 036 * @return returns the current version 037 */ 038 public static int getIntVersion() { 039 init(); 040 return version; 041 } 042 043 /** 044 * return creattion time of this version 045 * @return creattion time 046 */ 047 public static long getCreateTime() { 048 init(); 049 return created; 050 } 051 052 053 private static void init() { 054 if(version!=-1) return; 055 String content="9000000:"+System.currentTimeMillis(); 056 try { 057 content= Util.getContentAsString( 058 new TP().getClass().getClassLoader().getResourceAsStream("lucee/version"), 059 "UTF-8"); 060 061 062 } 063 catch (IOException e) {} 064 065 int index=content.indexOf(':'); 066 version=Util.toInVersion((content.substring(0,index))); 067 created=Long.parseLong(content.substring(index+1)); 068 069 } 070}