📄 stringutils.html
字号:
<DL><DD>Reformats a string where lines that are longer than <tt>width</tt> are split apart at the earliest wordbreak or at maxLength, whichever is sooner. If the width specified is less than 5 or greater than the input Strings length the string will be returned as is. <p/> Please note that this method can be lossy - trailing spaces on wrapped lines may be trimmed.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>input</CODE> - the String to reformat.<DD><CODE>width</CODE> - the maximum length of any one line.<DT><B>Returns:</B><DD>a new String with reformatted as needed.</DL></DD></DL><HR><A NAME="escapeForSQL(java.lang.String)"><!-- --></A><H3>escapeForSQL</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>escapeForSQL</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> string)</PRE><DL><DD>Escapes all necessary characters in the String so that it can be used in SQL<P><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string to escape.<DT><B>Returns:</B><DD>the string with appropriate characters escaped.</DL></DD></DL><HR><A NAME="escapeForXML(java.lang.String)"><!-- --></A><H3>escapeForXML</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>escapeForXML</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> string)</PRE><DL><DD>Escapes all necessary characters in the String so that it can be used in an XML doc.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string to escape.<DT><B>Returns:</B><DD>the string with appropriate characters escaped.</DL></DD></DL><HR><A NAME="unescapeFromXML(java.lang.String)"><!-- --></A><H3>unescapeFromXML</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>unescapeFromXML</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> string)</PRE><DL><DD>Unescapes the String by converting XML escape sequences back into normal characters.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the string to unescape.<DT><B>Returns:</B><DD>the string with appropriate characters unescaped.</DL></DD></DL><HR><A NAME="zeroPadString(java.lang.String, int)"><!-- --></A><H3>zeroPadString</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>zeroPadString</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> string, int length)</PRE><DL><DD>Pads the supplied String with 0's to the specified length and returns the result as a new String. For example, if the initial String is "9999" and the desired length is 8, the result would be "00009999". This type of padding is useful for creating numerical values that need to be stored and sorted as character data. Note: the current implementation of this method allows for a maximum <tt>length</tt> of 64.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the original String to pad.<DD><CODE>length</CODE> - the desired length of the new padded String.<DT><B>Returns:</B><DD>a new String padded with the required number of 0's.</DL></DD></DL><HR><A NAME="dateToMillis(java.util.Date)"><!-- --></A><H3>dateToMillis</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>dateToMillis</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html" title="class or interface in java.util">Date</A> date)</PRE><DL><DD>Formats a Date as a fifteen character long String made up of the Date's padded millisecond value.<P><DD><DL><DT><B>Returns:</B><DD>a Date encoded as a String.</DL></DD></DL><HR><A NAME="getElapsedTime(long)"><!-- --></A><H3>getElapsedTime</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getElapsedTime</B>(long delta)</PRE><DL><DD>Returns a textual representation for the time that has elapsed.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>delta</CODE> - the elapsed time.<DT><B>Returns:</B><DD>textual representation for the time that has elapsed.</DL></DD></DL><HR><A NAME="getTimeFromLong(long)"><!-- --></A><H3>getTimeFromLong</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>getTimeFromLong</B>(long diff)</PRE><DL><DD>Returns a formatted String from time.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>diff</CODE> - the amount of elapsed time.<DT><B>Returns:</B><DD>the formatte String.</DL></DD></DL><HR><A NAME="collectionToString(java.util.Collection)"><!-- --></A><H3>collectionToString</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>collectionToString</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A><<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>> collection)</PRE><DL><DD>Returns a collection of Strings as a comma-delimitted list of strings.<P><DD><DL><DT><B>Returns:</B><DD>a String representing the Collection.</DL></DD></DL><HR><A NAME="stringToCollection(java.lang.String)"><!-- --></A><H3>stringToCollection</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Collection.html" title="class or interface in java.util">Collection</A><<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A>> <B>stringToCollection</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> string)</PRE><DL><DD>Returns a comma-delimitted list of Strings as a Collection.<P><DD><DL><DT><B>Returns:</B><DD>a Collection representing the String.</DL></DD></DL><HR><A NAME="abbreviate(java.lang.String, int)"><!-- --></A><H3>abbreviate</H3><PRE>public static <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> <B>abbreviate</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> str, int maxWidth)</PRE><DL><DD>Abbreviates a string to a specified length and then adds an ellipsis if the input is greater than the maxWidth. Example input: <pre> user1@jivesoftware.com/home </pre> and a maximum length of 20 characters, the abbreviate method will return: <pre> user1@jivesoftware.c... </pre><P><DD><DL><DT><B>Parameters:</B><DD><CODE>str</CODE> - the String to abbreviate.<DD><CODE>maxWidth</CODE> - the maximum size of the string, minus the ellipsis.<DT><B>Returns:</B><DD>the abbreviated String, or <tt>null</tt> if the string was <tt>null</tt>.</DL></DD></DL><HR><A NAME="isValidEmailAddress(java.lang.String)"><!-- --></A><H3>isValidEmailAddress</H3><PRE>public static boolean <B>isValidEmailAddress</B>(<A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> address)</PRE><DL><DD>Returns true if the string passed in is a valid Email address.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>address</CODE> - Email address to test for validity.<DT><B>Returns:</B><DD>true if the string passed in is a valid email address.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ======= START OF BOTTOM NAVBAR ====== --><A NAME="navbar_bottom"><!-- --></A><A HREF="#skip-navbar_bottom" 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_bottom_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> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Openfire 3.6.0a Javadoc</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../org/jivesoftware/util/SimpleSSLSocketFactory.html" title="class in org.jivesoftware.util"><B>PREV CLASS</B></A> <A HREF="../../../org/jivesoftware/util/TaskEngine.html" title="class in org.jivesoftware.util"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../index.html?org/jivesoftware/util/StringUtils.html" target="_top"><B>FRAMES</B></A> <A HREF="StringUtils.html" target="_top"><B>NO FRAMES</B></A> <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: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><A NAME="skip-navbar_bottom"></A><!-- ======== END OF BOTTOM NAVBAR ======= --><HR><i>Copyright © 2003-2008 Jive Software.</i></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -