UnsignedBytes.java 4.21 KB
package com.google.common.primitives;

import com.google.common.annotations.Beta;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import java.util.Comparator;

public final class UnsignedBytes
{
  public static final byte MAX_POWER_OF_TWO = -128;
  public static final byte MAX_VALUE = -1;
  
  @VisibleForTesting
  static Comparator<byte[]> a()
  {
    return UnsignedBytes.a.a.a;
  }
  
  public static byte checkedCast(long paramLong)
  {
    if (paramLong >> 8 != 0L) {
      throw new IllegalArgumentException(34 + "Out of range: " + paramLong);
    }
    return (byte)(int)paramLong;
  }
  
  public static int compare(byte paramByte1, byte paramByte2)
  {
    return toInt(paramByte1) - toInt(paramByte2);
  }
  
  public static String join(String paramString, byte... paramVarArgs)
  {
    Preconditions.checkNotNull(paramString);
    if (paramVarArgs.length == 0) {
      return "";
    }
    StringBuilder localStringBuilder = new StringBuilder(paramVarArgs.length * (paramString.length() + 3));
    localStringBuilder.append(toInt(paramVarArgs[0]));
    int i = 1;
    while (i < paramVarArgs.length)
    {
      localStringBuilder.append(paramString).append(toString(paramVarArgs[i]));
      i += 1;
    }
    return localStringBuilder.toString();
  }
  
  public static Comparator<byte[]> lexicographicalComparator()
  {
    return a.b;
  }
  
  public static byte max(byte... paramVarArgs)
  {
    int i = 1;
    if (paramVarArgs.length > 0) {}
    int j;
    for (boolean bool = true;; bool = false)
    {
      Preconditions.checkArgument(bool);
      int k;
      for (j = toInt(paramVarArgs[0]); i < paramVarArgs.length; j = k)
      {
        int m = toInt(paramVarArgs[i]);
        k = j;
        if (m > j) {
          k = m;
        }
        i += 1;
      }
    }
    return (byte)j;
  }
  
  public static byte min(byte... paramVarArgs)
  {
    int i = 1;
    if (paramVarArgs.length > 0) {}
    int j;
    for (boolean bool = true;; bool = false)
    {
      Preconditions.checkArgument(bool);
      int k;
      for (j = toInt(paramVarArgs[0]); i < paramVarArgs.length; j = k)
      {
        int m = toInt(paramVarArgs[i]);
        k = j;
        if (m < j) {
          k = m;
        }
        i += 1;
      }
    }
    return (byte)j;
  }
  
  @Beta
  public static byte parseUnsignedByte(String paramString)
  {
    return parseUnsignedByte(paramString, 10);
  }
  
  @Beta
  public static byte parseUnsignedByte(String paramString, int paramInt)
  {
    paramInt = Integer.parseInt((String)Preconditions.checkNotNull(paramString), paramInt);
    if (paramInt >> 8 == 0) {
      return (byte)paramInt;
    }
    throw new NumberFormatException(25 + "out of range: " + paramInt);
  }
  
  public static byte saturatedCast(long paramLong)
  {
    if (paramLong > toInt((byte)-1)) {
      return -1;
    }
    if (paramLong < 0L) {
      return 0;
    }
    return (byte)(int)paramLong;
  }
  
  public static int toInt(byte paramByte)
  {
    return paramByte & 0xFF;
  }
  
  @Beta
  public static String toString(byte paramByte)
  {
    return toString(paramByte, 10);
  }
  
  @Beta
  public static String toString(byte paramByte, int paramInt)
  {
    if ((paramInt >= 2) && (paramInt <= 36)) {}
    for (boolean bool = true;; bool = false)
    {
      Preconditions.checkArgument(bool, "radix (%s) must be between Character.MIN_RADIX and Character.MAX_RADIX", new Object[] { Integer.valueOf(paramInt) });
      return Integer.toString(toInt(paramByte), paramInt);
    }
  }
  
  @VisibleForTesting
  static class a
  {
    static final String a = String.valueOf(a.class.getName()).concat("$UnsafeComparator");
    static final Comparator<byte[]> b = a();
    
    private static Comparator<byte[]> a()
    {
      try
      {
        Comparator localComparator = (Comparator)Class.forName(a).getEnumConstants()[0];
        return localComparator;
      }
      catch (Throwable localThrowable) {}
      return UnsignedBytes.a();
    }
    
    static enum a
      implements Comparator<byte[]>
    {
      private a() {}
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/com/google/common/primitives/UnsignedBytes.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */