01: /*
02: * $Id: Library.java,v 1.43 2007/03/16 09:55:00 agoubard Exp $
03: *
04: * Copyright 2003-2007 Orange Nederland Breedband B.V.
05: * See the COPYRIGHT file for redistribution and use restrictions.
06: */
07: package org.xins.server;
08:
09: import org.apache.oro.text.regex.Pattern;
10: import org.apache.oro.text.regex.Perl5Matcher;
11: import org.xins.common.text.PatternUtils;
12:
13: /**
14: * Class that represents the XINS/Java Server Framework library.
15: *
16: * @version $Revision: 1.43 $ $Date: 2007/03/16 09:55:00 $
17: * @author <a href="mailto:ernst@ernstdehaan.com">Ernst de Haan</a>
18: *
19: * @since XINS 1.0.0
20: */
21: public final class Library {
22:
23: /**
24: * Regular expression that production release versions of XINS match, and
25: * non-production release version do not.
26: */
27: private static final String PRODUCTION_RELEASE_PATTERN_STRING = "[1-9][0-9]*\\.[0-9]+(\\.[0-9]+)?";
28:
29: /**
30: * The pattern for a URL.
31: */
32: private static final Pattern PRODUCTION_RELEASE_PATTERN = PatternUtils
33: .createPattern(PRODUCTION_RELEASE_PATTERN_STRING);
34:
35: /**
36: * Constructs a new <code>Library</code> object.
37: */
38: private Library() {
39: // empty
40: }
41:
42: /**
43: * Returns the version of this library.
44: *
45: * @return
46: * the version of this library, for example <code>"1.0.0"</code>,
47: * never <code>null</code>.
48: */
49: public static final String getVersion() {
50: return "%%VERSION%%";
51: }
52:
53: /**
54: * Checks if the specified version indicates a production release of XINS.
55: *
56: * @param version
57: * the XINS version to check, cannot be <code>null</code>.
58: *
59: * @return
60: * <code>true</code> is the specified XINS version identifies a
61: * production release of XINS, <code>false</code> if it does not.
62: *
63: * @throws NullPointerException
64: * if <code>version == null</code>.
65: */
66: static final boolean isProductionRelease(String version)
67: throws NullPointerException {
68: Perl5Matcher patternMatcher = new Perl5Matcher();
69: return patternMatcher.matches(version,
70: PRODUCTION_RELEASE_PATTERN);
71: }
72: }
|