Skip to content

Commit c72ba76

Browse files
committed
Reorder some of the HTTP Headers.
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=25806584
1 parent e3676a6 commit c72ba76

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

guava/src/com/google/common/net/HttpHeaders.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,14 @@ private HttpHeaders() {}
129129
public static final String AGE = "Age";
130130
/** The HTTP Allow header field name. */
131131
public static final String ALLOW = "Allow";
132+
/** The HTTP Content-Disposition header field name. */
133+
public static final String CONTENT_DISPOSITION = "Content-Disposition";
132134
/** The HTTP Content-Encoding header field name. */
133135
public static final String CONTENT_ENCODING = "Content-Encoding";
134136
/** The HTTP Content-Language header field name. */
135137
public static final String CONTENT_LANGUAGE = "Content-Language";
136138
/** The HTTP Content-Location header field name. */
137139
public static final String CONTENT_LOCATION = "Content-Location";
138-
/** The HTTP Content-Disposition header field name. */
139-
public static final String CONTENT_DISPOSITION = "Content-Disposition";
140140
/** The HTTP Content-MD5 header field name. */
141141
public static final String CONTENT_MD5 = "Content-MD5";
142142
/** The HTTP Content-Range header field name. */
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package com.google.common.primitives;
19+
20+
/**
21+
* Android {@code Integer.java}, stripped down to {@code parseInt} methods.
22+
*/
23+
final class AndroidInteger {
24+
/**
25+
* Parses the specified string as a signed integer value using the specified
26+
* radix. The ASCII character \u002d ('-') is recognized as the minus sign.
27+
*
28+
* @param string
29+
* the string representation of an integer value.
30+
* @param radix
31+
* the radix to use when parsing.
32+
* @return the primitive integer value represented by {@code string} using
33+
* {@code radix}.
34+
* @throws NumberFormatException
35+
* if {@code string} is {@code null} or has a length of zero,
36+
* {@code radix < Character.MIN_RADIX},
37+
* {@code radix > Character.MAX_RADIX}, or if {@code string}
38+
* can not be parsed as an integer value.
39+
*/
40+
static int parseInt(String string, int radix) throws NumberFormatException {
41+
if (string == null || radix < Character.MIN_RADIX || radix > Character.MAX_RADIX) {
42+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
43+
}
44+
int length = string.length(), i = 0;
45+
if (length == 0) {
46+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
47+
}
48+
boolean negative = string.charAt(i) == '-';
49+
if (negative && ++i == length) {
50+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
51+
}
52+
53+
return parse(string, i, radix, negative);
54+
}
55+
56+
private static int parse(String string, int offset, int radix, boolean negative)
57+
throws NumberFormatException {
58+
int max = Integer.MIN_VALUE / radix;
59+
int result = 0, length = string.length();
60+
while (offset < length) {
61+
int digit = Character.digit(string.charAt(offset++), radix);
62+
if (digit == -1) {
63+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
64+
}
65+
if (max > result) {
66+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
67+
}
68+
int next = result * radix - digit;
69+
if (next > result) {
70+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
71+
}
72+
result = next;
73+
}
74+
if (!negative) {
75+
result = -result;
76+
if (result < 0) {
77+
throw new NumberFormatException("unable to parse '"+string+"' as integer");
78+
}
79+
}
80+
return result;
81+
}
82+
83+
private AndroidInteger() {}
84+
}

0 commit comments

Comments
 (0)