Java Doc for ParameterParser.java in  » Groupware » hipergate » com » oreilly » servlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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


java.lang.Object
   com.oreilly.servlet.ParameterParser

ParameterParser
public class ParameterParser (Code)
A class to simplify parameter handling. It can return parameters of any primitive type (no casting or parsing required), can throw an exception when a parameter is not found (simplifying error handling), and can accept default values (eliminating error handling).

It is used like this:

 ParameterParser parser = new ParameterParser(req);
  
 float ratio = parser.getFloatParameter("ratio", 1.0);
  
 int count = 0;
 try {
 count = parser.getIntParameter("count");
 }
 catch (NumberFormatException e) {
 handleMalformedCount();
 }
 catch (ParameterNotFoundException e) {
 handleNoCount();
 }
 
There's also a capability to find out if any required parameters are missing from a request:
 ParameterParser parser = new ParameterParser(req);
 String[] required = { "fname", "lname", "account" };
 String[] missing = parser.getMissingParameters(required);
 
The default charset for input parameters is ISO-8859-1 (Latin-1). If the parameter values are encoded in another format, specify that using setCharacterEncoding() before parsing. The parameter names currently have to be in the Latin-1 character set:
 ParameterParser parser = new ParameterParser(req);
 parser.setCharacterEncoding("Shift_JIS");
 String japaneseValue = parser.getStringParameter("latinName");
 

See Also:   com.oreilly.servlet.ParameterNotFoundException
author:
   Jason Hunter, Copyright © 1998, 1999
version:
   1.4, 2000/12/14, better checking the selected encoding is valid in
version:
   setCharacterEncoding() thanks to Dewayne McNair
version:
   1.3, 2000/05/17, added setCharacterEncoding()
version:
   1.2, 2000/05/17, getBooleanParameter() now recognizes "on" and "yes"
version:
   1.1, 1999/12/20, added getMissingParameters() method
version:
   1.0, 1998/09/18



Constructor Summary
public  ParameterParser(ServletRequest req)
     Constructs a new ParameterParser to handle the parameters of the given request.

Method Summary
public  booleangetBooleanParameter(String name)
     Gets the named parameter value as a boolean, with true indicated by "true", "on", or "yes" in any letter case, false indicated by "false", "off", or "no" in any letter case.
public  booleangetBooleanParameter(String name, boolean def)
     Gets the named parameter value as a boolean, with a default.
public  bytegetByteParameter(String name)
    
public  bytegetByteParameter(String name, byte def)
     Gets the named parameter value as a byte, with a default.
public  chargetCharParameter(String name)
    
public  chargetCharParameter(String name, char def)
     Gets the named parameter value as a char, with a default.
public  doublegetDoubleParameter(String name)
    
public  doublegetDoubleParameter(String name, double def)
     Gets the named parameter value as a double, with a default.
public  floatgetFloatParameter(String name)
    
public  floatgetFloatParameter(String name, float def)
     Gets the named parameter value as a float, with a default.
public  intgetIntParameter(String name)
    
public  intgetIntParameter(String name, int def)
     Gets the named parameter value as a int, with a default.
public  longgetLongParameter(String name)
    
public  longgetLongParameter(String name, long def)
     Gets the named parameter value as a long, with a default.
public  String[]getMissingParameters(String[] required)
     Determines which of the required parameters were missing from the request.
public  shortgetShortParameter(String name)
    
public  shortgetShortParameter(String name, short def)
     Gets the named parameter value as a short, with a default.
public  StringgetStringParameter(String name)
    
public  StringgetStringParameter(String name, String def)
     Gets the named parameter value as a String, with a default.
public  voidsetCharacterEncoding(String encoding)
     Sets the character encoding (charset) of the request to help the parser properly decode parameter values.


Constructor Detail
ParameterParser
public ParameterParser(ServletRequest req)(Code)
Constructs a new ParameterParser to handle the parameters of the given request.
Parameters:
  req - the servlet request




