java.lang.Character.charValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(227)

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

Character.charValue介绍

[英]Gets the primitive value of this character.
[中]获取此字符的基元值。

代码示例

代码示例来源:origin: apache/incubator-dubbo

public static char unboxed(Character v) {
  return v == null ? '\0' : v.charValue();
}

代码示例来源:origin: apache/incubator-dubbo

public static char unboxed(Character v) {
  return v == null ? '\0' : v.charValue();
}

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

private char objectToKey(Object key) {
  return (char) ((Character) key).charValue();
}

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

private char objectToKey(Object key) {
  return (char) ((Character) key).charValue();
}

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

/**
 * Converts to primitive array.
 */
public static char[] values(Character[] array) {
  char[] dest = new char[array.length];
  for (int i = 0; i < array.length; i++) {
    Character v = array[i];
    if (v != null) {
      dest[i] = v.charValue();
    }
  }
  return dest;
}
/**

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

@Override
CharSequence trimTrailingPadding(CharSequence chars) {
 checkNotNull(chars);
 if (paddingChar == null) {
  return chars;
 }
 char padChar = paddingChar.charValue();
 int l;
 for (l = chars.length() - 1; l >= 0; l--) {
  if (chars.charAt(l) != padChar) {
   break;
  }
 }
 return chars.subSequence(0, l + 1);
}

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

@Override
public BaseEncoding withPadChar(char padChar) {
 if (8 % alphabet.bitsPerChar == 0
   || (paddingChar != null && paddingChar.charValue() == padChar)) {
  return this;
 } else {
  return newInstance(alphabet, padChar);
 }
}

代码示例来源:origin: spring-projects/spring-framework

@Override
  public T convert(Character source) {
    return NumberUtils.convertNumberToTargetClass((short) source.charValue(), this.targetType);
  }
}

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

@Override
 public void close() throws IOException {
  if (bitBufferLength > 0) {
   int charIndex = (bitBuffer << (alphabet.bitsPerChar - bitBufferLength)) & alphabet.mask;
   out.write(alphabet.encode(charIndex));
   writtenChars++;
   if (paddingChar != null) {
    while (writtenChars % alphabet.charsPerChunk != 0) {
     out.write(paddingChar.charValue());
     writtenChars++;
    }
   }
  }
  out.close();
 }
};

代码示例来源:origin: prestodb/presto

@Override
public BaseEncoding withPadChar(char padChar) {
 if (8 % alphabet.bitsPerChar == 0
   || (paddingChar != null && paddingChar.charValue() == padChar)) {
  return this;
 } else {
  return newInstance(alphabet, padChar);
 }
}

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

@Override
public BaseEncoding withSeparator(String separator, int afterEveryChars) {
 for (int i = 0; i < separator.length(); i++) {
  checkArgument(
    !alphabet.matches(separator.charAt(i)),
    "Separator (%s) cannot contain alphabet characters",
    separator);
 }
 if (paddingChar != null) {
  checkArgument(
    separator.indexOf(paddingChar.charValue()) < 0,
    "Separator (%s) cannot contain padding character",
    separator);
 }
 return new SeparatedBaseEncoding(this, separator, afterEveryChars);
}

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

/**
 * Converts value to <code>char</code>. Returns default value
 * when conversion result is <code>null</code>.
 */
public char toCharValue(Object value, char defaultValue) {
  Character result = (Character) typeConverters[13].convert(value);
  if (result == null) {
    return defaultValue;
  }
  return result.charValue();
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void encodeToWire(Buffer buffer, Character chr) {
 buffer.appendShort((short)chr.charValue());
}

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

/**
 * Converts type using type converter manager.
 */
protected char convertType(Object value) {
  return typeConverterManagerBean.convertType(value, char.class).charValue();
}

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

protected String objectToString(Object o) {
  if ( o == null ) {
    return "NULL";
  }
  if ( o.getClass().isArray() )
    return arrayToString(o);
  if ( o instanceof String ) {
    return "\""+o+"\"";
  }
  if ( o instanceof Character )
    return "'"+o+"'("+(int)((Character) o).charValue()+")";
  return ""+o;
}

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

@Override
public void writeObject(FSTObjectOutput out, Object toWrite, FSTClazzInfo clzInfo, FSTClazzInfo.FSTFieldInfo referencedBy, int streamPosition) throws IOException {
  out.writeChar(((Character)toWrite).charValue());
}

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

@Override
public BaseEncoding withPadChar(char padChar) {
 if (8 % alphabet.bitsPerChar == 0
   || (paddingChar != null && paddingChar.charValue() == padChar)) {
  return this;
 } else {
  return newInstance(alphabet, padChar);
 }
}

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

void encodeChunkTo(Appendable target, byte[] bytes, int off, int len) throws IOException {
 checkNotNull(target);
 checkPositionIndexes(off, off + len, bytes.length);
 checkArgument(len <= alphabet.bytesPerChunk);
 long bitBuffer = 0;
 for (int i = 0; i < len; ++i) {
  bitBuffer |= bytes[off + i] & 0xFF;
  bitBuffer <<= 8; // Add additional zero byte in the end.
 }
 // Position of first character is length of bitBuffer minus bitsPerChar.
 final int bitOffset = (len + 1) * 8 - alphabet.bitsPerChar;
 int bitsProcessed = 0;
 while (bitsProcessed < len * 8) {
  int charIndex = (int) (bitBuffer >>> (bitOffset - bitsProcessed)) & alphabet.mask;
  target.append(alphabet.encode(charIndex));
  bitsProcessed += alphabet.bitsPerChar;
 }
 if (paddingChar != null) {
  while (bitsProcessed < alphabet.bytesPerChunk * 8) {
   target.append(paddingChar.charValue());
   bitsProcessed += alphabet.bitsPerChar;
  }
 }
}

代码示例来源:origin: alibaba/fastjson

public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
  SerializeWriter out = serializer.out;
  Character value = (Character) object;
  if (value == null) {
    out.writeString("");
    return;
  }
  char c = value.charValue();
  if (c == 0) {
    out.writeString("\u0000");
  } else {
    out.writeString(value.toString());
  }
}

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

public void testGetDefaultValue() {
  assertEquals(false, Defaults.defaultValue(boolean.class).booleanValue());
  assertEquals('\0', Defaults.defaultValue(char.class).charValue());
  assertEquals(0, Defaults.defaultValue(byte.class).byteValue());
  assertEquals(0, Defaults.defaultValue(short.class).shortValue());
  assertEquals(0, Defaults.defaultValue(int.class).intValue());
  assertEquals(0, Defaults.defaultValue(long.class).longValue());
  assertEquals(0.0f, Defaults.defaultValue(float.class).floatValue());
  assertEquals(0.0d, Defaults.defaultValue(double.class).doubleValue());
  assertNull(Defaults.defaultValue(void.class));
  assertNull(Defaults.defaultValue(String.class));
 }
}

相关文章

Character类方法