001 /** 002 * Copyright (c) 2000-present Liferay, Inc. All rights reserved. 003 * 004 * This library is free software; you can redistribute it and/or modify it under 005 * the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or (at your option) 007 * any later version. 008 * 009 * This library is distributed in the hope that it will be useful, but WITHOUT 010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 012 * details. 013 */ 014 015 package com.liferay.portal.kernel.util; 016 017 import com.liferay.portal.kernel.service.ServiceContext; 018 019 import java.io.Serializable; 020 021 import java.text.DateFormat; 022 023 import java.util.Date; 024 import java.util.Enumeration; 025 import java.util.Locale; 026 import java.util.Map; 027 028 import javax.portlet.PortletRequest; 029 030 import javax.servlet.http.HttpServletRequest; 031 032 /** 033 * Provides utility methods for reading request parameters. 034 * 035 * @author Brian Wing Shun Chan 036 * @author Raymond Aug?? 037 */ 038 public class ParamUtil { 039 040 /** 041 * Returns the request parameter value as a boolean. If the parameter is 042 * missing, the default value is returned. 043 * 044 * <p> 045 * If the value is not convertible to a boolean, <code>false</code> is 046 * returned. 047 * </p> 048 * 049 * @param request the servlet request from which to read the parameter 050 * @param param the name of the parameter 051 * @param defaultValue a default value 052 * @return the request parameter value as a boolean 053 */ 054 public static boolean get( 055 HttpServletRequest request, String param, boolean defaultValue) { 056 057 return GetterUtil.get(request.getParameter(param), defaultValue); 058 } 059 060 /** 061 * Returns the request parameter value as a Date. If the parameter is 062 * missing or not convertible to a Date, the default value is returned. 063 * 064 * @param request the servlet request from which to read the parameter 065 * @param param the name of the parameter 066 * @param dateFormat the format used to parse date 067 * @param defaultValue a default value 068 * @return the request parameter value as a Date 069 */ 070 public static Date get( 071 HttpServletRequest request, String param, DateFormat dateFormat, 072 Date defaultValue) { 073 074 return GetterUtil.get( 075 request.getParameter(param), dateFormat, defaultValue); 076 } 077 078 /** 079 * Returns the request parameter value as a double. If the parameter is 080 * missing or not convertible to a double, the default value is returned. 081 * 082 * @param request the servlet request from which to read the parameter 083 * @param param the name of the parameter 084 * @param defaultValue a default value 085 * @return the request parameter value as a double 086 */ 087 public static double get( 088 HttpServletRequest request, String param, double defaultValue) { 089 090 return GetterUtil.get(request.getParameter(param), defaultValue); 091 } 092 093 /** 094 * Returns the request parameter value as a float. If the parameter is 095 * missing or not convertible to a float, the default value is returned. 096 * 097 * @param request the servlet request from which to read the parameter 098 * @param param the name of the parameter 099 * @param defaultValue a default value 100 * @return the request parameter value as a float 101 */ 102 public static float get( 103 HttpServletRequest request, String param, float defaultValue) { 104 105 return GetterUtil.get(request.getParameter(param), defaultValue); 106 } 107 108 /** 109 * Returns the request parameter value as an integer. If the parameter is 110 * missing or not convertible to an integer, the default value is returned. 111 * 112 * @param request the servlet request from which to read the parameter 113 * @param param the name of the parameter 114 * @param defaultValue a default value 115 * @return the request parameter value as an integer 116 */ 117 public static int get( 118 HttpServletRequest request, String param, int defaultValue) { 119 120 return GetterUtil.get(request.getParameter(param), defaultValue); 121 } 122 123 /** 124 * Returns the request parameter value as a long. If the parameter is 125 * missing or not convertible to a long, the default value is returned. 126 * 127 * @param request the servlet request from which to read the parameter 128 * @param param the name of the parameter 129 * @param defaultValue a default value 130 * @return the request parameter value as a long 131 */ 132 public static long get( 133 HttpServletRequest request, String param, long defaultValue) { 134 135 return GetterUtil.get(request.getParameter(param), defaultValue); 136 } 137 138 /** 139 * Returns the request parameter value as a Number. If the parameter is 140 * missing or not convertible to a Number, the default value is returned. 141 * 142 * @param request the servlet request from which to read the parameter 143 * @param param the name of the parameter 144 * @param defaultValue a default value 145 * @return the request parameter value as a Number 146 */ 147 public static Number get( 148 HttpServletRequest request, String param, Number defaultValue) { 149 150 return GetterUtil.get(request.getParameter(param), defaultValue); 151 } 152 153 /** 154 * Returns the request parameter value as a short. If the parameter is 155 * missing or not convertible to a short, the default value is returned. 156 * 157 * @param request the servlet request from which to read the parameter 158 * @param param the name of the parameter 159 * @param defaultValue a default value 160 * @return the request parameter value as a short 161 */ 162 public static short get( 163 HttpServletRequest request, String param, short defaultValue) { 164 165 return GetterUtil.get(request.getParameter(param), defaultValue); 166 } 167 168 /** 169 * Returns the request parameter value as a String. If the parameter is 170 * missing or not convertible to a String, the default value is returned. 171 * 172 * @param request the servlet request from which to read the parameter 173 * @param param the name of the parameter 174 * @param defaultValue a default value 175 * @return the request parameter value as a String 176 */ 177 public static String get( 178 HttpServletRequest request, String param, String defaultValue) { 179 180 String returnValue = GetterUtil.get( 181 request.getParameter(param), defaultValue); 182 183 if (returnValue != null) { 184 return returnValue.trim(); 185 } 186 187 return null; 188 } 189 190 /** 191 * Returns the portlet request parameter value as a boolean. If the 192 * parameter is missing, the default value is returned. 193 * 194 * <p> 195 * If the value is not convertible to a boolean, <code>false</code> is 196 * returned. 197 * </p> 198 * 199 * @param portletRequest the portlet request from which to read the 200 * parameter 201 * @param param the name of the parameter 202 * @param defaultValue a default value 203 * @return the portlet request parameter value as a boolean 204 */ 205 public static boolean get( 206 PortletRequest portletRequest, String param, boolean defaultValue) { 207 208 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 209 } 210 211 /** 212 * Returns the portlet request parameter value as a Date. If the parameter 213 * is missing or not convertible to a Date, the default value is returned. 214 * 215 * @param portletRequest the portlet request from which to read the 216 * parameter 217 * @param param the name of the parameter 218 * @param dateFormat the format used to parse date 219 * @param defaultValue a default value 220 * @return the portlet request parameter value as a Date 221 */ 222 public static Date get( 223 PortletRequest portletRequest, String param, DateFormat dateFormat, 224 Date defaultValue) { 225 226 return GetterUtil.get( 227 portletRequest.getParameter(param), dateFormat, defaultValue); 228 } 229 230 /** 231 * Returns the portlet request parameter value as a double. If the parameter 232 * is missing or not convertible to a double, the default value is returned. 233 * 234 * @param portletRequest the portlet request from which to read the 235 * parameter 236 * @param param the name of the parameter 237 * @param defaultValue a default value 238 * @return the portlet request parameter value as a double 239 */ 240 public static double get( 241 PortletRequest portletRequest, String param, double defaultValue) { 242 243 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 244 } 245 246 /** 247 * Returns the portlet request parameter value as a float. If the parameter 248 * is missing or not convertible to a float, the default value is returned. 249 * 250 * @param portletRequest the portlet request from which to read the 251 * parameter 252 * @param param the name of the parameter 253 * @param defaultValue a default value 254 * @return the portlet request parameter value as a float 255 */ 256 public static float get( 257 PortletRequest portletRequest, String param, float defaultValue) { 258 259 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 260 } 261 262 /** 263 * Returns the portlet request parameter value as an integer. If the 264 * parameter is missing or not convertible to an integer, the default value 265 * is returned. 266 * 267 * @param portletRequest the portlet request from which to read the 268 * parameter 269 * @param param the name of the parameter 270 * @param defaultValue a default value 271 * @return the portlet request parameter value as an integer 272 */ 273 public static int get( 274 PortletRequest portletRequest, String param, int defaultValue) { 275 276 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 277 } 278 279 /** 280 * Returns the portlet request parameter value as a long. If the parameter 281 * is missing or not convertible to a long, the default value is returned. 282 * 283 * @param portletRequest the portlet request from which to read the 284 * parameter 285 * @param param the name of the parameter 286 * @param defaultValue a default value 287 * @return the portlet request parameter value as a long 288 */ 289 public static long get( 290 PortletRequest portletRequest, String param, long defaultValue) { 291 292 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 293 } 294 295 /** 296 * Returns the portlet request parameter value as a Number. If the parameter 297 * is missing or not convertible to a Number, the default value is returned. 298 * 299 * @param portletRequest the portlet request from which to read the 300 * parameter 301 * @param param the name of the parameter 302 * @param defaultValue a default value 303 * @return the portlet request parameter value as a Number 304 */ 305 public static Number get( 306 PortletRequest portletRequest, String param, Number defaultValue) { 307 308 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 309 } 310 311 /** 312 * Returns the portlet request parameter value as a short. If the parameter 313 * is missing or not convertible to a short, the default value is returned. 314 * 315 * @param portletRequest the portlet request from which to read the 316 * parameter 317 * @param param the name of the parameter 318 * @param defaultValue a default value 319 * @return the portlet request parameter value as a short 320 */ 321 public static short get( 322 PortletRequest portletRequest, String param, short defaultValue) { 323 324 return GetterUtil.get(portletRequest.getParameter(param), defaultValue); 325 } 326 327 /** 328 * Returns the portlet request parameter value as a String. If the parameter 329 * is missing or not convertible to a String, the default value is returned. 330 * 331 * @param portletRequest the portlet request from which to read the 332 * parameter 333 * @param param the name of the parameter 334 * @param defaultValue a default value 335 * @return the portlet request parameter value as a String 336 */ 337 public static String get( 338 PortletRequest portletRequest, String param, String defaultValue) { 339 340 String returnValue = GetterUtil.get( 341 portletRequest.getParameter(param), defaultValue); 342 343 if (returnValue != null) { 344 return returnValue.trim(); 345 } 346 347 return null; 348 } 349 350 /** 351 * Returns the service context parameter value as a boolean. If the 352 * parameter is missing, the default value is returned. 353 * 354 * <p> 355 * If the value is not convertible to a boolean, <code>false</code> is 356 * returned. 357 * </p> 358 * 359 * @param serviceContext the service context from which to read the 360 * parameter 361 * @param param the name of the parameter 362 * @param defaultValue a default value 363 * @return the service context parameter value as a boolean 364 */ 365 public static boolean get( 366 ServiceContext serviceContext, String param, boolean defaultValue) { 367 368 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 369 } 370 371 /** 372 * Returns the service context parameter value as a Date. If the parameter 373 * is missing or not convertible to a Date, the default value is returned. 374 * 375 * @param serviceContext the service context from which to read the 376 * parameter 377 * @param param the name of the parameter 378 * @param dateFormat the format used to parse date 379 * @param defaultValue a default value 380 * @return the service context parameter value as a Date 381 */ 382 public static Date get( 383 ServiceContext serviceContext, String param, DateFormat dateFormat, 384 Date defaultValue) { 385 386 return GetterUtil.get( 387 serviceContext.getAttribute(param), dateFormat, defaultValue); 388 } 389 390 /** 391 * Returns the service context parameter value as a double. If the parameter 392 * is missing or not convertible to a double, the default value is returned. 393 * 394 * @param serviceContext the service context from which to read the 395 * parameter 396 * @param param the name of the parameter 397 * @param defaultValue a default value 398 * @return the service context parameter value as a double 399 */ 400 public static double get( 401 ServiceContext serviceContext, String param, double defaultValue) { 402 403 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 404 } 405 406 /** 407 * Returns the service context parameter value as a float. If the parameter 408 * is missing or not convertible to a float, the default value is returned. 409 * 410 * @param serviceContext the service context from which to read the 411 * parameter 412 * @param param the name of the parameter 413 * @param defaultValue a default value 414 * @return the service context parameter value as a float 415 */ 416 public static float get( 417 ServiceContext serviceContext, String param, float defaultValue) { 418 419 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 420 } 421 422 /** 423 * Returns the service context parameter value as an integer. If the 424 * parameter is missing or not convertible to an integer, the default value 425 * is returned. 426 * 427 * @param serviceContext the service context from which to read the 428 * parameter 429 * @param param the name of the parameter 430 * @param defaultValue a default value 431 * @return the service context parameter value as an integer 432 */ 433 public static int get( 434 ServiceContext serviceContext, String param, int defaultValue) { 435 436 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 437 } 438 439 /** 440 * Returns the service context parameter value as a long. If the parameter 441 * is missing or not convertible to a long, the default value is returned. 442 * 443 * @param serviceContext the service context from which to read the 444 * parameter 445 * @param param the name of the parameter 446 * @param defaultValue a default value 447 * @return the service context parameter value as a long 448 */ 449 public static long get( 450 ServiceContext serviceContext, String param, long defaultValue) { 451 452 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 453 } 454 455 /** 456 * Returns the service context parameter value as a Number. If the parameter 457 * is missing or not convertible to a Number, the default value is returned. 458 * 459 * @param serviceContext the service context from which to read the 460 * parameter 461 * @param param the name of the parameter 462 * @param defaultValue a default value 463 * @return the service context parameter value as a Number 464 */ 465 public static Number get( 466 ServiceContext serviceContext, String param, Number defaultValue) { 467 468 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 469 } 470 471 /** 472 * Returns the service context parameter value as a short. If the parameter 473 * is missing or not convertible to a short, the default value is returned. 474 * 475 * @param serviceContext the service context from which to read the 476 * parameter 477 * @param param the name of the parameter 478 * @param defaultValue a default value 479 * @return the service context parameter value as a short 480 */ 481 public static short get( 482 ServiceContext serviceContext, String param, short defaultValue) { 483 484 return GetterUtil.get(serviceContext.getAttribute(param), defaultValue); 485 } 486 487 /** 488 * Returns the service context parameter value as a String. If the parameter 489 * is missing or not convertible to a String, the default value is returned. 490 * 491 * @param serviceContext the service context from which to read the 492 * parameter 493 * @param param the name of the parameter 494 * @param defaultValue a default value 495 * @return the service context parameter value as a String 496 */ 497 public static String get( 498 ServiceContext serviceContext, String param, String defaultValue) { 499 500 String returnValue = GetterUtil.get( 501 serviceContext.getAttribute(param), defaultValue); 502 503 if (returnValue != null) { 504 return returnValue.trim(); 505 } 506 507 return null; 508 } 509 510 /** 511 * Returns the request parameter value as a boolean. If the parameter is 512 * missing or not convertible to a boolean, <code>false</code> is returned. 513 * 514 * @param request the servlet request from which to read the parameter 515 * @param param the name of the parameter 516 * @return the request parameter value as a boolean 517 */ 518 public static boolean getBoolean(HttpServletRequest request, String param) { 519 return GetterUtil.getBoolean(request.getParameter(param)); 520 } 521 522 /** 523 * Returns the request parameter value as a boolean. If the parameter is 524 * missing, the default value is returned. 525 * 526 * <p> 527 * If the value is not convertible to a boolean, <code>false</code> is 528 * returned. 529 * </p> 530 * 531 * @param request the servlet request from which to read the parameter 532 * @param param the name of the parameter 533 * @param defaultValue a default value 534 * @return the request parameter value as a boolean 535 */ 536 public static boolean getBoolean( 537 HttpServletRequest request, String param, boolean defaultValue) { 538 539 return get(request, param, defaultValue); 540 } 541 542 /** 543 * Returns the portlet request parameter value as a boolean. If the 544 * parameter is missing or not convertible to a boolean, <code>false</code> 545 * is returned. 546 * 547 * @param portletRequest the portlet request from which to read the 548 * parameter 549 * @param param the name of the parameter 550 * @return the portlet request parameter value as a boolean 551 */ 552 public static boolean getBoolean( 553 PortletRequest portletRequest, String param) { 554 555 return GetterUtil.getBoolean(portletRequest.getParameter(param)); 556 } 557 558 /** 559 * Returns the portlet request parameter value as a boolean. If the 560 * parameter is missing, the default value is returned. 561 * 562 * <p> 563 * If the value is not convertible to a boolean, <code>false</code> is 564 * returned. 565 * </p> 566 * 567 * @param portletRequest the portlet request from which to read the 568 * parameter 569 * @param param the name of the parameter 570 * @param defaultValue a default value 571 * @return the portlet request parameter value as a boolean 572 */ 573 public static boolean getBoolean( 574 PortletRequest portletRequest, String param, boolean defaultValue) { 575 576 return get(portletRequest, param, defaultValue); 577 } 578 579 /** 580 * Returns the service context parameter value as a boolean. If the 581 * parameter is missing or not convertible to a boolean, <code>false</code> 582 * is returned. 583 * 584 * @param serviceContext the service context from which to read the 585 * parameter 586 * @param param the name of the parameter 587 * @return the service context parameter value as a boolean 588 */ 589 public static boolean getBoolean( 590 ServiceContext serviceContext, String param) { 591 592 return GetterUtil.getBoolean(serviceContext.getAttribute(param)); 593 } 594 595 /** 596 * Returns the service context parameter value as a boolean. If the 597 * parameter is missing, the default value is returned. 598 * 599 * <p> 600 * If the value is not convertible to a boolean, <code>false</code> is 601 * returned. 602 * </p> 603 * 604 * @param serviceContext the service context from which to read the 605 * parameter 606 * @param param the name of the parameter 607 * @param defaultValue a default value 608 * @return the service context parameter value as a boolean 609 */ 610 public static boolean getBoolean( 611 ServiceContext serviceContext, String param, boolean defaultValue) { 612 613 return get(serviceContext, param, defaultValue); 614 } 615 616 /** 617 * Returns the request parameter value as a boolean array. In the returned 618 * array, each parameter value not convertible to a boolean is replaced by 619 * <code>false</code>. 620 * 621 * @param request the servlet request from which to read the parameter 622 * @param param the name of the parameter 623 * @return the request parameter value as a boolean array 624 */ 625 public static boolean[] getBooleanValues( 626 HttpServletRequest request, String param) { 627 628 return getBooleanValues(request, param, new boolean[0]); 629 } 630 631 /** 632 * Returns the request parameter value as a boolean array. In the returned 633 * array, each parameter value not convertible to a boolean is replaced by 634 * the default value. 635 * 636 * @param request the servlet request from which to read the parameter 637 * @param param the name of the parameter 638 * @param defaultValue a default value 639 * @return the request parameter value as a boolean array 640 */ 641 public static boolean[] getBooleanValues( 642 HttpServletRequest request, String param, boolean[] defaultValue) { 643 644 return GetterUtil.getBooleanValues( 645 getParameterValues(request, param, null), defaultValue); 646 } 647 648 /** 649 * Returns the portlet request parameter value as a boolean array. In the 650 * returned array, each parameter value not convertible to a boolean is 651 * replaced by <code>false</code>. 652 * 653 * @param portletRequest the portlet request from which to read the 654 * parameter 655 * @param param the name of the parameter 656 * @return the portlet request parameter value as a boolean array 657 */ 658 public static boolean[] getBooleanValues( 659 PortletRequest portletRequest, String param) { 660 661 return getBooleanValues(portletRequest, param, new boolean[0]); 662 } 663 664 /** 665 * Returns the portlet request parameter value as a boolean array. In the 666 * returned array, each parameter value not convertible to a boolean is 667 * replaced by the default value. 668 * 669 * @param portletRequest the portlet request from which to read the 670 * parameter 671 * @param param the name of the parameter 672 * @param defaultValue a default value 673 * @return the portlet request parameter value as a boolean array 674 */ 675 public static boolean[] getBooleanValues( 676 PortletRequest portletRequest, String param, boolean[] defaultValue) { 677 678 return GetterUtil.getBooleanValues( 679 getParameterValues(portletRequest, param, null), defaultValue); 680 } 681 682 /** 683 * Returns the service context parameter value as a boolean array. In the 684 * returned array, each parameter value not convertible to a boolean is 685 * replaced by <code>false</code>. 686 * 687 * @param serviceContext the service context from which to read the 688 * parameter 689 * @param param the name of the parameter 690 * @return the service context parameter value as a boolean array 691 */ 692 public static boolean[] getBooleanValues( 693 ServiceContext serviceContext, String param) { 694 695 return getBooleanValues(serviceContext, param, new boolean[0]); 696 } 697 698 /** 699 * Returns the service context parameter value as a boolean array. In the 700 * returned array, each parameter value not convertible to a boolean is 701 * replaced by the default value. 702 * 703 * @param serviceContext the service context from which to read the 704 * parameter 705 * @param param the name of the parameter 706 * @param defaultValue a default value 707 * @return the service context parameter value as a boolean array 708 */ 709 public static boolean[] getBooleanValues( 710 ServiceContext serviceContext, String param, boolean[] defaultValue) { 711 712 return GetterUtil.getBooleanValues( 713 serviceContext.getAttribute(param), defaultValue); 714 } 715 716 /** 717 * Returns the request parameter value as a Date. If the parameter is 718 * missing or not convertible to a Date, the current date is returned. 719 * 720 * @param request the servlet request from which to read the parameter 721 * @param param the name of the parameter 722 * @param dateFormat the format used to parse the date 723 * @return the request parameter value as a Date 724 */ 725 public static Date getDate( 726 HttpServletRequest request, String param, DateFormat dateFormat) { 727 728 return GetterUtil.getDate(request.getParameter(param), dateFormat); 729 } 730 731 /** 732 * Returns the request parameter value as a Date. If the parameter is 733 * missing or not convertible to a Date, the default value is returned. 734 * 735 * @param request the servlet request from which to read the parameter 736 * @param param the name of the parameter 737 * @param dateFormat the format used to parse the date 738 * @param defaultValue a default value 739 * @return the request parameter value as a Date 740 */ 741 public static Date getDate( 742 HttpServletRequest request, String param, DateFormat dateFormat, 743 Date defaultValue) { 744 745 return get(request, param, dateFormat, defaultValue); 746 } 747 748 /** 749 * Returns the portlet request parameter value as a Date. If the parameter 750 * is missing or not convertible to a Date, the current date is returned. 751 * 752 * @param portletRequest the portlet request from which to read the 753 * parameter 754 * @param param the name of the parameter 755 * @param dateFormat the format used to parse the date 756 * @return the portlet request parameter value as a Date 757 */ 758 public static Date getDate( 759 PortletRequest portletRequest, String param, DateFormat dateFormat) { 760 761 return GetterUtil.getDate( 762 portletRequest.getParameter(param), dateFormat); 763 } 764 765 /** 766 * Returns the portlet request parameter value as a Date. If the parameter 767 * is missing or not convertible to a Date, the default value is returned. 768 * 769 * @param portletRequest the portlet request from which to read the 770 * parameter 771 * @param param the name of the parameter 772 * @param dateFormat the format used to parse the date 773 * @param defaultValue a default value 774 * @return the portlet request parameter value as a Date 775 */ 776 public static Date getDate( 777 PortletRequest portletRequest, String param, DateFormat dateFormat, 778 Date defaultValue) { 779 780 return get(portletRequest, param, dateFormat, defaultValue); 781 } 782 783 /** 784 * Returns the service context parameter value as a Date. If the parameter 785 * is missing or not convertible to a Date, the current date is returned. 786 * 787 * @param serviceContext the service context from which to read the 788 * parameter 789 * @param param the name of the parameter 790 * @param dateFormat the format used to parse the date 791 * @return the service context parameter value as a Date 792 */ 793 public static Date getDate( 794 ServiceContext serviceContext, String param, DateFormat dateFormat) { 795 796 return GetterUtil.getDate( 797 serviceContext.getAttribute(param), dateFormat); 798 } 799 800 /** 801 * Returns the service context parameter value as a Date. If the parameter 802 * is missing or not convertible to a Date, the default value is returned. 803 * 804 * @param serviceContext the service context from which to read the 805 * parameter 806 * @param param the name of the parameter 807 * @param dateFormat the format used to parse the date 808 * @param defaultValue a default value 809 * @return the service context parameter value as a Date 810 */ 811 public static Date getDate( 812 ServiceContext serviceContext, String param, DateFormat dateFormat, 813 Date defaultValue) { 814 815 return get(serviceContext, param, dateFormat, defaultValue); 816 } 817 818 /** 819 * Returns the request parameter value as a Date array. In the returned 820 * array, each parameter value not convertible to a Date is replaced by the 821 * current date. 822 * 823 * @param request the servlet request from which to read the parameter 824 * @param param the name of the parameter 825 * @param dateFormat the format used to parse the date 826 * @return the request parameter value as a Date array 827 */ 828 public static Date[] getDateValues( 829 HttpServletRequest request, String param, DateFormat dateFormat) { 830 831 return getDateValues(request, param, dateFormat, new Date[0]); 832 } 833 834 /** 835 * Returns the request parameter value as a Date array. In the returned 836 * array, each parameter value not convertible to a Date is replaced by the 837 * default value. 838 * 839 * @param request the servlet request from which to read the parameter 840 * @param param the name of the parameter 841 * @param dateFormat the format used to parse the date 842 * @param defaultValue a default value 843 * @return the request parameter value as a Date array 844 */ 845 public static Date[] getDateValues( 846 HttpServletRequest request, String param, DateFormat dateFormat, 847 Date[] defaultValue) { 848 849 return GetterUtil.getDateValues( 850 getParameterValues(request, param, null), dateFormat, defaultValue); 851 } 852 853 /** 854 * Returns the portlet request parameter value as a Date array. In the 855 * returned array, each parameter value not convertible to a Date is 856 * replaced by the current date. 857 * 858 * @param portletRequest the portlet request from which to read the 859 * parameter 860 * @param param the name of the parameter 861 * @param dateFormat the format used to parse the date 862 * @return the portlet request parameter value as a Date array 863 */ 864 public static Date[] getDateValues( 865 PortletRequest portletRequest, String param, DateFormat dateFormat) { 866 867 return getDateValues(portletRequest, param, dateFormat, new Date[0]); 868 } 869 870 /** 871 * Returns the portlet request parameter value as a Date array. In the 872 * returned array, each parameter value not convertible to a Date is 873 * replaced by the default value. 874 * 875 * @param portletRequest the portlet request from which to read the 876 * parameter 877 * @param param the name of the parameter 878 * @param dateFormat the format used to parse the date 879 * @param defaultValue a default value 880 * @return the portlet request parameter value as a Date array 881 */ 882 public static Date[] getDateValues( 883 PortletRequest portletRequest, String param, DateFormat dateFormat, 884 Date[] defaultValue) { 885 886 return GetterUtil.getDateValues( 887 getParameterValues(portletRequest, param, null), dateFormat, 888 defaultValue); 889 } 890 891 /** 892 * Returns the service context parameter value as a Date array. In the 893 * returned array, each parameter value not convertible to a Date is 894 * replaced by the current date. 895 * 896 * @param serviceContext the service context from which to read the 897 * parameter 898 * @param param the name of the parameter 899 * @param dateFormat the format used to parse the date 900 * @return the service context parameter value as a Date array 901 */ 902 public static Date[] getDateValues( 903 ServiceContext serviceContext, String param, DateFormat dateFormat) { 904 905 return getDateValues(serviceContext, param, dateFormat, new Date[0]); 906 } 907 908 /** 909 * Returns the service context parameter value as a Date array. In the 910 * returned array, each parameter value not convertible to a Date is 911 * replaced by the default value. 912 * 913 * @param serviceContext the service context from which to read the 914 * parameter 915 * @param param the name of the parameter 916 * @param dateFormat the format used to parse the date 917 * @param defaultValue a default value 918 * @return the service context parameter value as a Date array 919 */ 920 public static Date[] getDateValues( 921 ServiceContext serviceContext, String param, DateFormat dateFormat, 922 Date[] defaultValue) { 923 924 return GetterUtil.getDateValues( 925 serviceContext.getAttribute(param), dateFormat, defaultValue); 926 } 927 928 /** 929 * Returns the request parameter value as a double. If the parameter is 930 * missing or not convertible to a double, <code>0</code> is returned. 931 * 932 * @param request the servlet request from which to read the parameter 933 * @param param the name of the parameter 934 * @return the request parameter value as a double 935 */ 936 public static double getDouble(HttpServletRequest request, String param) { 937 return GetterUtil.getDouble(request.getParameter(param)); 938 } 939 940 /** 941 * Returns the request parameter value as a double. If the parameter is 942 * missing or not convertible to a double, the default value is returned. 943 * 944 * @param request the servlet request from which to read the parameter 945 * @param param the name of the parameter 946 * @param defaultValue a default value 947 * @return the request parameter value as a double 948 */ 949 public static double getDouble( 950 HttpServletRequest request, String param, double defaultValue) { 951 952 return get(request, param, defaultValue); 953 } 954 955 /** 956 * Returns the request parameter value as a double. If the parameter is 957 * missing or not convertible to a double, the default value is returned. 958 * 959 * @param request the servlet request from which to read the parameter 960 * @param param the name of the parameter 961 * @param defaultValue a default value 962 * @param locale the locale used to parse the double value 963 * @return the request parameter value as a double 964 */ 965 public static double getDouble( 966 HttpServletRequest request, String param, double defaultValue, 967 Locale locale) { 968 969 return GetterUtil.get( 970 request.getParameter(param), defaultValue, locale); 971 } 972 973 /** 974 * Returns the request parameter value as a double. If the parameter is 975 * missing or not convertible to a double, <code>0</code> is returned. 976 * 977 * @param request the servlet request from which to read the parameter 978 * @param param the name of the parameter 979 * @param locale the locale used to parse the double value 980 * @return the request parameter value as a double 981 */ 982 public static double getDouble( 983 HttpServletRequest request, String param, Locale locale) { 984 985 return GetterUtil.getDouble(request.getParameter(param), locale); 986 } 987 988 /** 989 * Returns the portlet request parameter value as a double. If the parameter 990 * is missing or not convertible to a double, <code>0</code> is returned. 991 * 992 * @param portletRequest the portlet request from which to read the 993 * parameter 994 * @param param the name of the parameter 995 * @return the portlet request parameter value as a double 996 */ 997 public static double getDouble( 998 PortletRequest portletRequest, String param) { 999 1000 return GetterUtil.getDouble(portletRequest.getParameter(param)); 1001 } 1002 1003 /** 1004 * Returns the portlet request parameter value as a double. If the parameter 1005 * is missing or not convertible to a double, the default value is returned. 1006 * 1007 * @param portletRequest the portlet request from which to read the 1008 * parameter 1009 * @param param the name of the parameter 1010 * @param defaultValue a default value 1011 * @return the portlet request parameter value as a double 1012 */ 1013 public static double getDouble( 1014 PortletRequest portletRequest, String param, double defaultValue) { 1015 1016 return get(portletRequest, param, defaultValue); 1017 } 1018 1019 /** 1020 * Returns the portlet request parameter value as a double. If the parameter 1021 * is missing or not convertible to a double, the default value is returned. 1022 * 1023 * @param portletRequest the portlet request from which to read the 1024 * parameter 1025 * @param param the name of the parameter 1026 * @param defaultValue a default value 1027 * @param locale the locale used to parse the double value 1028 * @return the portlet request parameter value as a double 1029 */ 1030 public static double getDouble( 1031 PortletRequest portletRequest, String param, double defaultValue, 1032 Locale locale) { 1033 1034 return GetterUtil.get( 1035 portletRequest.getParameter(param), defaultValue, locale); 1036 } 1037 1038 /** 1039 * Returns the portlet request parameter value as a double. If the parameter 1040 * is missing or not convertible to a double, <code>0</code> is returned. 1041 * 1042 * @param portletRequest the portlet request from which to read the 1043 * parameter 1044 * @param param the name of the parameter 1045 * @param locale the locale used to parse the double value 1046 * @return the portlet request parameter value as a double 1047 */ 1048 public static double getDouble( 1049 PortletRequest portletRequest, String param, Locale locale) { 1050 1051 return GetterUtil.getDouble(portletRequest.getParameter(param), locale); 1052 } 1053 1054 /** 1055 * Returns the service context parameter value as a double. If the parameter 1056 * is missing or not convertible to a double, <code>0</code> is returned. 1057 * 1058 * @param serviceContext the service context from which to read the 1059 * parameter 1060 * @param param the name of the parameter 1061 * @return the service context parameter value as a double 1062 */ 1063 public static double getDouble( 1064 ServiceContext serviceContext, String param) { 1065 1066 return GetterUtil.getDouble(serviceContext.getAttribute(param)); 1067 } 1068 1069 /** 1070 * Returns the service context parameter value as a double. If the parameter 1071 * is missing or not convertible to a double, the default value is returned. 1072 * 1073 * @param serviceContext the service context from which to read the 1074 * parameter 1075 * @param param the name of the parameter 1076 * @param defaultValue a default value 1077 * @return the service context parameter value as a double 1078 */ 1079 public static double getDouble( 1080 ServiceContext serviceContext, String param, double defaultValue) { 1081 1082 return get(serviceContext, param, defaultValue); 1083 } 1084 1085 /** 1086 * Returns the request parameter value as a double array. In the returned 1087 * array, each parameter value not convertible to a double is replaced by 1088 * <code>0</code>. 1089 * 1090 * @param request the servlet request from which to read the parameter 1091 * @param param the name of the parameter 1092 * @return the request parameter value as a double array 1093 */ 1094 public static double[] getDoubleValues( 1095 HttpServletRequest request, String param) { 1096 1097 return getDoubleValues(request, param, new double[0]); 1098 } 1099 1100 /** 1101 * Returns the request parameter value as a double array. In the returned 1102 * array, each parameter value not convertible to a double is replaced by 1103 * the default value. 1104 * 1105 * @param request the servlet request from which to read the parameter 1106 * @param param the name of the parameter 1107 * @param defaultValue a default value 1108 * @return the request parameter value as a double array 1109 */ 1110 public static double[] getDoubleValues( 1111 HttpServletRequest request, String param, double[] defaultValue) { 1112 1113 return GetterUtil.getDoubleValues( 1114 getParameterValues(request, param, null), defaultValue); 1115 } 1116 1117 /** 1118 * Returns the portlet request parameter value as a double array. In the 1119 * returned array, each parameter value not convertible to a double is 1120 * replaced by <code>0</code>. 1121 * 1122 * @param portletRequest the portlet request from which to read the 1123 * parameter 1124 * @param param the name of the parameter 1125 * @return the portlet request parameter value as a double array 1126 */ 1127 public static double[] getDoubleValues( 1128 PortletRequest portletRequest, String param) { 1129 1130 return getDoubleValues(portletRequest, param, new double[0]); 1131 } 1132 1133 /** 1134 * Returns the portlet request parameter value as a double array. In the 1135 * returned array, each parameter value not convertible to a double is 1136 * replaced by the default value. 1137 * 1138 * @param portletRequest the portlet request from which to read the 1139 * parameter 1140 * @param param the name of the parameter 1141 * @param defaultValue a default value 1142 * @return the portlet request parameter value as a double array 1143 */ 1144 public static double[] getDoubleValues( 1145 PortletRequest portletRequest, String param, double[] defaultValue) { 1146 1147 return GetterUtil.getDoubleValues( 1148 getParameterValues(portletRequest, param, null), defaultValue); 1149 } 1150 1151 /** 1152 * Returns the service context parameter value as a double array. In the 1153 * returned array, each parameter value not convertible to a double is 1154 * replaced by <code>0</code>. 1155 * 1156 * @param serviceContext the service context from which to read the 1157 * parameter 1158 * @param param the name of the parameter 1159 * @return the service context parameter value as a double array 1160 */ 1161 public static double[] getDoubleValues( 1162 ServiceContext serviceContext, String param) { 1163 1164 return getDoubleValues(serviceContext, param, new double[0]); 1165 } 1166 1167 /** 1168 * Returns the service context parameter value as a double array. In the 1169 * returned array, each parameter value not convertible to a double is 1170 * replaced by the default value. 1171 * 1172 * @param serviceContext the service context from which to read the 1173 * parameter 1174 * @param param the name of the parameter 1175 * @param defaultValue a default value 1176 * @return the service context parameter value as a double array 1177 */ 1178 public static double[] getDoubleValues( 1179 ServiceContext serviceContext, String param, double[] defaultValue) { 1180 1181 return GetterUtil.getDoubleValues( 1182 serviceContext.getAttribute(param), defaultValue); 1183 } 1184 1185 /** 1186 * Returns the request parameter value as a float. If the parameter is 1187 * missing or not convertible to a float, <code>0</code> is returned. 1188 * 1189 * @param request the servlet request from which to read the parameter 1190 * @param param the name of the parameter 1191 * @return the request parameter value as a float 1192 */ 1193 public static float getFloat(HttpServletRequest request, String param) { 1194 return GetterUtil.getFloat(request.getParameter(param)); 1195 } 1196 1197 /** 1198 * Returns the request parameter value as a float. If the parameter is 1199 * missing or not convertible to a float, the default value is returned. 1200 * 1201 * @param request the servlet request from which to read the parameter 1202 * @param param the name of the parameter 1203 * @param defaultValue a default value 1204 * @return the request parameter value as a float 1205 */ 1206 public static float getFloat( 1207 HttpServletRequest request, String param, float defaultValue) { 1208 1209 return get(request, param, defaultValue); 1210 } 1211 1212 /** 1213 * Returns the portlet request parameter value as a float. If the parameter 1214 * is missing or not convertible to a float, <code>0</code> is returned. 1215 * 1216 * @param portletRequest the portlet request from which to read the 1217 * parameter 1218 * @param param the name of the parameter 1219 * @return the portlet request parameter value as a float 1220 */ 1221 public static float getFloat(PortletRequest portletRequest, String param) { 1222 return GetterUtil.getFloat(portletRequest.getParameter(param)); 1223 } 1224 1225 /** 1226 * Returns the portlet request parameter value as a float. If the parameter 1227 * is missing or not convertible to a float, the default value is returned. 1228 * 1229 * @param portletRequest the portlet request from which to read the 1230 * parameter 1231 * @param param the name of the parameter 1232 * @param defaultValue a default value 1233 * @return the portlet request parameter value as a float 1234 */ 1235 public static float getFloat( 1236 PortletRequest portletRequest, String param, float defaultValue) { 1237 1238 return get(portletRequest, param, defaultValue); 1239 } 1240 1241 /** 1242 * Returns the service context parameter value as a float. If the parameter 1243 * is missing or not convertible to a float, <code>0</code> is returned. 1244 * 1245 * @param serviceContext the service context from which to read the 1246 * parameter 1247 * @param param the name of the parameter 1248 * @return the service context parameter value as a float 1249 */ 1250 public static float getFloat(ServiceContext serviceContext, String param) { 1251 return GetterUtil.getFloat(serviceContext.getAttribute(param)); 1252 } 1253 1254 /** 1255 * Returns the service context parameter value as a float. If the parameter 1256 * is missing or not convertible to a float, the default value is returned. 1257 * 1258 * @param serviceContext the service context from which to read the 1259 * parameter 1260 * @param param the name of the parameter 1261 * @param defaultValue a default value 1262 * @return the service context parameter value as a float 1263 */ 1264 public static float getFloat( 1265 ServiceContext serviceContext, String param, float defaultValue) { 1266 1267 return get(serviceContext, param, defaultValue); 1268 } 1269 1270 /** 1271 * Returns the request parameter value as a float array. In the returned 1272 * array, each parameter value not convertible to a float is replaced by 1273 * <code>0</code>. 1274 * 1275 * @param request the servlet request from which to read the parameter 1276 * @param param the name of the parameter 1277 * @return the request parameter value as a float array 1278 */ 1279 public static float[] getFloatValues( 1280 HttpServletRequest request, String param) { 1281 1282 return getFloatValues(request, param, new float[0]); 1283 } 1284 1285 /** 1286 * Returns the request parameter value as a float array. In the returned 1287 * array, each parameter value not convertible to a float is replaced by the 1288 * default value. 1289 * 1290 * @param request the servlet request from which to read the parameter 1291 * @param param the name of the parameter 1292 * @param defaultValue a default value 1293 * @return the request parameter value as a float array 1294 */ 1295 public static float[] getFloatValues( 1296 HttpServletRequest request, String param, float[] defaultValue) { 1297 1298 return GetterUtil.getFloatValues( 1299 getParameterValues(request, param, null), defaultValue); 1300 } 1301 1302 /** 1303 * Returns the portlet request parameter value as a float array. In the 1304 * returned array, each parameter value not convertible to a float is 1305 * replaced by <code>0</code>. 1306 * 1307 * @param portletRequest the portlet request from which to read the 1308 * parameter 1309 * @param param the name of the parameter 1310 * @return the portlet request parameter value as a float array 1311 */ 1312 public static float[] getFloatValues( 1313 PortletRequest portletRequest, String param) { 1314 1315 return getFloatValues(portletRequest, param, new float[0]); 1316 } 1317 1318 /** 1319 * Returns the portlet request parameter value as a float array. In the 1320 * returned array, each parameter value not convertible to a float is 1321 * replaced by the default value. 1322 * 1323 * @param portletRequest the portlet request from which to read the 1324 * parameter 1325 * @param param the name of the parameter 1326 * @param defaultValue a default value 1327 * @return the portlet request parameter value as a float array 1328 */ 1329 public static float[] getFloatValues( 1330 PortletRequest portletRequest, String param, float[] defaultValue) { 1331 1332 return GetterUtil.getFloatValues( 1333 getParameterValues(portletRequest, param, null), defaultValue); 1334 } 1335 1336 /** 1337 * Returns the service context parameter value as a float array. In the 1338 * returned array, each parameter value not convertible to a float is 1339 * replaced by <code>0</code>. 1340 * 1341 * @param serviceContext the service context from which to read the 1342 * parameter 1343 * @param param the name of the parameter 1344 * @return the service context parameter value as a float array 1345 */ 1346 public static float[] getFloatValues( 1347 ServiceContext serviceContext, String param) { 1348 1349 return getFloatValues(serviceContext, param, new float[0]); 1350 } 1351 1352 /** 1353 * Returns the service context parameter value as a float array. In the 1354 * returned array, each parameter value not convertible to a float is 1355 * replaced by the default value. 1356 * 1357 * @param serviceContext the service context from which to read the 1358 * parameter 1359 * @param param the name of the parameter 1360 * @param defaultValue a default value 1361 * @return the service context parameter value as a float array 1362 */ 1363 public static float[] getFloatValues( 1364 ServiceContext serviceContext, String param, float[] defaultValue) { 1365 1366 return GetterUtil.getFloatValues( 1367 serviceContext.getAttribute(param), defaultValue); 1368 } 1369 1370 /** 1371 * Returns the request parameter value as an integer. If the parameter is 1372 * missing or not convertible to an integer, <code>0</code> is returned. 1373 * 1374 * @param request the servlet request from which to read the parameter 1375 * @param param the name of the parameter 1376 * @return the request parameter value as an integer 1377 */ 1378 public static int getInteger(HttpServletRequest request, String param) { 1379 return GetterUtil.getInteger(request.getParameter(param)); 1380 } 1381 1382 /** 1383 * Returns the request parameter value as an integer. If the parameter is 1384 * missing or not convertible to an integer, the default value is returned. 1385 * 1386 * @param request the servlet request from which to read the parameter 1387 * @param param the name of the parameter 1388 * @param defaultValue a default value 1389 * @return the request parameter value as an integer 1390 */ 1391 public static int getInteger( 1392 HttpServletRequest request, String param, int defaultValue) { 1393 1394 return get(request, param, defaultValue); 1395 } 1396 1397 /** 1398 * Returns the portlet request parameter value as an integer. If the 1399 * parameter is missing or not convertible to an integer, <code>0</code> is 1400 * returned. 1401 * 1402 * @param portletRequest the portlet request from which to read the 1403 * parameter 1404 * @param param the name of the parameter 1405 * @return the portlet request parameter value as an integer 1406 */ 1407 public static int getInteger(PortletRequest portletRequest, String param) { 1408 return GetterUtil.getInteger(portletRequest.getParameter(param)); 1409 } 1410 1411 /** 1412 * Returns the portlet request parameter value as an integer. If the 1413 * parameter is missing or not convertible to an integer, the default value 1414 * is returned. 1415 * 1416 * @param portletRequest the portlet request from which to read the 1417 * parameter 1418 * @param param the name of the parameter 1419 * @param defaultValue a default value 1420 * @return the portlet request parameter value as an integer 1421 */ 1422 public static int getInteger( 1423 PortletRequest portletRequest, String param, int defaultValue) { 1424 1425 return get(portletRequest, param, defaultValue); 1426 } 1427 1428 /** 1429 * Returns the service context parameter value as an integer. If the 1430 * parameter is missing or not convertible to an integer, <code>0</code> is 1431 * returned. 1432 * 1433 * @param serviceContext the service context from which to read the 1434 * parameter 1435 * @param param the name of the parameter 1436 * @return the service context parameter value as an integer 1437 */ 1438 public static int getInteger(ServiceContext serviceContext, String param) { 1439 return GetterUtil.getInteger(serviceContext.getAttribute(param)); 1440 } 1441 1442 /** 1443 * Returns the service context parameter value as an integer. If the 1444 * parameter is missing or not convertible to an integer, the default value 1445 * is returned. 1446 * 1447 * @param serviceContext the service context from which to read the 1448 * parameter 1449 * @param param the name of the parameter 1450 * @param defaultValue a default value 1451 * @return the service context parameter value as an integer 1452 */ 1453 public static int getInteger( 1454 ServiceContext serviceContext, String param, int defaultValue) { 1455 1456 return get(serviceContext, param, defaultValue); 1457 } 1458 1459 /** 1460 * Returns the request parameter value as an integer array. In the returned 1461 * array, each parameter value not convertible to an integer is replaced by 1462 * <code>0</code>. 1463 * 1464 * @param request the servlet request from which to read the parameter 1465 * @param param the name of the parameter 1466 * @return the request parameter value as an integer 1467 */ 1468 public static int[] getIntegerValues( 1469 HttpServletRequest request, String param) { 1470 1471 return getIntegerValues(request, param, new int[0]); 1472 } 1473 1474 /** 1475 * Returns the request parameter value as an integer array. In the returned 1476 * array, each parameter value not convertible to an integer is replaced by 1477 * the default value. 1478 * 1479 * @param request the servlet request from which to read the parameter 1480 * @param param the name of the parameter 1481 * @param defaultValue a default value 1482 * @return the request parameter value as an integer 1483 */ 1484 public static int[] getIntegerValues( 1485 HttpServletRequest request, String param, int[] defaultValue) { 1486 1487 return GetterUtil.getIntegerValues( 1488 getParameterValues(request, param, null), defaultValue); 1489 } 1490 1491 /** 1492 * Returns the portlet request parameter value as an integer array. In the 1493 * returned array, each parameter value not convertible to an integer is 1494 * replaced by <code>0</code>. 1495 * 1496 * @param portletRequest the portlet request from which to read the 1497 * parameter 1498 * @param param the name of the parameter 1499 * @return the portlet request parameter value as an integer 1500 */ 1501 public static int[] getIntegerValues( 1502 PortletRequest portletRequest, String param) { 1503 1504 return getIntegerValues(portletRequest, param, new int[0]); 1505 } 1506 1507 /** 1508 * Returns the portlet request parameter value as an integer array. In the 1509 * returned array, each parameter value not convertible to an integer is 1510 * replaced by the default value. 1511 * 1512 * @param portletRequest the portlet request from which to read the 1513 * parameter 1514 * @param param the name of the parameter 1515 * @param defaultValue a default value 1516 * @return the portlet request parameter value as an integer 1517 */ 1518 public static int[] getIntegerValues( 1519 PortletRequest portletRequest, String param, int[] defaultValue) { 1520 1521 return GetterUtil.getIntegerValues( 1522 getParameterValues(portletRequest, param, null), defaultValue); 1523 } 1524 1525 /** 1526 * Returns the service context parameter value as an integer array. In the 1527 * returned array, each parameter value not convertible to an integer is 1528 * replaced by <code>0</code>. 1529 * 1530 * @param serviceContext the service context from which to read the 1531 * parameter 1532 * @param param the name of the parameter 1533 * @return the service context parameter value as an integer 1534 */ 1535 public static int[] getIntegerValues( 1536 ServiceContext serviceContext, String param) { 1537 1538 return getIntegerValues(serviceContext, param, new int[0]); 1539 } 1540 1541 /** 1542 * Returns the service context parameter value as an integer array. In the 1543 * returned array, each parameter value not convertible to an integer is 1544 * replaced by the default value. 1545 * 1546 * @param serviceContext the service context from which to read the 1547 * parameter 1548 * @param param the name of the parameter 1549 * @param defaultValue a default value 1550 * @return the service context parameter value as an integer 1551 */ 1552 public static int[] getIntegerValues( 1553 ServiceContext serviceContext, String param, int[] defaultValue) { 1554 1555 return GetterUtil.getIntegerValues( 1556 serviceContext.getAttribute(param), defaultValue); 1557 } 1558 1559 /** 1560 * Returns the request parameter value as a long. If the parameter is 1561 * missing or not convertible to a long, <code>0</code> is returned. 1562 * 1563 * @param request the servlet request from which to read the parameter 1564 * @param param the name of the parameter 1565 * @return the request parameter value as a long 1566 */ 1567 public static long getLong(HttpServletRequest request, String param) { 1568 return GetterUtil.getLong(request.getParameter(param)); 1569 } 1570 1571 /** 1572 * Returns the request parameter value as a long. If the parameter is 1573 * missing or not convertible to a long, the default value is returned. 1574 * 1575 * @param request the servlet request from which to read the parameter 1576 * @param param the name of the parameter 1577 * @param defaultValue a default value 1578 * @return the request parameter value as a long 1579 */ 1580 public static long getLong( 1581 HttpServletRequest request, String param, long defaultValue) { 1582 1583 return get(request, param, defaultValue); 1584 } 1585 1586 /** 1587 * Returns the portlet request parameter value as a long. If the parameter 1588 * is missing or not convertible to a long, <code>0</code> is returned. 1589 * 1590 * @param portletRequest the portlet request from which to read the 1591 * parameter 1592 * @param param the name of the parameter 1593 * @return the portlet request parameter value as a long 1594 */ 1595 public static long getLong(PortletRequest portletRequest, String param) { 1596 return GetterUtil.getLong(portletRequest.getParameter(param)); 1597 } 1598 1599 /** 1600 * Returns the portlet request parameter value as a long. If the parameter 1601 * is missing or not convertible to a long, the default value is returned. 1602 * 1603 * @param portletRequest the portlet request from which to read the 1604 * parameter 1605 * @param param the name of the parameter 1606 * @param defaultValue a default value 1607 * @return the portlet request parameter value as a long 1608 */ 1609 public static long getLong( 1610 PortletRequest portletRequest, String param, long defaultValue) { 1611 1612 return get(portletRequest, param, defaultValue); 1613 } 1614 1615 /** 1616 * Returns the service context parameter value as a long. If the parameter 1617 * is missing or not convertible to a long, <code>0</code> is returned. 1618 * 1619 * @param serviceContext the service context from which to read the 1620 * parameter 1621 * @param param the name of the parameter 1622 * @return the service context parameter value as a long 1623 */ 1624 public static long getLong(ServiceContext serviceContext, String param) { 1625 return GetterUtil.getLong(serviceContext.getAttribute(param)); 1626 } 1627 1628 /** 1629 * Returns the service context parameter value as a long. If the parameter 1630 * is missing or not convertible to a long, the default value is returned. 1631 * 1632 * @param serviceContext the service context from which to read the 1633 * parameter 1634 * @param param the name of the parameter 1635 * @param defaultValue a default value 1636 * @return the service context parameter value as a long 1637 */ 1638 public static long getLong( 1639 ServiceContext serviceContext, String param, long defaultValue) { 1640 1641 return get(serviceContext, param, defaultValue); 1642 } 1643 1644 /** 1645 * Returns the request parameter value as a long array. In the returned 1646 * array, each parameter value not convertible to a long is replaced by 1647 * <code>0</code>. 1648 * 1649 * @param request the servlet request from which to read the parameter 1650 * @param param the name of the parameter 1651 * @return the request parameter value as a long array 1652 */ 1653 public static long[] getLongValues( 1654 HttpServletRequest request, String param) { 1655 1656 return getLongValues(request, param, new long[0]); 1657 } 1658 1659 /** 1660 * Returns the request parameter value as a long array. In the returned 1661 * array, each parameter value not convertible to a long is replaced by the 1662 * default value. 1663 * 1664 * @param request the servlet request from which to read the parameter 1665 * @param param the name of the parameter 1666 * @param defaultValue a default value 1667 * @return the request parameter value as a long array 1668 */ 1669 public static long[] getLongValues( 1670 HttpServletRequest request, String param, long[] defaultValue) { 1671 1672 return GetterUtil.getLongValues( 1673 getParameterValues(request, param, null), defaultValue); 1674 } 1675 1676 /** 1677 * Returns the portlet request parameter value as a long array. In the 1678 * returned array, each parameter value not convertible to a long is 1679 * replaced by <code>0</code>. 1680 * 1681 * @param portletRequest the portlet request from which to read the 1682 * parameter 1683 * @param param the name of the parameter 1684 * @return the portlet request parameter value as a long array 1685 */ 1686 public static long[] getLongValues( 1687 PortletRequest portletRequest, String param) { 1688 1689 return getLongValues(portletRequest, param, new long[0]); 1690 } 1691 1692 /** 1693 * Returns the portlet request parameter value as a long array. In the 1694 * returned array, each parameter value not convertible to a long is 1695 * replaced by the default value. 1696 * 1697 * @param portletRequest the portlet request from which to read the 1698 * parameter 1699 * @param param the name of the parameter 1700 * @param defaultValue a default value 1701 * @return the portlet request parameter value as a long array 1702 */ 1703 public static long[] getLongValues( 1704 PortletRequest portletRequest, String param, long[] defaultValue) { 1705 1706 return GetterUtil.getLongValues( 1707 getParameterValues(portletRequest, param, null), defaultValue); 1708 } 1709 1710 /** 1711 * Returns the service context parameter value as a long array. In the 1712 * returned array, each parameter value not convertible to a long is 1713 * replaced by <code>0</code>. 1714 * 1715 * @param serviceContext the service context from which to read the 1716 * parameter 1717 * @param param the name of the parameter 1718 * @return the service context parameter value as a long array 1719 */ 1720 public static long[] getLongValues( 1721 ServiceContext serviceContext, String param) { 1722 1723 return getLongValues(serviceContext, param, new long[0]); 1724 } 1725 1726 /** 1727 * Returns the service context parameter value as a long array. In the 1728 * returned array, each parameter value not convertible to a long is 1729 * replaced by the default value. 1730 * 1731 * @param serviceContext the service context from which to read the 1732 * parameter 1733 * @param param the name of the parameter 1734 * @param defaultValue a default value 1735 * @return the service context parameter value as a long array 1736 */ 1737 public static long[] getLongValues( 1738 ServiceContext serviceContext, String param, long[] defaultValue) { 1739 1740 return GetterUtil.getLongValues( 1741 serviceContext.getAttribute(param), defaultValue); 1742 } 1743 1744 /** 1745 * Returns the request parameter value as a Number. If the parameter is 1746 * missing or not convertible to a Number, <code>0</code> is returned. 1747 * 1748 * @param request the servlet request from which to read the parameter 1749 * @param param the name of the parameter 1750 * @return the request parameter value as a Number 1751 */ 1752 public static Number getNumber(HttpServletRequest request, String param) { 1753 return GetterUtil.getNumber(request.getParameter(param)); 1754 } 1755 1756 /** 1757 * Returns the request parameter value as a Number. If the parameter is 1758 * missing or not convertible to a Number, the default value is returned. 1759 * 1760 * @param request the servlet request from which to read the parameter 1761 * @param param the name of the parameter 1762 * @param defaultValue a default value 1763 * @return the request parameter value as a Number 1764 */ 1765 public static Number getNumber( 1766 HttpServletRequest request, String param, Number defaultValue) { 1767 1768 return get(request, param, defaultValue); 1769 } 1770 1771 /** 1772 * Returns the portlet request parameter value as a Number. If the parameter 1773 * is missing or not convertible to a Number, <code>0</code> is returned. 1774 * 1775 * @param portletRequest the portlet request from which to read the 1776 * parameter 1777 * @param param the name of the parameter 1778 * @return the portlet request parameter value as a Number 1779 */ 1780 public static Number getNumber( 1781 PortletRequest portletRequest, String param) { 1782 1783 return GetterUtil.getNumber(portletRequest.getParameter(param)); 1784 } 1785 1786 /** 1787 * Returns the portlet request parameter value as a Number. If the parameter 1788 * is missing or not convertible to a Number, the default value is returned. 1789 * 1790 * @param portletRequest the portlet request from which to read the 1791 * parameter 1792 * @param param the name of the parameter 1793 * @param defaultValue a default value 1794 * @return the portlet request parameter value as a Number 1795 */ 1796 public static Number getNumber( 1797 PortletRequest portletRequest, String param, Number defaultValue) { 1798 1799 return get(portletRequest, param, defaultValue); 1800 } 1801 1802 /** 1803 * Returns the service context parameter value as a Number. If the parameter 1804 * is missing or not convertible to a Number, <code>0</code> is returned. 1805 * 1806 * @param serviceContext the service context from which to read the 1807 * parameter 1808 * @param param the name of the parameter 1809 * @return the service context parameter value as a Number 1810 */ 1811 public static Number getNumber( 1812 ServiceContext serviceContext, String param) { 1813 1814 return GetterUtil.getNumber(serviceContext.getAttribute(param)); 1815 } 1816 1817 /** 1818 * Returns the service context parameter value as a Number. If the parameter 1819 * is missing or not convertible to a Number, the default value is returned. 1820 * 1821 * @param serviceContext the service context from which to read the 1822 * parameter 1823 * @param param the name of the parameter 1824 * @param defaultValue a default value 1825 * @return the service context parameter value as a Number 1826 */ 1827 public static Number getNumber( 1828 ServiceContext serviceContext, String param, Number defaultValue) { 1829 1830 return get(serviceContext, param, defaultValue); 1831 } 1832 1833 /** 1834 * Returns the request parameter value as a Number array. In the returned 1835 * array, each parameter value not convertible to a Number is replaced by 1836 * <code>0</code>. 1837 * 1838 * @param request the servlet request from which to read the parameter 1839 * @param param the name of the parameter 1840 * @return the request parameter value as a Number array 1841 */ 1842 public static Number[] getNumberValues( 1843 HttpServletRequest request, String param) { 1844 1845 return getNumberValues(request, param, new Number[0]); 1846 } 1847 1848 /** 1849 * Returns the request parameter value as a Number array. In the returned 1850 * array, each parameter value not convertible to a Number is replaced by 1851 * the default value. 1852 * 1853 * @param request the servlet request from which to read the parameter 1854 * @param param the name of the parameter 1855 * @param defaultValue a default value 1856 * @return the request parameter value as a Number array 1857 */ 1858 public static Number[] getNumberValues( 1859 HttpServletRequest request, String param, Number[] defaultValue) { 1860 1861 return GetterUtil.getNumberValues( 1862 getParameterValues(request, param, null), defaultValue); 1863 } 1864 1865 /** 1866 * Returns the portlet request parameter value as a Number array. In the 1867 * returned array, each parameter value not convertible to a Number is 1868 * replaced by <code>0</code>. 1869 * 1870 * @param portletRequest the portlet request from which to read the 1871 * parameter 1872 * @param param the name of the parameter 1873 * @return the portlet request parameter value as a Number array 1874 */ 1875 public static Number[] getNumberValues( 1876 PortletRequest portletRequest, String param) { 1877 1878 return getNumberValues(portletRequest, param, new Number[0]); 1879 } 1880 1881 /** 1882 * Returns the portlet request parameter value as a Number array. In the 1883 * returned array, each parameter value not convertible to a Number is 1884 * replaced by the default value. 1885 * 1886 * @param portletRequest the portlet request from which to read the 1887 * parameter 1888 * @param param the name of the parameter 1889 * @param defaultValue a default value 1890 * @return the portlet request parameter value as a Number array 1891 */ 1892 public static Number[] getNumberValues( 1893 PortletRequest portletRequest, String param, Number[] defaultValue) { 1894 1895 return GetterUtil.getNumberValues( 1896 getParameterValues(portletRequest, param, null), defaultValue); 1897 } 1898 1899 /** 1900 * Returns the service context parameter value as a Number array. In the 1901 * returned array, each parameter value not convertible to a Number is 1902 * replaced by <code>0</code>. 1903 * 1904 * @param serviceContext the service context from which to read the 1905 * parameter 1906 * @param param the name of the parameter 1907 * @return the service request parameter value as a Number array 1908 */ 1909 public static Number[] getNumberValues( 1910 ServiceContext serviceContext, String param) { 1911 1912 return getNumberValues(serviceContext, param, new Number[0]); 1913 } 1914 1915 /** 1916 * Returns the service context parameter value as a Number array. In the 1917 * returned array, each parameter value not convertible to a Number is 1918 * replaced by the default value. 1919 * 1920 * @param serviceContext the service context from which to read the 1921 * parameter 1922 * @param param the name of the parameter 1923 * @param defaultValue a default value 1924 * @return the service request parameter value as a Number array 1925 */ 1926 public static Number[] getNumberValues( 1927 ServiceContext serviceContext, String param, Number[] defaultValue) { 1928 1929 return GetterUtil.getNumberValues( 1930 serviceContext.getAttribute(param), defaultValue); 1931 } 1932 1933 /** 1934 * Returns the request parameter value as a String array. In the returned 1935 * array, each parameter value not convertible to a String is replaced by a 1936 * blank string. 1937 * 1938 * @param request the servlet request from which to read the parameter 1939 * @param param the name of the parameter 1940 * @return the request parameter value as a String array 1941 */ 1942 public static String[] getParameterValues( 1943 HttpServletRequest request, String param) { 1944 1945 return getParameterValues(request, param, new String[0]); 1946 } 1947 1948 /** 1949 * Returns the request parameter value as a String array. In the returned 1950 * array, each parameter value not convertible to a String is replaced by 1951 * the default value. 1952 * 1953 * @param request the servlet request from which to read the parameter 1954 * @param param the name of the parameter 1955 * @param defaultValue a default value 1956 * @return the request parameter value as a String array 1957 */ 1958 public static String[] getParameterValues( 1959 HttpServletRequest request, String param, String[] defaultValue) { 1960 1961 return getParameterValues(request, param, defaultValue, true); 1962 } 1963 1964 /** 1965 * Returns the request parameter value as a String array. In the returned 1966 * array, each parameter value not convertible to a String is replaced by 1967 * the default value. 1968 * 1969 * @param request the servlet request from which to read the parameter 1970 * @param param the name of the parameter 1971 * @param defaultValue a default value 1972 * @param split whether to split the single parameter value using comma 1973 * separators to get multiple values 1974 * @return the request parameter value as a String array 1975 */ 1976 public static String[] getParameterValues( 1977 HttpServletRequest request, String param, String[] defaultValue, 1978 boolean split) { 1979 1980 String[] values = request.getParameterValues(param); 1981 1982 if (values == null) { 1983 return defaultValue; 1984 } 1985 1986 if (split && (values.length == 1)) { 1987 return StringUtil.split(values[0]); 1988 } 1989 1990 return values; 1991 } 1992 1993 /** 1994 * Returns the portlet request parameter value as a String array. In the 1995 * returned array, each parameter value not convertible to a String is 1996 * replaced by a blank string. 1997 * 1998 * @param portletRequest the portlet request from which to read the 1999 * parameter 2000 * @param param the name of the parameter 2001 * @return the portlet request parameter value as a String array 2002 */ 2003 public static String[] getParameterValues( 2004 PortletRequest portletRequest, String param) { 2005 2006 return getParameterValues(portletRequest, param, new String[0]); 2007 } 2008 2009 /** 2010 * Returns the portlet request parameter value as a String array. In the 2011 * returned array, each parameter value not convertible to a String is 2012 * replaced by the default value. 2013 * 2014 * @param portletRequest the portlet request from which to read the 2015 * parameter 2016 * @param param the name of the parameter 2017 * @param defaultValue a default value 2018 * @return the portlet request parameter value as a String array 2019 */ 2020 public static String[] getParameterValues( 2021 PortletRequest portletRequest, String param, String[] defaultValue) { 2022 2023 return getParameterValues(portletRequest, param, defaultValue, true); 2024 } 2025 2026 /** 2027 * Returns the portlet request parameter value as a String array. In the 2028 * returned array, each parameter value not convertible to a String is 2029 * replaced by the default value. 2030 * 2031 * @param portletRequest the portlet request from which to read the 2032 * parameter 2033 * @param param the name of the parameter 2034 * @param defaultValue a default value 2035 * @param split whether to split the single parameter value using comma 2036 * separators to get multiple values 2037 * @return the portlet request parameter value as a String array 2038 */ 2039 public static String[] getParameterValues( 2040 PortletRequest portletRequest, String param, String[] defaultValue, 2041 boolean split) { 2042 2043 HttpServletRequest request = PortalUtil.getHttpServletRequest( 2044 portletRequest); 2045 2046 return getParameterValues(request, param, defaultValue, split); 2047 } 2048 2049 /** 2050 * Returns the request parameter value as a short. If the parameter is 2051 * missing or not convertible to a short, <code>0</code> is returned. 2052 * 2053 * @param request the servlet request from which to read the parameter 2054 * @param param the name of the parameter 2055 * @return the request parameter value as a short 2056 */ 2057 public static short getShort(HttpServletRequest request, String param) { 2058 return GetterUtil.getShort(request.getParameter(param)); 2059 } 2060 2061 /** 2062 * Returns the request parameter value as a short. If the parameter is 2063 * missing or not convertible to a short, the default value is returned. 2064 * 2065 * @param request the servlet request from which to read the parameter 2066 * @param param the name of the parameter 2067 * @param defaultValue a default value 2068 * @return the request parameter value as a short 2069 */ 2070 public static short getShort( 2071 HttpServletRequest request, String param, short defaultValue) { 2072 2073 return get(request, param, defaultValue); 2074 } 2075 2076 /** 2077 * Returns the portlet request parameter value as a short. If the parameter 2078 * is missing or not convertible to a short, <code>0</code> is returned. 2079 * 2080 * @param portletRequest the portlet request from which to read the 2081 * parameter 2082 * @param param the name of the parameter 2083 * @return the portlet request parameter value as a short 2084 */ 2085 public static short getShort(PortletRequest portletRequest, String param) { 2086 return GetterUtil.getShort(portletRequest.getParameter(param)); 2087 } 2088 2089 /** 2090 * Returns the portlet request parameter value as a short. If the parameter 2091 * is missing or not convertible to a short, the default value is returned. 2092 * 2093 * @param portletRequest the portlet request from which to read the 2094 * parameter 2095 * @param param the name of the parameter 2096 * @param defaultValue a default value 2097 * @return the portlet request parameter value as a short 2098 */ 2099 public static short getShort( 2100 PortletRequest portletRequest, String param, short defaultValue) { 2101 2102 return get(portletRequest, param, defaultValue); 2103 } 2104 2105 /** 2106 * Returns the service context parameter value as a short. If the parameter 2107 * is missing or not convertible to a short, <code>0</code> is returned. 2108 * 2109 * @param serviceContext the service context from which to read the 2110 * parameter 2111 * @param param the name of the parameter 2112 * @return the service context parameter value as a short 2113 */ 2114 public static short getShort(ServiceContext serviceContext, String param) { 2115 return GetterUtil.getShort(serviceContext.getAttribute(param)); 2116 } 2117 2118 /** 2119 * Returns the service context parameter value as a short. If the parameter 2120 * is missing or not convertible to a short, the default value is returned. 2121 * 2122 * @param serviceContext the service context from which to read the 2123 * parameter 2124 * @param param the name of the parameter 2125 * @param defaultValue a default value 2126 * @return the service context parameter value as a short 2127 */ 2128 public static short getShort( 2129 ServiceContext serviceContext, String param, short defaultValue) { 2130 2131 return get(serviceContext, param, defaultValue); 2132 } 2133 2134 /** 2135 * Returns the request parameter value as a short array. In the returned 2136 * array, each parameter value not convertible to a short is replaced by 2137 * <code>0</code>. 2138 * 2139 * @param request the servlet request from which to read the parameter 2140 * @param param the name of the parameter 2141 * @return the request parameter value as a short array 2142 */ 2143 public static short[] getShortValues( 2144 HttpServletRequest request, String param) { 2145 2146 return getShortValues(request, param, new short[0]); 2147 } 2148 2149 /** 2150 * Returns the request parameter value as a short array. In the returned 2151 * array, each parameter value not convertible to a short is replaced by the 2152 * default value. 2153 * 2154 * @param request the servlet request from which to read the parameter 2155 * @param param the name of the parameter 2156 * @param defaultValue a default value 2157 * @return the request parameter value as a short array 2158 */ 2159 public static short[] getShortValues( 2160 HttpServletRequest request, String param, short[] defaultValue) { 2161 2162 return GetterUtil.getShortValues( 2163 getParameterValues(request, param, null), defaultValue); 2164 } 2165 2166 /** 2167 * Returns the portlet request parameter value as a short array. In the 2168 * returned array, each parameter value not convertible to a short is 2169 * replaced by <code>0</code>. 2170 * 2171 * @param portletRequest the portlet request from which to read the 2172 * parameter 2173 * @param param the name of the parameter 2174 * @return the portlet request parameter value as a short array 2175 */ 2176 public static short[] getShortValues( 2177 PortletRequest portletRequest, String param) { 2178 2179 return getShortValues(portletRequest, param, new short[0]); 2180 } 2181 2182 /** 2183 * Returns the portlet request parameter value as a short array. In the 2184 * returned array, each parameter value not convertible to a short is 2185 * replaced by the default value. 2186 * 2187 * @param portletRequest the portlet request from which to read the 2188 * parameter 2189 * @param param the name of the parameter 2190 * @param defaultValue a default value 2191 * @return the portlet request parameter value as a short array 2192 */ 2193 public static short[] getShortValues( 2194 PortletRequest portletRequest, String param, short[] defaultValue) { 2195 2196 return GetterUtil.getShortValues( 2197 getParameterValues(portletRequest, param, null), defaultValue); 2198 } 2199 2200 /** 2201 * Returns the service context parameter value as a short array. In the 2202 * returned array, each parameter value not convertible to a short is 2203 * replaced by <code>0</code>. 2204 * 2205 * @param serviceContext the service context from which to read the 2206 * parameter 2207 * @param param the name of the parameter 2208 * @return the service context parameter value as a short array 2209 */ 2210 public static short[] getShortValues( 2211 ServiceContext serviceContext, String param) { 2212 2213 return getShortValues(serviceContext, param, new short[0]); 2214 } 2215 2216 /** 2217 * Returns the service context parameter value as a short array. In the 2218 * returned array, each parameter value not convertible to a short is 2219 * replaced by the default value. 2220 * 2221 * @param serviceContext the service context from which to read the 2222 * parameter 2223 * @param param the name of the parameter 2224 * @param defaultValue a default value 2225 * @return the service context parameter value as a short array 2226 */ 2227 public static short[] getShortValues( 2228 ServiceContext serviceContext, String param, short[] defaultValue) { 2229 2230 return GetterUtil.getShortValues( 2231 serviceContext.getAttribute(param), defaultValue); 2232 } 2233 2234 /** 2235 * Returns the request parameter value as a String. If the parameter is 2236 * missing or not convertible to a String, a blank string is returned. 2237 * 2238 * @param request the servlet request from which to read the parameter 2239 * @param param the name of the parameter 2240 * @return the request parameter value as a String 2241 */ 2242 public static String getString(HttpServletRequest request, String param) { 2243 return GetterUtil.getString(request.getParameter(param)); 2244 } 2245 2246 /** 2247 * Returns the request parameter value as a String. If the parameter is 2248 * missing or not convertible to a String, the default value is returned. 2249 * 2250 * @param request the servlet request from which to read the parameter 2251 * @param param the name of the parameter 2252 * @param defaultValue a default value 2253 * @return the request parameter value as a String 2254 */ 2255 public static String getString( 2256 HttpServletRequest request, String param, String defaultValue) { 2257 2258 return get(request, param, defaultValue); 2259 } 2260 2261 /** 2262 * Returns the portlet request parameter value as a String. If the parameter 2263 * is missing or not convertible to a String, a blank string is returned. 2264 * 2265 * @param portletRequest the portlet request from which to read the 2266 * parameter 2267 * @param param the name of the parameter 2268 * @return the portlet request parameter value as a String 2269 */ 2270 public static String getString( 2271 PortletRequest portletRequest, String param) { 2272 2273 return GetterUtil.getString(portletRequest.getParameter(param)); 2274 } 2275 2276 /** 2277 * Returns the portlet request parameter value as a String. If the parameter 2278 * is missing or not convertible to a String, the default value is returned. 2279 * 2280 * @param portletRequest the portlet request from which to read the 2281 * parameter 2282 * @param param the name of the parameter 2283 * @param defaultValue a default value 2284 * @return the portlet request parameter value as a String 2285 */ 2286 public static String getString( 2287 PortletRequest portletRequest, String param, String defaultValue) { 2288 2289 return get(portletRequest, param, defaultValue); 2290 } 2291 2292 /** 2293 * Returns the service context parameter value as a String. If the parameter 2294 * is missing or not convertible to a String, a blank string is returned. 2295 * 2296 * @param serviceContext the service context from which to read the 2297 * parameter 2298 * @param param the name of the parameter 2299 * @return the service context parameter value as a String 2300 */ 2301 public static String getString( 2302 ServiceContext serviceContext, String param) { 2303 2304 return GetterUtil.getString(serviceContext.getAttribute(param)); 2305 } 2306 2307 /** 2308 * Returns the service context parameter value as a String. If the parameter 2309 * is missing or not convertible to a String, the default value is returned. 2310 * 2311 * @param serviceContext the service context from which to read the 2312 * parameter 2313 * @param param the name of the parameter 2314 * @param defaultValue a default value 2315 * @return the service context parameter value as a String 2316 */ 2317 public static String getString( 2318 ServiceContext serviceContext, String param, String defaultValue) { 2319 2320 return get(serviceContext, param, defaultValue); 2321 } 2322 2323 /** 2324 * Returns the request parameter value as a String array. In the returned 2325 * array, each parameter value not convertible to a String is replaced by a 2326 * blank string. 2327 * 2328 * @param request the servlet request from which to read the parameter 2329 * @param param the name of the parameter 2330 * @return the request parameter value as a String array 2331 */ 2332 public static String[] getStringValues( 2333 HttpServletRequest request, String param) { 2334 2335 return getStringValues(request, param, new String[0]); 2336 } 2337 2338 /** 2339 * Returns the request parameter value as a String array. In the returned 2340 * array, each parameter value not convertible to a String is replaced by 2341 * the default value. 2342 * 2343 * @param request the servlet request from which to read the parameter 2344 * @param param the name of the parameter 2345 * @param defaultValue a default value 2346 * @return the request parameter value as a String array 2347 */ 2348 public static String[] getStringValues( 2349 HttpServletRequest request, String param, String[] defaultValue) { 2350 2351 return GetterUtil.getStringValues( 2352 getParameterValues(request, param, null), defaultValue); 2353 } 2354 2355 /** 2356 * Returns the portlet request parameter value as a String array. In the 2357 * returned array, each parameter value not convertible to a String is 2358 * replaced by a blank string. 2359 * 2360 * @param portletRequest the portlet request from which to read the 2361 * parameter 2362 * @param param the name of the parameter 2363 * @return the portlet request parameter value as a String array 2364 */ 2365 public static String[] getStringValues( 2366 PortletRequest portletRequest, String param) { 2367 2368 return getStringValues(portletRequest, param, new String[0]); 2369 } 2370 2371 /** 2372 * Returns the portlet request parameter value as a String array. In the 2373 * returned array, each parameter value not convertible to a String is 2374 * replaced by the default value. 2375 * 2376 * @param portletRequest the portlet request from which to read the 2377 * parameter 2378 * @param param the name of the parameter 2379 * @param defaultValue a default value 2380 * @return the portlet request parameter value as a String array 2381 */ 2382 public static String[] getStringValues( 2383 PortletRequest portletRequest, String param, String[] defaultValue) { 2384 2385 return GetterUtil.getStringValues( 2386 getParameterValues(portletRequest, param, null), defaultValue); 2387 } 2388 2389 /** 2390 * Returns the service context parameter value as a String array. In the 2391 * returned array, each parameter value not convertible to a String is 2392 * replaced by a blank string. 2393 * 2394 * @param serviceContext the service context from which to read the 2395 * parameter 2396 * @param param the name of the parameter 2397 * @return the service context parameter value as a String array 2398 */ 2399 public static String[] getStringValues( 2400 ServiceContext serviceContext, String param) { 2401 2402 return getStringValues(serviceContext, param, new String[0]); 2403 } 2404 2405 /** 2406 * Returns the service context parameter value as a String array. In the 2407 * returned array, each parameter value not convertible to a String is 2408 * replaced by the default value. 2409 * 2410 * @param serviceContext the service context from which to read the 2411 * parameter 2412 * @param param the name of the parameter 2413 * @param defaultValue a default value 2414 * @return the service context parameter value as a String array 2415 */ 2416 public static String[] getStringValues( 2417 ServiceContext serviceContext, String param, String[] defaultValue) { 2418 2419 return GetterUtil.getStringValues( 2420 serviceContext.getAttribute(param), defaultValue); 2421 } 2422 2423 /** 2424 * Prints all the request parameters as standard output. 2425 * 2426 * @param request the servlet request from which to read the parameters 2427 */ 2428 public static void print(HttpServletRequest request) { 2429 Map<String, String[]> parameters = request.getParameterMap(); 2430 2431 for (Map.Entry<String, String[]> entry : parameters.entrySet()) { 2432 String name = entry.getKey(); 2433 String[] values = entry.getValue(); 2434 2435 for (int i = 0; i < values.length; i++) { 2436 System.out.println(name + "[" + i + "] = " + values[i]); 2437 } 2438 } 2439 } 2440 2441 /** 2442 * Prints all the portlet request parameters as standard output. 2443 * 2444 * @param portletRequest the portlet request from which to read the 2445 * parameters 2446 */ 2447 public static void print(PortletRequest portletRequest) { 2448 Enumeration<String> enu = portletRequest.getParameterNames(); 2449 2450 while (enu.hasMoreElements()) { 2451 String param = enu.nextElement(); 2452 2453 String[] values = portletRequest.getParameterValues(param); 2454 2455 for (int i = 0; i < values.length; i++) { 2456 System.out.println(param + "[" + i + "] = " + values[i]); 2457 } 2458 } 2459 } 2460 2461 /** 2462 * Prints all the service context parameters as standard output. 2463 * 2464 * @param serviceContext the service context from which to read the 2465 * parameters 2466 */ 2467 public static void print(ServiceContext serviceContext) { 2468 Map<String, Serializable> attributes = serviceContext.getAttributes(); 2469 2470 for (Map.Entry<String, Serializable> entry : attributes.entrySet()) { 2471 System.out.println( 2472 entry.getKey() + " = " + String.valueOf(entry.getValue())); 2473 } 2474 } 2475 2476 }