jiveglobals.java
来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· Java 代码 · 共 487 行 · 第 1/2 页
JAVA
487 行
/** * $RCSfile: JiveGlobals.java,v $ * $Revision: 1.13 $ * $Date: 2002/06/14 16:45:14 $ * * Copyright (C) 1999-2002 CoolServlets, Inc. All rights reserved. * * This software is the proprietary information of CoolServlets, Inc. * Use is subject to license terms. */package com.jivesoftware.forum;import com.jivesoftware.forum.util.XMLProperties;import java.util.*;import java.io.*;import java.text.*;/** * Contains constant values representing various objects in Jive as well as * other settings such as the global locale and Jive version number.<p> * * The class also controls Jive properties. Jive properties are only meant to * be set and retrevied by core Jive classes. * <p> * All properties are stored in the file <tt>jive_config.xml</tt> which is * located in the <tt>jiveHome</tt> directory. The location of that * directory should be specified one of two ways:<ol> * <li>Indicate its value in the <tt>jive_init.properties</tt> file. This * is a standard properties file so the property should be something * like:<br> * <tt>jiveHome=c:\\some\\directory\\jiveHome</tt> (Windows) <br> * or <br> * <tt>jiveHome=/home/some/directory/jiveHome</tt> (Unix) * <p> * The file must be in your classpath so that it can be loaded by Java's * classloader. * <li>Use another class in your VM to set the * <tt>JiveGlobals.jiveHome</tt> variable. This must be done before * the rest of Jive starts up, for example: in a servlet that is set to run * as soon as the appserver starts up. * </ol> * <p> * All Jive property names must be in the form <code>prop.name</code> - parts of * the name must be seperated by ".". The value can be any valid String, * including Strings with line breaks. */public class JiveGlobals { // Constant values public static final int FORUM = 0; public static final int THREAD = 1; public static final int MESSAGE = 2; public static final int USER = 3; public static final int GROUP = 4; public static final int THREAD_NAME = 5; public static final int MESSAGE_SUBJECT = 6; public static final int MESSAGE_BODY = 7; public static final int CREATION_DATE = 8; public static final int MODIFIED_DATE = 9; public static final int EXTENDED_PROPERTY = 10; public static final int ANONYMOUS = 11; public static final int REGISTERED_USERS = 12; public static final int ATTACHMENT = 13; public static final int FORUM_CATEGORY = 14; public static final int FORUM_CATEGORY_INDEX = 15; public static final int FORUM_NAME = 16; public static final int SYSTEM = 17; // Time values in milliseconds public static final long SECOND = 1000; public static final long MINUTE = 60 * SECOND; public static final long HOUR = 60 * MINUTE; public static final long DAY = 24 * HOUR; public static final long WEEK = 7 * DAY; /** * The Major version number of Jive (ie 1.x.x). */ public static final int JIVE_MAJOR_VERSION = 2; /** * The Minor version number of Jive (ie x.1.x). */ public static final int JIVE_MINOR_VERSION = 6; /** * The revision version number of Jive (ie x.x.1). */ public static final int JIVE_REVISION_VERSION = 0; /** * Constant value for Jive Forums Basic. */ public static final int BASIC = 100; /** * Constant value for Jive Forums Professional. */ public static final int PROFESSIONAL = 101; /** * Constant value for Jive Forums Enterprise. */ public static final int ENTERPRISE = 102; /** * The edition of this copy of the software (changed through build process). */ private static final int EDITION = BASIC; private static final String JIVE_CONFIG_FILENAME = "jive_config.xml"; /** * Location of the jiveHome directory. All configuration files should be * located here. This value can be set explicitly by an outside class or * this class will attempt to load it from the <tt>jive_init.properties</tt> * file. */ public static String jiveHome = null; /** * XML properties to actually get and set the Jive properties. */ private static XMLProperties properties = null; private static Locale locale = null; private static TimeZone timeZone = null; private static String characterEncoding = null; private static DateFormat dateFormat = null; private static DateFormat dateTimeFormat = null; /** * Returns the version number of Jive as a String (ie major.minor.revision). */ public static String getJiveVersion() { return JIVE_MAJOR_VERSION + "." + JIVE_MINOR_VERSION + "." + JIVE_REVISION_VERSION; } /** * Returns the edition type of Jive Forums. Valid values are * JiveGlobals.BASIC, JiveGlobals.PROFESSIONAL, and JiveGlobals.ENTERPRISE. * * @return the edition of Jive Forums. */ public static int getJiveEdition() { return EDITION; } /** * Returns the global Locale used by Jive. A locale specifies language * and country codes, and is used for internationalization. The default * locale is Locale.US * * @return the global locale used by Jive. */ public static Locale getLocale() { if (locale == null) { loadProperties(); } return locale; } /** * Sets the global locale used by Jive. A locale specifies language * and country codes, and is used for formatting dates and numbers. * The default locale is Locale.US. * * @param newLocale the global Locale for Jive. */ public static void setLocale(Locale newLocale) { locale = newLocale; // Save values to Jive properties. setJiveProperty("locale.country", locale.getCountry()); setJiveProperty("locale.language", locale.getLanguage()); // Reset the date formatter objects dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale); dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, locale); dateFormat.setTimeZone(timeZone); dateTimeFormat.setTimeZone(timeZone); } /** * Returns the character set that Jive uses for encoding. This * is used for displaying content in skins, sending email watch * updates, etc. The default encoding is 8859_1, which is suitable for * most Latin languages. If you need to support double byte character sets * such as Chinese or Japanese, it's recommend that you use utf-8 * as the charset (Unicode). Unicode offers simultaneous support for a * large number of languages and is easy to convert into native charsets * as necessary. You may also specifiy any other charset that is supported * by your JVM. A list of encodings supported by the Sun JVM can be found * <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html"> * here.</a><p> * * In order for a particular encoding to work (such as Unicode), your * application server and database may need to be specially configured. * Please consult your server documentation for more information. For * example, SQLServer has a special column type for Unicode text, and the * Resin application server can be configured to use a custom charset by * adding a <character-encoding> element to the web.xml/resin.conf * file. Any Servlet 2.3 compliant application servers also supports the * method HttpServletRequest.setCharacterEncoding(String). A Servlet 2.3 * Filter called SetCharacterEncodingFilter is installed in the default * Jive Forums web.xml file, which will set the incoming character encoding * to the one reported by this method. * * @return the global Jive character encoding. */ public static String getCharacterEncoding() { if (locale == null) { loadProperties(); } return characterEncoding; } /** * Sets the character set that Jive uses for encoding. This * is used for displaying content in skins, sending email watch * updates, etc. The default encoding is 8859_1, which is suitable for * most Latin languages. If you need to support double byte character sets * such as Chinese or Japanese, it's recommend that you use utf-8 * as the charset (Unicode). Unicode offers simultaneous support for a * large number of languages and is easy to convert into native charsets * as necessary. You may also specifiy any other charset that is supported * by your JVM. A list of encodings supported by the Sun JVM can be found * <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html"> * here.</a><p> * * In order for a particular encoding to work (such as Unicode), your * application server and database may need to be specially configured. * Please consult your server documentation for more information. For * example, SQLServer has a special column type for Unicode text, and the * Resin application server can be configured to use a custom charset by
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?