Mercurial Hosting > luan
annotate src/org/eclipse/jetty/util/StringUtil.java @ 919:dd6b1f079634
remove AsyncContinuation._lastAsyncListeners
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 03:45:31 -0600 |
parents | 3242aff51053 |
children | 8d0bdd357e6e |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.util; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.UnsupportedEncodingException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import java.nio.charset.Charset; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
24 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
25 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 /** Fast String Utilities. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 * These string utilities provide both conveniance methods and |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 * performance improvements over most standard library versions. The |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 * main aim of the optimizations is to avoid object creation unless |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 * absolutely required. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 public class StringUtil |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 { |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
38 private static final Logger LOG = LoggerFactory.getLogger(StringUtil.class); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
39 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
40 public static final String ALL_INTERFACES="0.0.0.0"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
41 public static final String CRLF="\015\012"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
42 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
43 public static final String __ISO_8859_1="ISO-8859-1"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
44 public final static String __UTF8="UTF-8"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
45 public final static String __UTF8Alt="UTF8"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
46 public final static String __UTF16="UTF-16"; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
47 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
48 public final static Charset __UTF8_CHARSET; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
49 public final static Charset __ISO_8859_1_CHARSET; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
50 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
51 static |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
52 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
53 __UTF8_CHARSET=Charset.forName(__UTF8); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
54 __ISO_8859_1_CHARSET=Charset.forName(__ISO_8859_1); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
55 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
56 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
57 private static char[] lowercases = { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
58 '\000','\001','\002','\003','\004','\005','\006','\007', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
59 '\010','\011','\012','\013','\014','\015','\016','\017', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
60 '\020','\021','\022','\023','\024','\025','\026','\027', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
61 '\030','\031','\032','\033','\034','\035','\036','\037', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
62 '\040','\041','\042','\043','\044','\045','\046','\047', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
63 '\050','\051','\052','\053','\054','\055','\056','\057', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
64 '\060','\061','\062','\063','\064','\065','\066','\067', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
65 '\070','\071','\072','\073','\074','\075','\076','\077', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
66 '\100','\141','\142','\143','\144','\145','\146','\147', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
67 '\150','\151','\152','\153','\154','\155','\156','\157', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
68 '\160','\161','\162','\163','\164','\165','\166','\167', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
69 '\170','\171','\172','\133','\134','\135','\136','\137', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
70 '\140','\141','\142','\143','\144','\145','\146','\147', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
71 '\150','\151','\152','\153','\154','\155','\156','\157', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
72 '\160','\161','\162','\163','\164','\165','\166','\167', |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
73 '\170','\171','\172','\173','\174','\175','\176','\177' }; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
74 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
75 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
76 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
77 * fast lower case conversion. Only works on ascii (not unicode) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
78 * @param s the string to convert |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
79 * @return a lower case version of s |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
80 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
81 public static String asciiToLowerCase(String s) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
82 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
83 char[] c = null; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
84 int i=s.length(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
85 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
86 // look for first conversion |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
87 while (i-->0) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
88 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
89 char c1=s.charAt(i); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
90 if (c1<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
91 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
92 char c2=lowercases[c1]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
93 if (c1!=c2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
94 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
95 c=s.toCharArray(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
96 c[i]=c2; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
97 break; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
98 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
99 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
100 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
101 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
102 while (i-->0) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
103 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
104 if(c[i]<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
105 c[i] = lowercases[c[i]]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
106 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
107 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
108 return c==null?s:new String(c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
109 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
110 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
111 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
112 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
113 public static boolean startsWithIgnoreCase(String s,String w) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
114 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
115 if (w==null) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
116 return true; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
117 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
118 if (s==null || s.length()<w.length()) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
119 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
120 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
121 for (int i=0;i<w.length();i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
122 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
123 char c1=s.charAt(i); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
124 char c2=w.charAt(i); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
125 if (c1!=c2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
126 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
127 if (c1<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
128 c1=lowercases[c1]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
129 if (c2<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
130 c2=lowercases[c2]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
131 if (c1!=c2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
132 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
133 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
134 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
135 return true; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
136 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
137 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
138 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
139 public static boolean endsWithIgnoreCase(String s,String w) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
140 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
141 if (w==null) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
142 return true; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
143 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
144 if (s==null) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
145 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
146 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
147 int sl=s.length(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
148 int wl=w.length(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
149 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
150 if (sl<wl) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
151 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
152 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
153 for (int i=wl;i-->0;) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
154 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
155 char c1=s.charAt(--sl); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
156 char c2=w.charAt(i); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
157 if (c1!=c2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
158 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
159 if (c1<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
160 c1=lowercases[c1]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
161 if (c2<=127) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
162 c2=lowercases[c2]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
163 if (c1!=c2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
164 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
165 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
166 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
167 return true; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
168 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
169 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
170 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
171 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
172 * returns the next index of a character from the chars string |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
173 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
174 public static int indexFrom(String s,String chars) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
175 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
176 for (int i=0;i<s.length();i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
177 if (chars.indexOf(s.charAt(i))>=0) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
178 return i; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
179 return -1; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
180 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
181 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
182 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
183 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
184 * replace substrings within string. |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
185 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
186 public static String replace(String s, String sub, String with) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
187 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
188 int c=0; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
189 int i=s.indexOf(sub,c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
190 if (i == -1) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
191 return s; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
192 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
193 StringBuilder buf = new StringBuilder(s.length()+with.length()); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
194 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
195 do |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
196 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
197 buf.append(s.substring(c,i)); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
198 buf.append(with); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
199 c=i+sub.length(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
200 } while ((i=s.indexOf(sub,c))!=-1); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
201 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
202 if (c<s.length()) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
203 buf.append(s.substring(c,s.length())); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
204 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
205 return buf.toString(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
206 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
207 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
208 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
209 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
210 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
211 /** Remove single or double quotes. |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
212 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
213 public static String unquote(String s) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
214 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
215 return QuotedStringTokenizer.unquote(s); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
216 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
217 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
218 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
219 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
220 /** Append substring to StringBuilder |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
221 * @param buf StringBuilder to append to |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
222 * @param s String to append from |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
223 * @param offset The offset of the substring |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
224 * @param length The length of the substring |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
225 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
226 public static void append(StringBuilder buf, |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
227 String s, |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
228 int offset, |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
229 int length) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
230 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
231 synchronized(buf) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
232 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
233 int end=offset+length; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
234 for (int i=offset; i<end;i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
235 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
236 if (i>=s.length()) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
237 break; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
238 buf.append(s.charAt(i)); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
239 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
240 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
241 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
242 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
243 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
244 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
245 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
246 * append hex digit |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
247 * |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
248 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
249 public static void append(StringBuilder buf,byte b,int base) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
250 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
251 int bi=0xff&b; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
252 int c='0'+(bi/base)%base; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
253 if (c>'9') |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
254 c= 'a'+(c-'0'-10); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
255 buf.append((char)c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
256 c='0'+bi%base; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
257 if (c>'9') |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
258 c= 'a'+(c-'0'-10); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
259 buf.append((char)c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
260 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
261 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
262 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
263 public static void append2digits(StringBuffer buf,int i) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
264 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
265 if (i<100) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
266 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
267 buf.append((char)(i/10+'0')); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
268 buf.append((char)(i%10+'0')); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
269 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
270 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
271 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
272 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
273 public static void append2digits(StringBuilder buf,int i) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
274 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
275 if (i<100) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
276 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
277 buf.append((char)(i/10+'0')); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
278 buf.append((char)(i%10+'0')); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
279 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
280 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
281 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
282 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
283 /** Return a non null string. |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
284 * @param s String |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
285 * @return The string passed in or empty string if it is null. |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
286 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
287 public static String nonNull(String s) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
288 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
289 if (s==null) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
290 return ""; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
291 return s; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
292 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
293 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
294 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
295 public static boolean equals(String s,char[] buf, int offset, int length) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
296 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
297 if (s.length()!=length) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
298 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
299 for (int i=0;i<length;i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
300 if (buf[offset+i]!=s.charAt(i)) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
301 return false; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
302 return true; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
303 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
304 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
305 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
306 public static String toUTF8String(byte[] b,int offset,int length) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
307 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
308 try |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
309 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
310 return new String(b,offset,length,__UTF8); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
311 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
312 catch (UnsupportedEncodingException e) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
313 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
314 throw new IllegalArgumentException(e); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
315 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
316 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
317 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
318 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
319 public static String toString(byte[] b,int offset,int length,String charset) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
320 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
321 try |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
322 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
323 return new String(b,offset,length,charset); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
324 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
325 catch (UnsupportedEncodingException e) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
326 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
327 throw new IllegalArgumentException(e); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
328 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
329 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
330 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
331 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
332 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
333 public static boolean isUTF8(String charset) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
334 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
335 return __UTF8.equalsIgnoreCase(charset)||__UTF8Alt.equalsIgnoreCase(charset); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
336 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
337 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
338 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
339 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
340 public static String printable(String name) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
341 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
342 if (name==null) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
343 return null; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
344 StringBuilder buf = new StringBuilder(name.length()); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
345 for (int i=0;i<name.length();i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
346 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
347 char c=name.charAt(i); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
348 if (!Character.isISOControl(c)) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
349 buf.append(c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
350 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
351 return buf.toString(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
352 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
353 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
354 /* ------------------------------------------------------------ */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
355 public static String printable(byte[] b) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
356 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
357 StringBuilder buf = new StringBuilder(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
358 for (int i=0;i<b.length;i++) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
359 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
360 char c=(char)b[i]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
361 if (Character.isWhitespace(c)|| c>' ' && c<0x7f) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
362 buf.append(c); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
363 else |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
364 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
365 buf.append("0x"); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
366 TypeUtil.toHex(b[i],buf); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
367 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
368 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
369 return buf.toString(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
370 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
371 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
372 public static byte[] getBytes(String s) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
373 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
374 try |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
375 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
376 return s.getBytes(__ISO_8859_1); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
377 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
378 catch(Exception e) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
379 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
380 LOG.warn("",e); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
381 return s.getBytes(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
382 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
383 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
384 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
385 public static byte[] getBytes(String s,String charset) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
386 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
387 try |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
388 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
389 return s.getBytes(charset); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
390 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
391 catch(Exception e) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
392 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
393 LOG.warn("",e); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
394 return s.getBytes(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
395 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
396 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
397 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
398 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
399 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
400 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
401 * Converts a binary SID to a string SID |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
402 * |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
403 * http://en.wikipedia.org/wiki/Security_Identifier |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
404 * |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
405 * S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
406 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
407 public static String sidBytesToString(byte[] sidBytes) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
408 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
409 StringBuilder sidString = new StringBuilder(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
410 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
411 // Identify this as a SID |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
412 sidString.append("S-"); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
413 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
414 // Add SID revision level (expect 1 but may change someday) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
415 sidString.append(Byte.toString(sidBytes[0])).append('-'); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
416 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
417 StringBuilder tmpBuilder = new StringBuilder(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
418 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
419 // crunch the six bytes of issuing authority value |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
420 for (int i = 2; i <= 7; ++i) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
421 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
422 tmpBuilder.append(Integer.toHexString(sidBytes[i] & 0xFF)); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
423 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
424 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
425 sidString.append(Long.parseLong(tmpBuilder.toString(), 16)); // '-' is in the subauth loop |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
426 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
427 // the number of subAuthorities we need to attach |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
428 int subAuthorityCount = sidBytes[1]; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
429 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
430 // attach each of the subAuthorities |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
431 for (int i = 0; i < subAuthorityCount; ++i) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
432 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
433 int offset = i * 4; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
434 tmpBuilder.setLength(0); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
435 // these need to be zero padded hex and little endian |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
436 tmpBuilder.append(String.format("%02X%02X%02X%02X", |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
437 (sidBytes[11 + offset] & 0xFF), |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
438 (sidBytes[10 + offset] & 0xFF), |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
439 (sidBytes[9 + offset] & 0xFF), |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
440 (sidBytes[8 + offset] & 0xFF))); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
441 sidString.append('-').append(Long.parseLong(tmpBuilder.toString(), 16)); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
442 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
443 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
444 return sidString.toString(); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
445 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
446 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
447 /** |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
448 * Converts a string SID to a binary SID |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
449 * |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
450 * http://en.wikipedia.org/wiki/Security_Identifier |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
451 * |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
452 * S-1-IdentifierAuthority-SubAuthority1-SubAuthority2-...-SubAuthorityn |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
453 */ |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
454 public static byte[] sidStringToBytes( String sidString ) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
455 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
456 String[] sidTokens = sidString.split("-"); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
457 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
458 int subAuthorityCount = sidTokens.length - 3; // S-Rev-IdAuth- |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
459 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
460 int byteCount = 0; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
461 byte[] sidBytes = new byte[1 + 1 + 6 + (4 * subAuthorityCount)]; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
462 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
463 // the revision byte |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
464 sidBytes[byteCount++] = (byte)Integer.parseInt(sidTokens[1]); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
465 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
466 // the # of sub authorities byte |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
467 sidBytes[byteCount++] = (byte)subAuthorityCount; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
468 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
469 // the certAuthority |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
470 String hexStr = Long.toHexString(Long.parseLong(sidTokens[2])); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
471 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
472 while( hexStr.length() < 12) // pad to 12 characters |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
473 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
474 hexStr = "0" + hexStr; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
475 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
476 |
853
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
477 // place the certAuthority 6 bytes |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
478 for ( int i = 0 ; i < hexStr.length(); i = i + 2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
479 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
480 sidBytes[byteCount++] = (byte)Integer.parseInt(hexStr.substring(i, i + 2),16); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
481 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
482 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
483 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
484 for ( int i = 3; i < sidTokens.length ; ++i) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
485 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
486 hexStr = Long.toHexString(Long.parseLong(sidTokens[i])); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
487 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
488 while( hexStr.length() < 8) // pad to 8 characters |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
489 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
490 hexStr = "0" + hexStr; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
491 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
492 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
493 // place the inverted sub authorities, 4 bytes each |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
494 for ( int j = hexStr.length(); j > 0; j = j - 2) |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
495 { |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
496 sidBytes[byteCount++] = (byte)Integer.parseInt(hexStr.substring(j-2, j),16); |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
497 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
498 } |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
499 |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
500 return sidBytes; |
3242aff51053
remove RolloverFileOutputStream and cleanup NCSARequestLog
Franklin Schmidt <fschmidt@gmail.com>
parents:
820
diff
changeset
|
501 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
502 } |