com.google.common.hash.HashCode.decode()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中com.google.common.hash.HashCode.decode()方法的一些代码示例,展示了HashCode.decode()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HashCode.decode()方法的具体详情如下:
包路径:com.google.common.hash.HashCode
类名称:HashCode
方法名:decode

HashCode.decode介绍

暂无

代码示例

代码示例来源:origin: google/guava

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode}
 * (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(
   string.length() >= 2, "input string (%s) must have at least 2 characters", string);
 checkArgument(
   string.length() % 2 == 0,
   "input string (%s) must have an even number of characters",
   string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: google/j2objc

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode}
 * (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(
   string.length() >= 2, "input string (%s) must have at least 2 characters", string);
 checkArgument(
   string.length() % 2 == 0,
   "input string (%s) must have an even number of characters",
   string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: wildfly/wildfly

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode}
 * (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(
   string.length() >= 2, "input string (%s) must have at least 2 characters", string);
 checkArgument(
   string.length() % 2 == 0,
   "input string (%s) must have an even number of characters",
   string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: Nextdoor/bender

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode}
 * (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(
   string.length() >= 2, "input string (%s) must have at least 2 characters", string);
 checkArgument(
   string.length() % 2 == 0,
   "input string (%s) must have an even number of characters",
   string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: com.google.guava/guava-jdk5

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use
 * {@link com.google.common.io.BaseEncoding#decode} (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(string.length() >= 2,
   "input string (%s) must have at least 2 characters", string);
 checkArgument(string.length() % 2 == 0,
   "input string (%s) must have an even number of characters", string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Creates a {@code HashCode} from a hexadecimal ({@code base 16}) encoded string. The string must
 * be at least 2 characters long, and contain only valid, lower-cased hexadecimal characters.
 *
 * <p>This method accepts the exact format generated by {@link #toString}. If you require more
 * lenient {@code base 16} decoding, please use {@link com.google.common.io.BaseEncoding#decode}
 * (and pass the result to {@link #fromBytes}).
 *
 * @since 15.0
 */
public static HashCode fromString(String string) {
 checkArgument(
   string.length() >= 2, "input string (%s) must have at least 2 characters", string);
 checkArgument(
   string.length() % 2 == 0,
   "input string (%s) must have an even number of characters",
   string);
 byte[] bytes = new byte[string.length() / 2];
 for (int i = 0; i < string.length(); i += 2) {
  int ch1 = decode(string.charAt(i)) << 4;
  int ch2 = decode(string.charAt(i + 1));
  bytes[i / 2] = (byte) (ch1 + ch2);
 }
 return fromBytesNoCopy(bytes);
}

相关文章