001: /*
002: * $HeadURL: https://svn.apache.org/repos/asf/httpcomponents/httpcore/tags/4.0-beta1/module-main/src/main/java/org/apache/http/HttpVersion.java $
003: * $Revision: 609106 $
004: * $Date: 2008-01-05 10:15:42 +0100 (Sat, 05 Jan 2008) $
005: *
006: * ====================================================================
007: * Licensed to the Apache Software Foundation (ASF) under one
008: * or more contributor license agreements. See the NOTICE file
009: * distributed with this work for additional information
010: * regarding copyright ownership. The ASF licenses this file
011: * to you under the Apache License, Version 2.0 (the
012: * "License"); you may not use this file except in compliance
013: * with the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing,
018: * software distributed under the License is distributed on an
019: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
020: * KIND, either express or implied. See the License for the
021: * specific language governing permissions and limitations
022: * under the License.
023: * ====================================================================
024: *
025: * This software consists of voluntary contributions made by many
026: * individuals on behalf of the Apache Software Foundation. For more
027: * information on the Apache Software Foundation, please see
028: * <http://www.apache.org/>.
029: *
030: */
031:
032: package org.apache.http;
033:
034: import java.io.Serializable;
035:
036: /**
037: * Represents an HTTP version, as specified in RFC 2616.
038: *
039: * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
040: *
041: * @version $Revision: 609106 $ $Date: 2008-01-05 10:15:42 +0100 (Sat, 05 Jan 2008) $
042: */
043: public final class HttpVersion extends ProtocolVersion implements
044: Serializable {
045:
046: private static final long serialVersionUID = -5856653513894415344L;
047:
048: /** The protocol name. */
049: public static final String HTTP = "HTTP";
050:
051: /** HTTP protocol version 0.9 */
052: public static final HttpVersion HTTP_0_9 = new HttpVersion(0, 9);
053:
054: /** HTTP protocol version 1.0 */
055: public static final HttpVersion HTTP_1_0 = new HttpVersion(1, 0);
056:
057: /** HTTP protocol version 1.1 */
058: public static final HttpVersion HTTP_1_1 = new HttpVersion(1, 1);
059:
060: /**
061: * Create an HTTP protocol version designator.
062: *
063: * @param major the major version number of the HTTP protocol
064: * @param minor the minor version number of the HTTP protocol
065: *
066: * @throws IllegalArgumentException if either major or minor version number is negative
067: */
068: public HttpVersion(int major, int minor) {
069: super (HTTP, major, minor);
070: }
071:
072: /**
073: * Obtains a specific HTTP version.
074: *
075: * @param major the major version
076: * @param minor the minor version
077: *
078: * @return an instance of {@link HttpVersion} with the argument version
079: */
080: public ProtocolVersion forVersion(int major, int minor) {
081:
082: if ((major == this .major) && (minor == this .minor)) {
083: return this ;
084: }
085:
086: if (major == 1) {
087: if (minor == 0) {
088: return HTTP_1_0;
089: }
090: if (minor == 1) {
091: return HTTP_1_1;
092: }
093: }
094: if ((major == 0) && (minor == 9)) {
095: return HTTP_0_9;
096: }
097:
098: // argument checking is done in the constructor
099: return new HttpVersion(major, minor);
100: }
101:
102: }
|