⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringutils.html

📁 开源软件openfire的API文件。进行openfire的二次开发所必需的工具。
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<DT><B>Parameters:</B><DD><CODE>in</CODE> - the text to be converted.<DT><B>Returns:</B><DD>the input string with the characters '&lt;' and '&gt;' replaced         with their HTML escape sequences.</DL></DD></DL><HR><A NAME="hash(java.lang.String)"><!-- --></A><H3>hash</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>hash</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>&nbsp;data)</PRE><DL><DD>Hashes a String using the Md5 algorithm and returns the result as a String of hexadecimal numbers. This method is synchronized to avoid excessive MessageDigest object creation. If calling this method becomes a bottleneck in your code, you may wish to maintain a pool of MessageDigest objects instead of using this method. <p/> A hash is a one-way function -- that is, given an input, an output is easily computed. However, given the output, the input is almost impossible to compute. This is useful for passwords since we can store the hash and a hacker will then have a very hard time determining the original password. <p/> In Jive, every time a user logs in, we simply take their plain text password, compute the hash, and compare the generated hash to the stored hash. Since it is almost impossible that two passwords will generate the same hash, we know if the user gave us the correct password or not. The only negative to this system is that password recovery is basically impossible. Therefore, a reset password method is used instead.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the String to compute the hash of.<DT><B>Returns:</B><DD>a hashed version of the passed-in String</DL></DD></DL><HR><A NAME="hash(java.lang.String, java.lang.String)"><!-- --></A><H3>hash</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>hash</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>&nbsp;data,                          <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>&nbsp;algorithm)</PRE><DL><DD>Hashes a String using the specified algorithm and returns the result as a String of hexadecimal numbers. This method is synchronized to avoid excessive MessageDigest object creation. If calling this method becomes a bottleneck in your code, you may wish to maintain a pool of MessageDigest objects instead of using this method. <p/> A hash is a one-way function -- that is, given an input, an output is easily computed. However, given the output, the input is almost impossible to compute. This is useful for passwords since we can store the hash and a hacker will then have a very hard time determining the original password. <p/> In Jive, every time a user logs in, we simply take their plain text password, compute the hash, and compare the generated hash to the stored hash. Since it is almost impossible that two passwords will generate the same hash, we know if the user gave us the correct password or not. The only negative to this system is that password recovery is basically impossible. Therefore, a reset password method is used instead.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - the String to compute the hash of.<DD><CODE>algorithm</CODE> - the name of the algorithm requested.<DT><B>Returns:</B><DD>a hashed version of the passed-in String</DL></DD></DL><HR><A NAME="hash(byte[], java.lang.String)"><!-- --></A><H3>hash</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>hash</B>(byte[]&nbsp;bytes,                          <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>&nbsp;algorithm)</PRE><DL><DD>Hashes a byte array using the specified algorithm and returns the result as a String of hexadecimal numbers. This method is synchronized to avoid excessive MessageDigest object creation. If calling this method becomes a bottleneck in your code, you may wish to maintain a pool of MessageDigest objects instead of using this method. <p/> A hash is a one-way function -- that is, given an input, an output is easily computed. However, given the output, the input is almost impossible to compute. This is useful for passwords since we can store the hash and a hacker will then have a very hard time determining the original password. <p/> In Jive, every time a user logs in, we simply take their plain text password, compute the hash, and compare the generated hash to the stored hash. Since it is almost impossible that two passwords will generate the same hash, we know if the user gave us the correct password or not. The only negative to this system is that password recovery is basically impossible. Therefore, a reset password method is used instead.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>bytes</CODE> - the byte array to compute the hash of.<DD><CODE>algorithm</CODE> - the name of the algorithm requested.<DT><B>Returns:</B><DD>a hashed version of the passed-in String</DL></DD></DL><HR><A NAME="encodeHex(byte[])"><!-- --></A><H3>encodeHex</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>encodeHex</B>(byte[]&nbsp;bytes)</PRE><DL><DD>Turns an array of bytes into a String representing each byte as an unsigned hex number. <p/> Method by Santeri Paavolainen, Helsinki Finland 1996<br> (c) Santeri Paavolainen, Helsinki Finland 1996<br> Distributed under LGPL.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>bytes</CODE> - an array of bytes to convert to a hex-string<DT><B>Returns:</B><DD>generated hex string</DL></DD></DL><HR><A NAME="decodeHex(java.lang.String)"><!-- --></A><H3>decodeHex</H3><PRE>public static byte[] <B>decodeHex</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>&nbsp;hex)</PRE><DL><DD>Turns a hex encoded string into a byte array. It is specifically meant to "reverse" the toHex(byte[]) method.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>hex</CODE> - a hex encoded String to transform into a byte array.<DT><B>Returns:</B><DD>a byte array representing the hex String[</DL></DD></DL><HR><A NAME="encodeBase64(java.lang.String)"><!-- --></A><H3>encodeBase64</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>encodeBase64</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>&nbsp;data)</PRE><DL><DD>Encodes a String as a base64 String.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - a String to encode.<DT><B>Returns:</B><DD>a base64 encoded String.</DL></DD></DL><HR><A NAME="encodeBase64(byte[])"><!-- --></A><H3>encodeBase64</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>encodeBase64</B>(byte[]&nbsp;data)</PRE><DL><DD>Encodes a byte array into a base64 String.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - a byte array to encode.<DT><B>Returns:</B><DD>a base64 encode String.</DL></DD></DL><HR><A NAME="decodeBase64(java.lang.String)"><!-- --></A><H3>decodeBase64</H3><PRE>public static byte[] <B>decodeBase64</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>&nbsp;data)</PRE><DL><DD>Decodes a base64 String.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - a base64 encoded String to decode.<DT><B>Returns:</B><DD>the decoded String.</DL></DD></DL><HR><A NAME="toLowerCaseWordArray(java.lang.String)"><!-- --></A><H3>toLowerCaseWordArray</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>toLowerCaseWordArray</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>&nbsp;text)</PRE><DL><DD>Converts a line of text into an array of lower case words using a BreakIterator.wordInstance().<p> This method is under the Jive Open Source Software License and was written by Mark Imbriaco.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>text</CODE> - a String of text to convert into an array of words<DT><B>Returns:</B><DD>text broken up into an array of words.</DL></DD></DL><HR><A NAME="randomString(int)"><!-- --></A><H3>randomString</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>randomString</B>(int&nbsp;length)</PRE><DL><DD>Returns a random String of numbers and letters (lower and upper case) of the specified length. The method uses the Random class that is built-in to Java which is suitable for low to medium grade security uses. This means that the output is only pseudo random, i.e., each number is mathematically generated so is not truly random.<p> <p/> The specified length must be at least one. If not, the method will return null.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>length</CODE> - the desired length of the random String to return.<DT><B>Returns:</B><DD>a random String of numbers and letters of the specified length.</DL></DD></DL><HR><A NAME="chopAtWord(java.lang.String, int)"><!-- --></A><H3>chopAtWord</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>chopAtWord</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>&nbsp;string,                                int&nbsp;length)</PRE><DL><DD>Intelligently chops a String at a word boundary (whitespace) that occurs at the specified index in the argument or before. However, if there is a newline character before <code>length</code>, the String will be chopped there. If no newline or whitespace is found in <code>string</code> up to the index <code>length</code>, the String will chopped at <code>length</code>. <p/> For example, chopAtWord("This is a nice String", 10) will return "This is a" which is the first word boundary less than or equal to 10 characters into the original String.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>string</CODE> - the String to chop.<DD><CODE>length</CODE> - the index in <code>string</code> to start looking for a               whitespace boundary at.<DT><B>Returns:</B><DD>a substring of <code>string</code> whose length is less than or         equal to <code>length</code>, and that is chopped at whitespace.</DL></DD></DL><HR><A NAME="wordWrap(java.lang.String, int, java.util.Locale)"><!-- --></A><H3>wordWrap</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>wordWrap</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>&nbsp;input,                              int&nbsp;width,                              <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Locale.html" title="class or interface in java.util">Locale</A>&nbsp;locale)</PRE>

⌨️ 快捷键说明

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