numberconverter.html

来自「j2ee帮助文档软件设计/软件工程 文件格式」· HTML 代码 · 共 1,309 行 · 第 1/5 页

HTML
1,309
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc (build 1.5.0_14) on Mon Jan 28 05:46:53 PST 2008 --><TITLE>NumberConverter (Java EE 5)</TITLE><META NAME="keywords" CONTENT="javax.faces.convert.NumberConverter class"><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style"><SCRIPT type="text/javascript">function windowTitle(){    parent.document.title="NumberConverter (Java EE 5)";}</SCRIPT><NOSCRIPT></NOSCRIPT></HEAD><BODY BGCOLOR="white" onload="windowTitle();"><!-- ========= START OF TOP NAVBAR ======= --><A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">  <TR ALIGN="center" VALIGN="top">  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> &nbsp;<FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A>&nbsp;</TD>  <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1">    <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A>&nbsp;</TD>  </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">&nbsp;<A HREF="../../../javax/faces/convert/LongConverter.html" title="class in javax.faces.convert"><B>PREV CLASS</B></A>&nbsp;&nbsp;<A HREF="../../../javax/faces/convert/ShortConverter.html" title="class in javax.faces.convert"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">  <A HREF="../../../index.html?javax/faces/convert/NumberConverter.html" target="_top"><B>FRAMES</B></A>  &nbsp;&nbsp;<A HREF="NumberConverter.html" target="_top"><B>NO FRAMES</B></A>  &nbsp;&nbsp;<SCRIPT type="text/javascript">  <!--  if(window==top) {    document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');  }  //--></SCRIPT><NOSCRIPT>  <A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A></NOSCRIPT></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">  SUMMARY:&nbsp;NESTED&nbsp;|&nbsp;<A HREF="#field_summary">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_summary">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL:&nbsp;<A HREF="#field_detail">FIELD</A>&nbsp;|&nbsp;<A HREF="#constructor_detail">CONSTR</A>&nbsp;|&nbsp;<A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= --><HR><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">javax.faces.convert</FONT><BR>Class NumberConverter</H2><PRE><A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">java.lang.Object</A>  <IMG SRC="../../../resources/inherit.gif" ALT="extended by "><B>javax.faces.convert.NumberConverter</B></PRE><DL><DT><B>All Implemented Interfaces:</B> <DD><A HREF="../../../javax/faces/component/StateHolder.html" title="interface in javax.faces.component">StateHolder</A>, <A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert">Converter</A></DD></DL><HR><DL><DT><PRE>public class <B>NumberConverter</B><DT>extends <A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/Object.html" title="class or interface in java.lang">Object</A><DT>implements <A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert">Converter</A>, <A HREF="../../../javax/faces/component/StateHolder.html" title="interface in javax.faces.component">StateHolder</A></DL></PRE><P><p><A HREF="../../../javax/faces/convert/Converter.html" title="interface in javax.faces.convert"><CODE>Converter</CODE></A> implementation for <code>java.lang.Number</code> values.</p> <p>The <code>getAsObject()</code> method parses a String into an <code>java.lang.Double</code> or <code>java.lang.Long</code>, according to the following algorithm:</p> <ul> <li>If the specified String is null, return     a <code>null</code>.  Otherwise, trim leading and trailing     whitespace before proceeding.</li> <li>If the specified String - after trimming - has a zero length,     return <code>null</code>.</li> <li>If the <code>locale</code> property is not null,     use that <code>Locale</code> for managing parsing.  Otherwise, use the     <code>Locale</code> from the <code>UIViewRoot</code>.</li> <li>If a <code>pattern</code> has been specified, its syntax must conform     the rules specified by <code>java.text.DecimalFormat</code>.  Such     a pattern will be used to parse, and the <code>type</code> property     will be ignored.</li> <li>If a <code>pattern</code> has not been specified, parsing will be based     on the <code>type</code> property, which expects a currency, a number,     or a percent.  The parse pattern for currencies, numbers, and     percentages is determined by calling the     <code>getCurrencyInstance()</code>, <code>getNumberInstance()</code>,     or <code>getPercentInstance()</code> method of the     <code>java.text.NumberFormat</code> class, passing in the selected     <code>Locale</code>.</li> <li>If the <code>integerOnly</code> property has been set to true, only     the integer portion of the String will be parsed.  See the JavaDocs     for the <code>setParseIntegerOnly()</code> method of the     <code>java.text.NumberFormat</code> class for more information.</li> </ul> <p>The <code>getAsString()</code> method expects a value of type <code>java.lang.Number</code> (or a subclass), and creates a formatted String according to the following algorithm:</p> <ul> <li>If the specified value is null, return a zero-length String.</li> <li>If the specified value is a String, return it unmodified.</li> <li>If the <code>locale</code> property is not null,     use that <code>Locale</code> for managing formatting.  Otherwise, use the     <code>Locale</code> from the <code>FacesContext</code>.</li> <li>If a <code>pattern</code> has been specified, its syntax must conform     the rules specified by <code>java.text.DecimalFormat</code>.  Such     a pattern will be used to format, and the <code>type</code> property     (along with related formatting options described in the next paragraph)     will be ignored.</li> <li>If a <code>pattern</code> has not been specified, formatting will be     based on the <code>type</code> property, which formats the value as a     currency, a number, or a percent.  The format pattern for currencies,     numbers, and percentages is determined by calling the     percentages is determined by calling the     <code>getCurrencyInstance()</code>, <code>getNumberInstance()</code>,     or <code>getPercentInstance()</code> method of the     <code>java.text.NumberFormat</code> class, passing in the selected     <code>Locale</code>.  In addition, the following properties will be     applied to the format pattern, if specified:     <ul>     <li>If the <code>groupingUsed</code> property is <code>true</code>, the         <code>setGroupingUsed(true)</code> method on the corresponding         <code>NumberFormat</code> instance will be called.</li>     <li>The minimum and maximum number of digits in the integer and         fractional portions of the result will be configured based on         any values set for the <code>maxFractionDigits</code>,         <code>maxIntegerDigits</code>, <code>minFractionDigits</code>,         and <code>minIntegerDigits</code> properties.</li>     <li>If the type is set to <code>currency</code>, it is also possible         to configure the currency symbol to be used, using either the         <code>currencyCode</code> or <code>currencySymbol</code> properties.         If both are set, the value for <code>currencyCode</code> takes         precedence on a JDK 1.4 (or later) JVM; otherwise, the value         for <code>currencySymbol</code> takes precedence.</li>     </ul></li> </ul><P><P><HR><P><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Field Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#CONVERTER_ID">CONVERTER_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The standard converter id for this converter.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#CURRENCY_ID">CURRENCY_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Number</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#NUMBER_ID">NUMBER_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Number</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#PATTERN_ID">PATTERN_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Number</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#PERCENT_ID">PERCENT_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if the conversion to <code>Number</code> fails.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static&nbsp;<A HREF="http://java.sun.com/j2se/1.5/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A></CODE></FONT></TD><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#STRING_ID">STRING_ID</A></B></CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The message identifier of the <A HREF="../../../javax/faces/application/FacesMessage.html" title="class in javax.faces.application"><CODE>FacesMessage</CODE></A> to be created if  the conversion of the <code>Number</code> value to  <code>String</code> fails.</TD></TR></TABLE>&nbsp;<!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TH></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../javax/faces/convert/NumberConverter.html#NumberConverter()">NumberConverter</A></B>()</CODE><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD></TR></TABLE>&nbsp;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?