001: package org.methodize.nntprss.util;
002:
003: /* -----------------------------------------------------------
004: * nntp//rss - a bridge between the RSS world and NNTP clients
005: * Copyright (c) 2002, 2003 Jason Brome. All Rights Reserved.
006: *
007: * email: nntprss@methodize.org
008: * mail: Methodize Solutions
009: * PO Box 3865
010: * Grand Central Station
011: * New York NY 10163
012: *
013: * This file is part of nntp//rss
014: *
015: * nntp//rss is free software; you can redistribute it
016: * and/or modify it under the terms of the GNU General
017: * Public License as published by the Free Software Foundation;
018: * either version 2 of the License, or (at your option) any
019: * later version.
020: *
021: * This program is distributed in the hope that it will be
022: * useful, but WITHOUT ANY WARRANTY; without even the implied
023: * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
024: * PURPOSE. See the GNU General Public License for more
025: * details.
026: *
027: * You should have received a copy of the GNU General Public
028: * License along with this program; if not, write to the
029: * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
030: * Boston, MA 02111-1307 USA
031: * ----------------------------------------------------- */
032:
033: import javax.xml.parsers.DocumentBuilder;
034: import javax.xml.parsers.DocumentBuilderFactory;
035: import javax.xml.parsers.ParserConfigurationException;
036:
037: /**
038: * @author Jason Brome <jason@methodize.org>
039: * @version $Id: AppConstants.java,v 1.7 2003/03/22 16:35:11 jasonbrome Exp $
040: */
041: public class AppConstants {
042:
043: private static DocumentBuilderFactory docBuilderFactory;
044: private static String platform;
045: private static String userAgent;
046:
047: public static final AppConstants appConstants = new AppConstants();
048:
049: public static final String NNTPRSS_CONFIGURATION_FILE = "nntprss-config.xml";
050: public static final String USERS_CONFIG = "users.properties";
051:
052: public static final String VERSION = "0.3";
053:
054: public static final int OPEN_ENDED_RANGE = -1;
055:
056: public static final int CONTENT_TYPE_TEXT = 1;
057: public static final int CONTENT_TYPE_HTML = 2;
058: public static final int CONTENT_TYPE_MIXED = 3;
059:
060: private AppConstants() {
061: // Private constructor... initialize platform string
062: StringBuffer pltfmBuf = new StringBuffer();
063: String osName = System.getProperty("os.name");
064: if (osName != null) {
065: pltfmBuf.append(osName);
066: pltfmBuf.append(' ');
067: }
068:
069: String osVersion = System.getProperty("os.version");
070: if (osVersion != null) {
071: pltfmBuf.append(osVersion);
072: pltfmBuf.append(' ');
073: }
074:
075: String osArch = System.getProperty("os.arch");
076: if (osVersion != null) {
077: pltfmBuf.append(osArch);
078: }
079:
080: platform = pltfmBuf.toString();
081: userAgent = "nntp//rss v" + VERSION + " (" + platform
082: + "; http://www.methodize.org/nntprss/)";
083:
084: docBuilderFactory = DocumentBuilderFactory.newInstance();
085: docBuilderFactory.setNamespaceAware(true);
086: }
087:
088: public static DocumentBuilder newDocumentBuilder()
089: throws ParserConfigurationException {
090: return docBuilderFactory.newDocumentBuilder();
091: }
092:
093: public static String getPlatform() {
094: return platform;
095: }
096:
097: public static String getUserAgent() {
098: return userAgent;
099: }
100:
101: }
|