01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.core;
15:
16: /**
17: * Defines some constants and utility methods related with GZip compression.
18: *
19: * <p>Constant values are bitwise defined to be used with | or & bit operators.
20: *
21: * @author Jose Maria Arranz Santamaria
22: * @see ItsNatServletConfig#setUseGZip(int)
23: */
24: public class UseGZip {
25: /**
26: * Defines that neither markup nor JavaScript code is sent to the client compressed.
27: */
28: public static final int NONE = 0;
29:
30: /**
31: * Defines that markup is sent to the client compressed.
32: */
33: public static final int MARKUP = 0x1; // Bin: 01
34:
35: /**
36: * Defines that markup is sent to the client compressed.
37: */
38: public static final int SCRIPT = 0x2; // Bin: 10
39:
40: /**
41: * Informs whether the argument includes the SCRIPT
42: * bit.
43: *
44: * @param value the value to inspect.
45: * @return true if the argument includes the SCRIPT bit.
46: */
47: public static boolean isScriptUsingGZip(int value) {
48: return (value & SCRIPT) != 0;
49: }
50:
51: /**
52: * Informs whether the argument includes the MARKUP
53: * bit.
54: *
55: * @param value the value to inspect.
56: * @return true if the argument includes the MARKUP bit.
57: */
58: public static boolean isMarkupUsingGZip(int value) {
59: return (value & MARKUP) != 0;
60: }
61:
62: /**
63: * Informs whether the argument is NONE.
64: *
65: * @param value the value to inspect.
66: * @return true if the argument is NONE.
67: */
68: public static boolean isNoneUsingGZip(int value) {
69: return (value == NONE);
70: }
71: }
|