Method Detail
getBooleanParameter
public boolean getBooleanParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a boolean, with true indicated by "true", "on", or "yes" in any letter case, false indicated by "false", "off", or "no" in any letter case.
Parameters:
  name - the parameter name the parameter value as a boolean
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be converted to a boolean



getBooleanParameter
public boolean getBooleanParameter(String name, boolean def)(Code)
Gets the named parameter value as a boolean, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a boolean, or the default



getByteParameter
public byte getByteParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a byte
Parameters:
  name - the parameter name the parameter value as a byte
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter value could notbe converted to a byte



getByteParameter
public byte getByteParameter(String name, byte def)(Code)
Gets the named parameter value as a byte, with a default. Returns the default value if the parameter is not found or cannot be converted to a byte.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a byte, or the default



getCharParameter
public char getCharParameter(String name) throws ParameterNotFoundException(Code)
Gets the named parameter value as a char
Parameters:
  name - the parameter name the parameter value as a char
exception:
  ParameterNotFoundException - if the parameter was not foundor was the empty string



getCharParameter
public char getCharParameter(String name, char def)(Code)
Gets the named parameter value as a char, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a char, or the default



getDoubleParameter
public double getDoubleParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a double
Parameters:
  name - the parameter name the parameter value as a double
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be convertedto a double



getDoubleParameter
public double getDoubleParameter(String name, double def)(Code)
Gets the named parameter value as a double, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a double, or the default



getFloatParameter
public float getFloatParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a float
Parameters:
  name - the parameter name the parameter value as a float
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be convertedto a float



getFloatParameter
public float getFloatParameter(String name, float def)(Code)
Gets the named parameter value as a float, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a float, or the default



getIntParameter
public int getIntParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a int
Parameters:
  name - the parameter name the parameter value as a int
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be convertedto a int



getIntParameter
public int getIntParameter(String name, int def)(Code)
Gets the named parameter value as a int, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a int, or the default



getLongParameter
public long getLongParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a long
Parameters:
  name - the parameter name the parameter value as a long
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be convertedto a long



getLongParameter
public long getLongParameter(String name, long def)(Code)
Gets the named parameter value as a long, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a long, or the default



getMissingParameters
public String[] getMissingParameters(String[] required)(Code)
Determines which of the required parameters were missing from the request. Returns null if all the parameters are present.
Parameters:
  an - array of required parameters an array of missing parameters, or null if none are missing



getShortParameter
public short getShortParameter(String name) throws ParameterNotFoundException, NumberFormatException(Code)
Gets the named parameter value as a short
Parameters:
  name - the parameter name the parameter value as a short
exception:
  ParameterNotFoundException - if the parameter was not found
exception:
  NumberFormatException - if the parameter could not be convertedto a short



getShortParameter
public short getShortParameter(String name, short def)(Code)
Gets the named parameter value as a short, with a default. Returns the default value if the parameter is not found.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a short, or the default



getStringParameter
public String getStringParameter(String name) throws ParameterNotFoundException(Code)
Gets the named parameter value as a String
Parameters:
  name - the parameter name the parameter value as a String
exception:
  ParameterNotFoundException - if the parameter was not foundor was the empty string



getStringParameter
public String getStringParameter(String name, String def)(Code)
Gets the named parameter value as a String, with a default. Returns the default value if the parameter is not found or is the empty string.
Parameters:
  name - the parameter name
Parameters:
  def - the default parameter value the parameter value as a String, or the default



setCharacterEncoding
public void setCharacterEncoding(String encoding) throws UnsupportedEncodingException(Code)
Sets the character encoding (charset) of the request to help the parser properly decode parameter values. The default is to return undecoded values, the same as would be returned by getParameter().
Parameters:
  encoding - the charset of the request
exception:
  UnsupportedEncodingException - if the charset is not supported on this sytem



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.