• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Utf16Util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.waveprotocol.wave.model.util.Utf16Util的典型用法代码示例。如果您正苦于以下问题:Java Utf16Util类的具体用法?Java Utf16Util怎么用?Java Utf16Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Utf16Util类属于org.waveprotocol.wave.model.util包,在下文中一共展示了Utf16Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: makeMassiveString

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
String makeMassiveString() {
  int numCodePoints = 1 << 19;
  StringBuilder b = new StringBuilder(
      // Overestimate.
      numCodePoints * 2);
  int nextCp = 0;
  for (int i = 0; i < numCodePoints; i++) {
    b.appendCodePoint(nextCp);
    if (i + 1 < numCodePoints && i % 80 == 79) {
      b.append("\n");
      i++;
    }
    nextCp = (nextCp + 1) & 0x10ffff;
    while (Utf16Util.isSurrogate(nextCp) || !Utf16Util.isCodePointValid(nextCp)) {
      //log.info("Skipping cp " + nextCp);
      nextCp = (nextCp + 1) & 0x10ffff;
    }
  }
  return "" + b;
}
 
开发者ID:ArloJamesBarnes,项目名称:walkaround,代码行数:21,代码来源:MutationLogTest.java


示例2: getTextChunk

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
@VisibleForTesting
Item getTextChunk() throws XmlParseException {
  StringBuffer b = new StringBuffer();
  while (true) {
    String c = charData();
    if (c != null) {
      b.append(c);
      continue;
    }
    String r = reference();
    if (r != null) {
      b.append(r);
      continue;
    }
    if (b.length() > 0) {
      String val = b.toString();
      // Ensure that the sequence of character references form valid UTF-16
      ensure(Utf16Util.isValidUtf16(val), "Not valid UTF-16: " + val);
      return Item.text(val);
    } else {
      return null;
    }
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:StreamingXmlParser.java


示例3: checkAttributesUpdateWellFormed

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private ValidationResult checkAttributesUpdateWellFormed(AttributesUpdate u,
    ViolationCollector v) {
  if (u == null) { return nullAttributesUpdate(v); }
  String previousKey = null;
  for (int i = 0; i < u.changeSize(); i++) {
    String key = u.getChangeKey(i);
    if (key == null) { return nullAttributeKey(v); }
    if (!Utf16Util.isXmlName(key)) { return attributeNameNotXmlName(v, key); }
    if (previousKey != null && previousKey.compareTo(key) >= 0) {
      return attributeKeysNotStrictlyMonotonic(v, previousKey, key);
    }
    if (u.getOldValue(i) != null && !Utf16Util.isValidUtf16(u.getOldValue(i))) {
      return attributeValueNotValidUtf16(v);
    }
    if (u.getNewValue(i) != null && !Utf16Util.isValidUtf16(u.getNewValue(i))) {
      return attributeValueNotValidUtf16(v);
    }
    previousKey = key;
  }
  return ValidationResult.VALID;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:22,代码来源:DocOpAutomaton.java


示例4: checkDeleteCharacters

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
public ValidationResult checkDeleteCharacters(String chars, ViolationCollector v) {
  // well-formedness
  if (chars == null) { return nullCharacters(v); }
  if (chars.isEmpty()) { return emptyCharacters(v); }
  if (Utf16Util.firstSurrogate(chars) != -1) { return deleteCharactersContainsSurrogate(v); }
  if (!Utf16Util.isValidUtf16(chars)) { return deleteCharactersInvalidUnicode(v); }
  if (!insertionStackIsEmpty()) { return deleteInsideInsert(v); }
  // validity
  int docLength = doc.length();
  for (int offset = 0; offset < chars.length(); offset++) {
    if (effectivePos + offset >= docLength) {
      return cannotDeleteSoManyCharacters(v, offset, chars);
    }
    int charHereIfAny = doc.charAt(effectivePos + offset);
    if (charHereIfAny == -1) {
      return cannotDeleteSoManyCharacters(v, offset, chars);
    }
    char charHere = (char) charHereIfAny;
    if (charHere != chars.charAt(offset)) {
      return oldCharacterDiffersFromDocument(v, charHere, chars.charAt(offset));
    }
  }
  return checkAnnotationsForDeletion(v, chars.length());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:25,代码来源:DocOpAutomaton.java


示例5: extractCodePoints

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
/**
 * Extracts code points from a given character string.
 *
 * @param chars a character string from which to extract code points
 * @return the code points extracted from the given string
 */
private static List<Integer> extractCodePoints(String chars) throws InvalidSchemaException {
  List<Integer> codePoints = Utf16Util.traverseUtf16String(chars, codePointExtractor);
  if (codePoints == ERROR_LIST) {
    throw new InvalidSchemaException("Invalid code point in string: " + chars);
  }
  return codePoints;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:SchemaFactory.java


示例6: codePoint

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
@Override
public Boolean codePoint(int cp) {
  if (!Utf16Util.isCodePointValid(cp)) {
    return false;
  }
  if (cp < SAFE_ASCII_CHARS.length && !SAFE_ASCII_CHARS[cp]) {
    return false;
  }
  if (cp >= SAFE_ASCII_CHARS.length && !isUcsChar(cp)) {
    return false;
  }
  return null;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:WaveIdentifiers.java


示例7: advanceCodePoint

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private void advanceCodePoint() {
  if (Utf16Util.isHighSurrogate(str.charAt(position))) {
    position += 2;
  } else {
    position++;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:8,代码来源:StreamingXmlParser.java


示例8: StreamingXmlParser

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
StreamingXmlParser(String xml) throws XmlParseException {
  // Ensure that the input is valid UTF-16 here, makes rest of the code
  // simpler
  if (Utf16Util.isValidUtf16(xml)) {
    buffer = new Buffer(xml);
  } else {
    throw new XmlParseException("Input is not valid UTF-16: " + xml);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:10,代码来源:StreamingXmlParser.java


示例9: isXmlNameStartChar

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private boolean isXmlNameStartChar(int codePoint) throws XmlParseException {
  try {
    return Utf16Util.isXmlNameStartChar(codePoint);
  } catch (RuntimeException e) {
    throw new XmlParseException(e);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:8,代码来源:StreamingXmlParser.java


示例10: isXmlNameChar

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private boolean isXmlNameChar(int codePoint) throws XmlParseException {
  try {
    return Utf16Util.isXmlNameChar(codePoint);
  } catch (RuntimeException e) {
    throw new XmlParseException(e);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:8,代码来源:StreamingXmlParser.java


示例11: charReference

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
@VisibleForTesting
String charReference() throws XmlParseException {
  if (match(charReferenceStart)) {
    final int base;
    final ReadableStringSet validDigits;
    if (match('x')) {
      base = 16;
      validDigits = BASE_16_DIGITS;
    } else {
      base = 10;
      validDigits = BASE_10_DIGITS;
    }
    final int start = buffer.getPosition();
    while (validDigits.contains("" + (char) buffer.peek())) {
      buffer.advanceCodeUnit(1);
    }
    final int end = buffer.getPosition();
    ensure(start != end, "empty char reference");
    final int codePoint;
    final String number = buffer.substring(start, end);
    try {
      codePoint = Integer.parseInt(number, base);
    } catch (NumberFormatException e) {
      throw new XmlParseException("Could not parse number: " + number, e);
    }
    ensure(Utf16Util.isCodePoint(codePoint), "Not a codepoint: " + (base == 16 ? "0x" : "")
        + number);
    String ret = String.valueOf(Character.toChars(codePoint));
    ensure(match(';'), "Must match ; at end of charReference");
    return ret;
  }
  return null;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:34,代码来源:StreamingXmlParser.java


示例12: checkAttributesWellFormed

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private ValidationResult checkAttributesWellFormed(Attributes attr, ViolationCollector v) {
  if (attr == null) { return nullAttributes(v); }
  String previousKey = null;
  for (Map.Entry<String, String> e : attr.entrySet()) {
    if (e.getKey() == null) { return nullAttributeKey(v); }
    if (!Utf16Util.isXmlName(e.getKey())) { return attributeNameNotXmlName(v, e.getKey()); }
    if (e.getValue() == null) { return nullAttributeValue(v); }
    if (!Utf16Util.isValidUtf16(e.getValue())) { return attributeValueNotValidUtf16(v); }
    if (previousKey != null && previousKey.compareTo(e.getKey()) >= 0) {
      return attributeKeysNotStrictlyMonotonic(v, previousKey, e.getKey());
    }
    previousKey = e.getKey();
  }
  return ValidationResult.VALID;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:16,代码来源:DocOpAutomaton.java


示例13: checkElementType

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private static void checkElementType(String name) throws InvalidSchemaException {
  if (!Utf16Util.isXmlName(name)) {
    throw new InvalidSchemaException("Invalid element type: " + name);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:SchemaFactory.java


示例14: checkAttributeName

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private static void checkAttributeName(String name) throws InvalidSchemaException {
  if (!Utf16Util.isXmlName(name)) {
    throw new InvalidSchemaException("Invalid attribute name: " + name);
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:SchemaFactory.java


示例15: isValidIdentifier

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
/**
 * Checks whether a UTF-16 string is a valid wave identifier.
 */
public static boolean isValidIdentifier(String id) {
  return !id.isEmpty() && Utf16Util.traverseUtf16String(id, GOOD_UTF16_FOR_ID);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:7,代码来源:WaveIdentifiers.java


示例16: AnnotationParser

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private AnnotationParser(String input) throws XmlParseException {
  this.input = input;
  ensure(Utf16Util.isValidUtf16(input),
    "Input is not valid UTF-16: ", input);
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:AnnotationParser.java


示例17: validateAnnotationKey

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private ValidationResult validateAnnotationKey(String key, ViolationCollector v) {
  if (key == null) { return nullAnnotationKey(v); }
  if (key.contains("?") || key.contains("@")) { return invalidCharacterInAnnotationKey(v, key); }
  if (!Utf16Util.isValidUtf16(key)) { return annotationKeyNotValidUtf16(v); }
  return ValidationResult.VALID;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:7,代码来源:DocOpAutomaton.java


示例18: validateAnnotationValue

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private ValidationResult validateAnnotationValue(String value, ViolationCollector v) {
if (value == null) { return ValidationResult.VALID; }
if (!Utf16Util.isValidUtf16(value)) { return annotationValueNotValidUtf16(v); }
  return ValidationResult.VALID;
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:DocOpAutomaton.java


示例19: checkValidTagName

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private void checkValidTagName(String tagName) {
  if (!Utf16Util.isXmlName(tagName)) {
    Preconditions.illegalArgument("Invalid tag name: '" + tagName + "'");
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:XmlStringBuilderDoc.java


示例20: checkValidAttributeName

import org.waveprotocol.wave.model.util.Utf16Util; //导入依赖的package包/类
private void checkValidAttributeName(String tagName) {
  if (!Utf16Util.isXmlName(tagName)) {
    Preconditions.illegalArgument("Invalid attribute name: '" + tagName + "'");
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:6,代码来源:XmlStringBuilderDoc.java



注:本文中的org.waveprotocol.wave.model.util.Utf16Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java UifDictionaryIndex类代码示例发布时间:2022-05-16
下一篇:
Java SocialStreamActivity类代码示例发布时间:2022-05-16
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap