Source Code Cross Referenced for HttpFactory.java in  » Web-Server » Jigsaw » org » w3c » www » http » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Server » Jigsaw » org.w3c.www.http 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // HttpFactory.java
002:        // $Id: HttpFactory.java,v 1.5 2005/07/06 14:44:05 ylafon Exp $
003:        // (c) COPYRIGHT MIT and INRIA, 1996.
004:        // Please first read the full copyright statement in file COPYRIGHT.html
005:
006:        package org.w3c.www.http;
007:
008:        import org.w3c.www.mime.MimeType;
009:
010:        /**
011:         * Use this class to create pre-defined header values of various kind.
012:         */
013:
014:        public class HttpFactory {
015:
016:            /**
017:             * Create an <code>Accept</code> header clause.
018:             * @param type The MIME type that you will accept.
019:             * @param quality The quality you are willing to set to that MIME type.
020:             * @return An instance of <strong>HttpAccept</strong>.
021:             * @see HttpAccept
022:             */
023:
024:            public static HttpAccept makeAccept(MimeType type, double quality) {
025:                return new HttpAccept(true, type, quality);
026:            }
027:
028:            /**
029:             * Create an <code>Accept</code> header clause.
030:             * This will be assigned the default <strong>1.0</strong> quality.
031:             * @param type The MIME type that you will accept.
032:             * @return An instance of <strong>HttpAccept</strong>.
033:             * @see HttpAccept
034:             */
035:
036:            public static HttpAccept makeAccept(MimeType type) {
037:                return new HttpAccept(true, type, (double) 1.0);
038:            }
039:
040:            /**
041:             * Build an accept object by parsing the given string.
042:             * @param strval The String to parse.
043:             * @return An HttpAccept instance.
044:             */
045:
046:            public static HttpAccept parseAccept(String strval) {
047:                HttpAccept a = new HttpAccept();
048:                a.setString(strval);
049:                return a;
050:            }
051:
052:            /**
053:             * Build a list of accept clause, ready for the <code>Accept</code> header.
054:             * @param accepts The various accept clauses, as build through calls to
055:             * <code>makeAccept</code> and gathered in an array, or <strong>null
056:             * </strong> to create an empty list.
057:             * @return An instance of <strojng>HttpAcceptList</code>.
058:             * @see HttpAcceptList
059:             */
060:
061:            public static HttpAcceptList makeAcceptList(HttpAccept accepts[]) {
062:                if (accepts == null)
063:                    return new HttpAcceptList(null);
064:                else
065:                    return new HttpAcceptList(accepts);
066:            }
067:
068:            /**
069:             * Build an accept list object by parsing the given string.
070:             * @param strval The String to parse.
071:             * @return An HttpAcceptList instance.
072:             */
073:
074:            public static HttpAcceptList parseAcceptList(String strval) {
075:                HttpAcceptList a = new HttpAcceptList();
076:                a.setString(strval);
077:                return a;
078:            }
079:
080:            /**
081:             * Build an <code>Accept-Charset</code> header clause.
082:             * @param charset The accepted charset.
083:             * @param quality The quality under which this charset is accepted.
084:             * @return An instance of HttpAcceptCharset.
085:             * @see HttpAcceptCharset
086:             */
087:
088:            public static HttpAcceptCharset makeAcceptCharset(String charset,
089:                    double quality) {
090:                return new HttpAcceptCharset(true, charset, quality);
091:            }
092:
093:            /**
094:             * Build an <code>Accept-Charset</code> header clause.
095:             * Uses the default <strong>1.0</strong> quality.
096:             * @param charset The accepted charset.
097:             * @return An instance of HttpAcceptCharset.
098:             * @see HttpAcceptCharset
099:             */
100:
101:            public static HttpAcceptCharset makeAcceptCharset(String charset) {
102:                return new HttpAcceptCharset(true, charset, (double) 1.0);
103:            }
104:
105:            /**
106:             * Build an accept charset object by parsing the given string.
107:             * @param strval The String to parse.
108:             * @return An HttpAcceptCharset instance.
109:             */
110:
111:            public static HttpAcceptCharset parseAcceptCharset(String strval) {
112:                HttpAcceptCharset a = new HttpAcceptCharset();
113:                a.setString(strval);
114:                return a;
115:            }
116:
117:            /**
118:             * Build a list of accepted charset for the <code>Accept-Charset</code>
119:             * header.
120:             * @param charsets A list of accepted charsets, encoded as an array
121:             * or <strong>null</strong> to create an empty list.
122:             * @return An instance of HttpAcceptCharsetList.
123:             * @see HttpAcceptCharsetList
124:             */
125:
126:            public static HttpAcceptCharsetList makeAcceptCharsetList(
127:                    HttpAcceptCharset charsets[]) {
128:                return new HttpAcceptCharsetList(charsets);
129:            }
130:
131:            /**
132:             * Build an accept charset list object by parsing the given string.
133:             * @param strval The String to parse.
134:             * @return An HttpAcceptCharsetList instance.
135:             */
136:
137:            public static HttpAcceptCharsetList parseAcceptCharsetList(
138:                    String strval) {
139:                HttpAcceptCharsetList a = new HttpAcceptCharsetList();
140:                a.setString(strval);
141:                return a;
142:            }
143:
144:            /**
145:             * Build an <code>Accept-Encoding</code> header clause.
146:             * @param enc The accepted encoding.
147:             * @param quality The quality at which this encoding is accepted.
148:             * @return An instance of HttpAcceptEncoding.
149:             * @see HttpAcceptEncoding
150:             */
151:
152:            public static HttpAcceptEncoding makeAcceptEncoding(String enc,
153:                    double quality) {
154:                return new HttpAcceptEncoding(true, enc, quality);
155:            }
156:
157:            /**
158:             * Build an <code>Accept-Encoding</code> header clause.
159:             * Uses the default <strong>1.0</strong> quality.
160:             * @param enc The accepted encoding.
161:             * @return An instance of HttpAcceptEncoding.
162:             * @see HttpAcceptEncoding
163:             */
164:
165:            public static HttpAcceptEncoding makeAcceptEncoding(String enc) {
166:                return new HttpAcceptEncoding(true, enc, (double) 1.0);
167:            }
168:
169:            /**
170:             * Build an accept encoding object by parsing the given string.
171:             * @param strval The String to parse.
172:             * @return An HttpAcceptLanguage instance.
173:             */
174:
175:            public static HttpAcceptEncoding parseAcceptEncoding(String strval) {
176:                HttpAcceptEncoding e = new HttpAcceptEncoding();
177:                e.setString(strval);
178:                return e;
179:            }
180:
181:            /**
182:             * Build a list of accept encoding clauses for the <code>Accept-Encoding
183:             * </code> header.
184:             * @param langs A list of accepted encodings, encoded as an array, or
185:             * <strong>null</strong> to create an empty list.
186:             */
187:
188:            public static HttpAcceptEncodingList makeAcceptEncodingList(
189:                    HttpAcceptEncoding encs[]) {
190:                return new HttpAcceptEncodingList(encs);
191:            }
192:
193:            /**
194:             * Build an accept encoding list object by parsing the given string.
195:             * @param strval The String to parse.
196:             * @return An HttpAcceptENcodingList instance.
197:             */
198:
199:            public static HttpAcceptEncodingList parseAcceptEncodingList(
200:                    String strval) {
201:                HttpAcceptEncodingList a = new HttpAcceptEncodingList();
202:                a.setString(strval);
203:                return a;
204:            }
205:
206:            /**
207:             * Build an <code>Accept-Language</code> header clause.
208:             * @param lang The accepted language.
209:             * @param quality The quality at which this language is accepted.
210:             * @return An instance of HttpAcceptLanguage.
211:             * @see HttpAcceptLanguage
212:             */
213:
214:            public static HttpAcceptLanguage makeAcceptLanguage(String lang,
215:                    double quality) {
216:                return new HttpAcceptLanguage(true, lang, quality);
217:            }
218:
219:            /**
220:             * Build an <code>Accept-Language</code> header clause.
221:             * Uses the default <strong>1.0</strong> quality.
222:             * @param lang The accepted language.
223:             * @return An instance of HttpAcceptLanguage.
224:             * @see HttpAcceptLanguage
225:             */
226:
227:            public static HttpAcceptLanguage makeAcceptLanguage(String lang) {
228:                return new HttpAcceptLanguage(true, lang, (double) 1.0);
229:            }
230:
231:            /**
232:             * Build an accept language object by parsing the given string.
233:             * @param strval The String to parse.
234:             * @return An HttpAcceptLanguage instance.
235:             */
236:
237:            public static HttpAcceptLanguage parseAcceptLanguage(String strval) {
238:                HttpAcceptLanguage a = new HttpAcceptLanguage();
239:                a.setString(strval);
240:                return a;
241:            }
242:
243:            /**
244:             * Build a list of accept language clauses for the <code>Accept-Language
245:             * </code> header.
246:             * @param langs A list of accepted languages, encoded as an array, or
247:             * <strong>null</strong> to create an empty list.
248:             */
249:
250:            public static HttpAcceptLanguageList makeAcceptLanguageList(
251:                    HttpAcceptLanguage langs[]) {
252:                return new HttpAcceptLanguageList(langs);
253:            }
254:
255:            /**
256:             * Build an accept language list object by parsing the given string.
257:             * @param strval The String to parse.
258:             * @return An HttpAcceptLanguageList instance.
259:             */
260:
261:            public static HttpAcceptLanguageList parseAcceptLanguageList(
262:                    String strval) {
263:                HttpAcceptLanguageList a = new HttpAcceptLanguageList();
264:                a.setString(strval);
265:                return a;
266:            }
267:
268:            /**
269:             * Build a empty bag instance.
270:             * Bags are used in PEP and PICS.
271:             * @param name The name of the bag to construct.
272:             * @return An empty bag instance.
273:             * @see HttpBag
274:             */
275:
276:            public static HttpBag makeBag(String name) {
277:                return new HttpBag(true, name);
278:            }
279:
280:            /**
281:             * Build a bag object by parsing the given string.
282:             * @param strval The String to parse.
283:             * @return An HttpBag instance.
284:             */
285:
286:            public static HttpBag parseBag(String strval) {
287:                HttpBag a = new HttpBag();
288:                a.setString(strval);
289:                return a;
290:            }
291:
292:            /**
293:             * Build an empty cache control directive.
294:             * @return An instance of HttpCacheControl, with default settings.
295:             * @see HttpCacheControl
296:             */
297:
298:            public static HttpCacheControl makeCacheControl() {
299:                return new HttpCacheControl(true);
300:            }
301:
302:            /**
303:             * Build a cache control object by parsing the given string.
304:             * @param strval The String to parse.
305:             * @return An HttpCacheControl instance.
306:             */
307:
308:            public static HttpCacheControl parseCacheControl(String strval) {
309:                HttpCacheControl a = new HttpCacheControl();
310:                a.setString(strval);
311:                return a;
312:            }
313:
314:            /**
315:             * Build a challenge requesting authorization from a client.
316:             * @param scheme The scheme used by that challenge.
317:             * @return An HttpChallenge instance.
318:             * @see HttpChallenge
319:             */
320:
321:            public static HttpChallenge makeChallenge(String scheme) {
322:                return new HttpChallenge(true, scheme);
323:            }
324:
325:            /**
326:             * Build a challenge object by parsing the given string.
327:             * @param strval The String to parse.
328:             * @return An HttpChallenge instance.
329:             */
330:
331:            public static HttpChallenge parseChallenge(String strval) {
332:                HttpChallenge a = new HttpChallenge();
333:                a.setString(strval);
334:                return a;
335:            }
336:
337:            /**
338:             * Build the description of a HTTP content range.
339:             * @param unit The unit of that range.
340:             * @param firstpos The first position of that range (can be <strong>-1
341:             * </strong> to indicate a postfix range.
342:             * @param lastpost The last position of that range (can be <strong>-1
343:             * </strong> to indicate a prefix range).
344:             * @param length The full length of the entity from which that range was
345:             * taken.
346:             * @return An instance of HttpContentRange.
347:             * @see HttpContentRange
348:             */
349:
350:            public static HttpContentRange makeContentRange(String unit,
351:                    int firstpos, int lastpos, int length) {
352:                return new HttpContentRange(true, unit, firstpos, lastpos,
353:                        length);
354:            }
355:
356:            /**
357:             * Build a content range object by parsing the given string.
358:             * @param strval The String to parse.
359:             * @return An HttpContantRange instance.
360:             */
361:
362:            public static HttpContentRange parseContentRange(String strval) {
363:                HttpContentRange a = new HttpContentRange();
364:                a.setString(strval);
365:                return a;
366:            }
367:
368:            /**
369:             * Build a single cookie value.
370:             * @param name The name of that cookie.
371:             * @param value The value of that cookie.
372:             * @return An instance of HttpCookie.
373:             * @see HttpCookie
374:             */
375:
376:            public static HttpCookie makeCookie(String name, String value) {
377:                return new HttpCookie(true, name, value);
378:            }
379:
380:            /**
381:             * Build a list of cookies out of a set of cookies.
382:             * @param cookies The cookies to be added to the list, may be
383:             * <strong>null</strong> to create an empty list.
384:             * @return An instance of HttpCookieList.
385:             * @see HttpCookieList
386:             */
387:
388:            public static HttpCookieList makeCookieList(HttpCookie cookies[]) {
389:                return new HttpCookieList(cookies);
390:            }
391:
392:            /**
393:             * Build a cookie list object by parsing the given string.
394:             * @param strval The String to parse.
395:             * @return An HttpCookieList instance.
396:             */
397:
398:            public static HttpCookieList parseCookieList(String strval) {
399:                HttpCookieList a = new HttpCookieList();
400:                a.setString(strval);
401:                return a;
402:            }
403:
404:            /**
405:             * Build credential informations.
406:             * @param scheme The scheme for that credentials.
407:             * @return An instance of HttpCredential.
408:             * @see HttpCredential
409:             */
410:
411:            public static HttpCredential makeCredential(String scheme) {
412:                return new HttpCredential(true, scheme);
413:            }
414:
415:            /**
416:             * Build a credential object by parsing the given string.
417:             * @param strval The String to parse.
418:             * @return An HttpCredential instance.
419:             */
420:
421:            public static HttpCredential parseCredential(String strval) {
422:                HttpCredential a = new HttpCredential();
423:                a.setString(strval);
424:                return a;
425:            }
426:
427:            /**
428:             * Build an HTTP date object.
429:             * @param date The date, given in milliseconds since Java epoch.
430:             * @return An instance of HttpDate.
431:             * @see HttpDate
432:             */
433:
434:            public static HttpDate makeDate(long date) {
435:                return new HttpDate(true, date);
436:            }
437:
438:            /**
439:             * Build an HTTP date object representing the current time.
440:             * @return An instance of HttpDate.
441:             * @see HttpDate
442:             */
443:
444:            public static HttpDate makeDate() {
445:                return new HttpDate(true, System.currentTimeMillis());
446:            }
447:
448:            /**
449:             * Build a date object by parsing the given string.
450:             * @param strval The String to parse.
451:             * @return An HttpDate instance.
452:             */
453:
454:            public static HttpDate parseDate(String strval) {
455:                HttpDate a = new HttpDate();
456:                a.setString(strval);
457:                return a;
458:            }
459:
460:            /**
461:             * Build an entity tag object.
462:             * @param isWeak Is this a weak entity tag.
463:             * @param tag The tag encoded as a String.
464:             * @return An instance of HttpEntityTag.
465:             * @see HttpEntityTag
466:             */
467:
468:            public static HttpEntityTag makeETag(boolean isWeak, String tag) {
469:                return new HttpEntityTag(true, isWeak, tag);
470:            }
471:
472:            /**
473:             * Build an entity tag object by parsing the given string.
474:             * @param strval The String to parse.
475:             * @return An HttpEntityTag instance.
476:             */
477:
478:            public static HttpEntityTag parseETag(String strval) {
479:                HttpEntityTag a = new HttpEntityTag();
480:                a.setString(strval);
481:                return a;
482:            }
483:
484:            /**
485:             * Build an entity tag list.
486:             * @param tags A list of enetity tags, encoded as an array, or <strong>
487:             * null</strong> to create an empty list.
488:             * @return An instance of HttpEntityTagList.
489:             * @see HttpEntityTagList
490:             */
491:
492:            public static HttpEntityTagList makeETagList(HttpEntityTag tags[]) {
493:                return new HttpEntityTagList(tags);
494:            }
495:
496:            /**
497:             * Build an entity tag list object by parsing the given string.
498:             * @param strval The String to parse.
499:             * @return An HttpEntityTagList instance.
500:             */
501:
502:            public static HttpEntityTagList parseEntityTagList(String strval) {
503:                HttpEntityTagList a = new HttpEntityTagList();
504:                a.setString(strval);
505:                return a;
506:            }
507:
508:            /**
509:             * Build a wrapper for an HTTP integer.
510:             * @param i The integer to wrap for HTTP transportation.
511:             * @return An instance of HttpInteger.
512:             * @see HttpInteger
513:             */
514:
515:            public static HttpInteger makeInteger(int i) {
516:                return new HttpInteger(true, i);
517:            }
518:
519:            /**
520:             * Build an integer object by parsing the given string.
521:             * @param strval The String to parse.
522:             * @return An HttpInteger instance.
523:             */
524:
525:            public static HttpInteger parseInteger(String strval) {
526:                HttpInteger a = new HttpInteger();
527:                a.setString(strval);
528:                return a;
529:            }
530:
531:            /**
532:             * Build a wrapper for a MIME type suitable for HTTP transportation.
533:             * @param type The MIME type to wrap.
534:             * @return An instance of HttpMimeType.
535:             * @see HttpMimeType
536:             */
537:
538:            public static HttpMimeType makeMimeType(MimeType type) {
539:                return new HttpMimeType(true, type);
540:            }
541:
542:            /**
543:             * Build an MIME type object by parsing the given string.
544:             * @param strval The String to parse.
545:             * @return An HttpMimeType instance.
546:             */
547:
548:            public static HttpMimeType parseMimeType(String strval) {
549:                HttpMimeType a = new HttpMimeType();
550:                a.setString(strval);
551:                return a;
552:            }
553:
554:            /**
555:             * Build an object representing an HTTP range.
556:             * @param unit The units in which that byte range is measured.
557:             * @param firstpos The first position of requested byte range.
558:             * @param lastpos The last position of requested byte range.
559:             * @return An instance of HttpRange.
560:             * @see HttpRange
561:             */
562:
563:            public static HttpRange makeRange(String unit, int firstpos,
564:                    int lastpos) {
565:                return new HttpRange(true, unit, firstpos, lastpos);
566:            }
567:
568:            /**
569:             * Build a range object by parsing the given string.
570:             * @param strval The String to parse.
571:             * @return An HttpRange instance.
572:             */
573:
574:            public static HttpRange parseRange(String strval) {
575:                HttpRange a = new HttpRange();
576:                a.setString(strval);
577:                return a;
578:            }
579:
580:            /**
581:             * Build a list of ranges.
582:             * @param ranges A list of ranges, encoded as an array, or <strong>
583:             * null</strong> to create an empty list.
584:             * @return An instance of HttprangeList.
585:             * @see HttpRangeList
586:             */
587:
588:            public static HttpRangeList makeRangeList(HttpRange ranges[]) {
589:                return new HttpRangeList(ranges);
590:            }
591:
592:            /**
593:             * Build a list of ranges object by parsing the given string.
594:             * @param strval The String to parse.
595:             * @return An HttpRangeList instance.
596:             */
597:
598:            public static HttpRangeList parseRangeList(String strval) {
599:                HttpRangeList a = new HttpRangeList();
600:                a.setString(strval);
601:                return a;
602:            }
603:
604:            /**
605:             * Build a set cookie clause for the <code>Set-Cookie</code> header.
606:             * @param name The name of the cookie we are requesting to be set.
607:             * @param value It's value.
608:             * @return An instance of HttpSetCookie.
609:             * @see HttpSetCookie
610:             */
611:
612:            public static HttpSetCookie makeSetCookie(String name, String value) {
613:                return new HttpSetCookie(true, name, value);
614:            }
615:
616:            /**
617:             * Build a list of set cookies commands.
618:             * @param setcookies A list of set cookie commands, encoded as an
619:             * array, or <strong>null</strong> to build an empty list.
620:             * @return An instance of HttpStCookieList.
621:             * @see HttpSetCookieList
622:             */
623:
624:            public static HttpSetCookieList makeSetCookieList(
625:                    HttpSetCookie setcookies[]) {
626:                return new HttpSetCookieList(setcookies);
627:            }
628:
629:            /**
630:             * Build a list of set cookies object by parsing the given string.
631:             * @param strval The String to parse.
632:             * @return An HttpSetCookieList instance.
633:             */
634:
635:            public static HttpSetCookieList parseSetCookieList(String strval) {
636:                HttpSetCookieList a = new HttpSetCookieList();
637:                a.setString(strval);
638:                return a;
639:            }
640:
641:            /**
642:             * Build a wrapper for a String, for HTTP transportation.
643:             * @param str The String (or <em>token</em>) to wrap.
644:             * @return An instance of HttpString.
645:             * @see HttpString
646:             */
647:
648:            public static HttpString makeString(String str) {
649:                return new HttpString(true, str);
650:            }
651:
652:            /**
653:             * Build a String object by parsing the given string.
654:             * @param strval The String to parse.
655:             * @return An HttpString instance.
656:             */
657:
658:            public static HttpString parseString(String strval) {
659:                HttpString a = new HttpString();
660:                a.setString(strval);
661:                return a;
662:            }
663:
664:            /**
665:             * Build a list of strings.
666:             * @param list The list of strings, encoded as an array, or <strong>null
667:             * </strong> to create an empty list.
668:             * @return An instance of HttpTokenList.
669:             * @see HttpTokenList
670:             */
671:
672:            public static HttpTokenList makeStringList(String list[]) {
673:                return new HttpTokenList(list);
674:            }
675:
676:            /**
677:             * Build a list of one string.
678:             * @param item The item to be added to the list.
679:             * @return An instance of HttpTokenList.
680:             * @see HttpTokenList
681:             */
682:
683:            public static HttpTokenList makeStringList(String item) {
684:                String list[] = new String[1];
685:                list[0] = item;
686:                return new HttpTokenList(list);
687:            }
688:
689:            /**
690:             * Build a list of string object by parsing the given string.
691:             * @param strval The String to parse.
692:             * @return An HttpTokenList instance.
693:             */
694:
695:            public static HttpTokenList parseTokenList(String strval) {
696:                HttpTokenList a = new HttpTokenList();
697:                a.setString(strval);
698:                return a;
699:            }
700:
701:            /**
702:             * Build an HTTP Warning object.
703:             * @param status The warning status code.
704:             * @param agent The agent generating that warning.
705:             * @param text The text for the warning.
706:             * @return An instance of HttpWarning.
707:             * @see HttpWarning
708:             */
709:
710:            public static HttpWarning makeWarning(int status, String agent,
711:                    String text) {
712:                return new HttpWarning(true, status, agent, text);
713:            }
714:
715:            /**
716:             * Build an HTTP Warning object.
717:             * @param status The warning status code.
718:             * @return An instance of HttpWarning.
719:             * @see HttpWarning
720:             */
721:
722:            public static HttpWarning makeWarning(int status) {
723:                return new HttpWarning(true, status, null, null);
724:            }
725:
726:            /**
727:             * Build a warning object by parsing the given string.
728:             * @param strval The String to parse.
729:             * @return An HttpWarning instance.
730:             */
731:
732:            public static HttpWarning parseWarning(String strval) {
733:                HttpWarning a = new HttpWarning();
734:                a.setString(strval);
735:                return a;
736:            }
737:
738:            /**
739:             * Build a list of warnings for the <code>Warning</code> header.
740:             * @param warnings A list of warning encoded as an array, or <strong>
741:             * null</strong> to get an empty list.
742:             * @return An instance of HttpWarningList.
743:             * @see HttpWarningList
744:             */
745:
746:            public static HttpWarningList makeWarningList(
747:                    HttpWarning warnings[]) {
748:                return new HttpWarningList(warnings);
749:            }
750:
751:            /**
752:             * Build a list of warnings object by parsing the given string.
753:             * @param strval The String to parse.
754:             * @return An HttpWarningList instance.
755:             */
756:
757:            public static HttpWarningList parseWarningList(String strval) {
758:                HttpWarningList a = new HttpWarningList();
759:                a.setString(strval);
760:                return a;
761:            }
762:
763:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.