<!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.6.0-google-internal) on Mon Jan 04 20:48:00 PST 2010 --> <TITLE> SignedBytes (Guava Libraries 2010.01.04) </TITLE> <META NAME="date" CONTENT="2010-01-04"> <LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> <SCRIPT type="text/javascript"> function windowTitle() { if (location.href.indexOf('is-external=true') == -1) { parent.document.title="SignedBytes (Guava Libraries 2010.01.04)"; } } </SCRIPT> <NOSCRIPT> </NOSCRIPT> </HEAD> <BODY BGCOLOR="white" onload="windowTitle();"> <HR> <!-- ========= 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> </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="class-use/SignedBytes.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </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> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/google/common/primitives/Shorts.html" title="class in com.google.common.primitives"><B>PREV CLASS</B></A> <A HREF="../../../../com/google/common/primitives/UnsignedBytes.html" title="class in com.google.common.primitives"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/google/common/primitives/SignedBytes.html" target="_top"><B>FRAMES</B></A> <A HREF="SignedBytes.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_top"></A> <!-- ========= END OF TOP NAVBAR ========= --> <HR> <!-- ======== START OF CLASS DATA ======== --> <H2> <FONT SIZE="-1"> com.google.common.primitives</FONT> <BR> Class SignedBytes</H2> <PRE> <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.primitives.SignedBytes</B> </PRE> <HR> <DL> <DT><PRE>public final class <B>SignedBytes</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></DL> </PRE> <P> Static utility methods pertaining to <code>byte</code> primitives that interpret values as signed. The corresponding methods that treat the values as unsigned are found in <A HREF="../../../../com/google/common/primitives/UnsignedBytes.html" title="class in com.google.common.primitives"><CODE>UnsignedBytes</CODE></A>, and the methods for which signedness is not an issue are in <A HREF="../../../../com/google/common/primitives/Bytes.html" title="class in com.google.common.primitives"><CODE>Bytes</CODE></A>. <P> <P> <DL> <DT><B>Since:</B></DT> <DD>2009.09.15 <b>tentative</b></DD> <DT><B>Author:</B></DT> <DD>Kevin Bourrillion</DD> </DL> <HR> <P> <!-- ========== METHOD SUMMARY =========== --> <A NAME="method_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>Method Summary</B></FONT></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#checkedCast(long)">checkedCast</A></B>(long value)</CODE> <BR> Returns the <code>byte</code> value that is equal to <code>value</code>, if possible.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static int</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#compare(byte, byte)">compare</A></B>(byte a, byte b)</CODE> <BR> Compares the two specified <code>byte</code> values.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#join(java.lang.String, byte...)">join</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> separator, byte... array)</CODE> <BR> Returns a string containing the supplied <code>byte</code> values separated by <code>separator</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</A><byte[]></CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#lexicographicalComparator()">lexicographicalComparator</A></B>()</CODE> <BR> Returns a comparator that compares two <code>byte</code> arrays lexicographically.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#max(byte...)">max</A></B>(byte... array)</CODE> <BR> Returns the greatest value present in <code>array</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#min(byte...)">min</A></B>(byte... array)</CODE> <BR> Returns the least value present in <code>array</code>.</TD> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> <CODE>static byte</CODE></FONT></TD> <TD><CODE><B><A HREF="../../../../com/google/common/primitives/SignedBytes.html#saturatedCast(long)">saturatedCast</A></B>(long value)</CODE> <BR> Returns the <code>byte</code> nearest in value to <code>value</code>.</TD> </TR> </TABLE> <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> <TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> </TR> <TR BGCOLOR="white" CLASS="TableRowColor"> <TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang">equals</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> </TR> </TABLE> <P> <!-- ============ METHOD DETAIL ========== --> <A NAME="method_detail"><!-- --></A> <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> <B>Method Detail</B></FONT></TH> </TR> </TABLE> <A NAME="checkedCast(long)"><!-- --></A><H3> checkedCast</H3> <PRE> public static byte <B>checkedCast</B>(long value)</PRE> <DL> <DD>Returns the <code>byte</code> value that is equal to <code>value</code>, if possible. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>value</CODE> - any value in the range of the <code>byte</code> type <DT><B>Returns:</B><DD>the <code>byte</code> value that equals <code>value</code> <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>value</code> is greater than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Byte.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Byte.MAX_VALUE</CODE></A> or less than <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Byte.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><CODE>Byte.MIN_VALUE</CODE></A></DL> </DD> </DL> <HR> <A NAME="saturatedCast(long)"><!-- --></A><H3> saturatedCast</H3> <PRE> public static byte <B>saturatedCast</B>(long value)</PRE> <DL> <DD>Returns the <code>byte</code> nearest in value to <code>value</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>value</CODE> - any <code>long</code> value <DT><B>Returns:</B><DD>the same value cast to <code>byte</code> if it is in the range of the <code>byte</code> type, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Byte.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Byte.MAX_VALUE</CODE></A> if it is too large, or <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Byte.html?is-external=true#MIN_VALUE" title="class or interface in java.lang"><CODE>Byte.MIN_VALUE</CODE></A> if it is too small</DL> </DD> </DL> <HR> <A NAME="compare(byte, byte)"><!-- --></A><H3> compare</H3> <PRE> public static int <B>compare</B>(byte a, byte b)</PRE> <DL> <DD>Compares the two specified <code>byte</code> values. The sign of the value returned is the same as that of <code>((Byte) a).compareTo(b)</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>a</CODE> - the first <code>byte</code> to compare<DD><CODE>b</CODE> - the second <code>byte</code> to compare <DT><B>Returns:</B><DD>a negative value if <code>a</code> is less than <code>b</code>; a positive value if <code>a</code> is greater than <code>b</code>; or zero if they are equal</DL> </DD> </DL> <HR> <A NAME="min(byte...)"><!-- --></A><H3> min</H3> <PRE> public static byte <B>min</B>(byte... array)</PRE> <DL> <DD>Returns the least value present in <code>array</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>array</CODE> - a <i>nonempty</i> array of <code>byte</code> values <DT><B>Returns:</B><DD>the value present in <code>array</code> that is less than or equal to every other value in the array <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>array</code> is empty</DL> </DD> </DL> <HR> <A NAME="max(byte...)"><!-- --></A><H3> max</H3> <PRE> public static byte <B>max</B>(byte... array)</PRE> <DL> <DD>Returns the greatest value present in <code>array</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>array</CODE> - a <i>nonempty</i> array of <code>byte</code> values <DT><B>Returns:</B><DD>the value present in <code>array</code> that is greater than or equal to every other value in the array <DT><B>Throws:</B> <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>array</code> is empty</DL> </DD> </DL> <HR> <A NAME="join(java.lang.String, byte...)"><!-- --></A><H3> join</H3> <PRE> public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>join</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> separator, byte... array)</PRE> <DL> <DD>Returns a string containing the supplied <code>byte</code> values separated by <code>separator</code>. For example, <code>join(":", 0x01, 0x02, -0x01)</code> returns the string <code>"1:2:-1"</code>. <P> <DD><DL> <DT><B>Parameters:</B><DD><CODE>separator</CODE> - the text that should appear between consecutive values in the resulting string (but not at the start or end)<DD><CODE>array</CODE> - an array of <code>byte</code> values, possibly empty</DL> </DD> </DL> <HR> <A NAME="lexicographicalComparator()"><!-- --></A><H3> lexicographicalComparator</H3> <PRE> public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Comparator.html?is-external=true" title="class or interface in java.util">Comparator</A><byte[]> <B>lexicographicalComparator</B>()</PRE> <DL> <DD>Returns a comparator that compares two <code>byte</code> arrays lexicographically. That is, it compares, using <A HREF="../../../../com/google/common/primitives/SignedBytes.html#compare(byte, byte)"><CODE>compare(byte, byte)</CODE></A>), the first pair of values that follow any common prefix, or when one array is a prefix of the other, treats the shorter array as the lesser. For example, <code>[] < [0x01] < [0x01, 0x80] < [0x01, 0x7F] < [0x02]</code>. Values are treated as signed. <p>The returned comparator is inconsistent with <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#equals(java.lang.Object)" title="class or interface in java.lang"><CODE>Object.equals(Object)</CODE></A> (since arrays support only identity equality), but it is consistent with <A HREF="http://java.sun.com/javase/6/docs/api/java/util/Arrays.html?is-external=true#equals(byte[], byte[])" title="class or interface in java.util"><CODE>Arrays.equals(byte[], byte[])</CODE></A>. <P> <DD><DL> <DT><B>Since:</B></DT> <DD>2010.01.04 <b>tentative</b></DD> <DT><B>See Also:</B><DD><a href="http://en.wikipedia.org/wiki/Lexicographical_order"> Lexicographical order</a> article at Wikipedia</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="class-use/SignedBytes.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </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> </EM> </TD> </TR> <TR> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../com/google/common/primitives/Shorts.html" title="class in com.google.common.primitives"><B>PREV CLASS</B></A> <A HREF="../../../../com/google/common/primitives/UnsignedBytes.html" title="class in com.google.common.primitives"><B>NEXT CLASS</B></A></FONT></TD> <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html?com/google/common/primitives/SignedBytes.html" target="_top"><B>FRAMES</B></A> <A HREF="SignedBytes.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> </BODY> </HTML>