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

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

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

Character.isUnicodeIdentifierPart介绍

[英]Indicates whether the specified character is valid as part of a Unicode identifier other than the first character.
[中]

代码示例

代码示例来源:origin: konsoletyper/teavm

@Override
  public boolean contains(int ch) {
    return Character.isUnicodeIdentifierPart(ch);
  }
};

代码示例来源:origin: pentaho/pentaho-kettle

/**
 * Create a valid filename using a name We remove all special characters, spaces, etc.
 *
 * @param name
 *          The name to use as a base for the filename
 * @return a valid filename
 */
public static String createFilename( String name ) {
 StringBuilder filename = new StringBuilder();
 for ( int i = 0; i < name.length(); i++ ) {
  char c = name.charAt( i );
  if ( Character.isUnicodeIdentifierPart( c ) ) {
   filename.append( c );
  } else if ( Character.isWhitespace( c ) ) {
   filename.append( '_' );
  }
 }
 return filename.toString().toLowerCase();
}

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

&& Character.isUnicodeIdentifierPart(pattern.charAt(i))) {
convBuf.append(pattern.charAt(i));
currentLiteral.append(pattern.charAt(i));

代码示例来源:origin: pentaho/pentaho-kettle

public static String createName( String filename ) {
 if ( Utils.isEmpty( filename ) ) {
  return filename;
 }
 String pureFilename = filenameOnly( filename );
 if ( pureFilename.endsWith( ".ktr" ) || pureFilename.endsWith( ".kjb" ) || pureFilename.endsWith( ".xml" ) ) {
  pureFilename = pureFilename.substring( 0, pureFilename.length() - 4 );
 }
 StringBuilder sb = new StringBuilder();
 for ( int i = 0; i < pureFilename.length(); i++ ) {
  char c = pureFilename.charAt( i );
  if ( Character.isUnicodeIdentifierPart( c ) ) {
   sb.append( c );
  } else if ( Character.isWhitespace( c ) ) {
   sb.append( ' ' );
  } else if ( c == '-' ) {
   sb.append( c );
  }
 }
 return sb.toString();
}

代码示例来源:origin: twosigma/beakerx

private KeyWithIndex findKey(final String txt, final int cur) {
 if (cur <= 0 || Character.isWhitespace(txt.charAt(cur - 1))) {
  return new KeyWithIndex("", txt.length());
 } else {
  String res = "";
  int eos = cur - 1;
  for (int i = eos; i >= 0; i--) {
   final boolean isIdentifier = Character.isUnicodeIdentifierPart(txt.charAt(i)) || PARAM_CHAR.charAt(0) == txt.charAt(i);
   if (isIdentifier) {
    eos = i;
   }
   if (!isIdentifier || i == 0) {
    res = new String(txt.substring(eos, cur));
    break;
   }
  }
  return new KeyWithIndex(res, eos);
 }
}

代码示例来源:origin: org.antlr/antlr4-runtime

public boolean isNameChar(int c) { return Character.isUnicodeIdentifierPart(c); }

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

int break2 = length - maxLength;
for (final int lower = (maxLength >> 1); break1 >= lower; break1--) {
  if (!Character.isUnicodeIdentifierPart(text.charAt(break1))) {
    break1--;
    while (break1 >= lower && !Character.isUnicodeIdentifierPart(text.charAt(break1))) {
      break1--;
  if (!Character.isUnicodeIdentifierPart(text.charAt(break2))) {
    break2++;
    while (break2 < upper && !Character.isUnicodeIdentifierPart(text.charAt(break2))) {
      break2++;

代码示例来源:origin: apache/log4j

&& Character.isUnicodeIdentifierPart(pattern.charAt(i))) {
convBuf.append(pattern.charAt(i));
currentLiteral.append(pattern.charAt(i));

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

while (upper < length && Character.isUnicodeIdentifierPart(text.charAt(upper))) {
  upper++;

代码示例来源:origin: org.ogce/xpp3

boolean isIdentifierChar(char c)
{
  switch ( c )
  {
    case '-':
    case '.':
      return true;
  }

  return Character.isUnicodeIdentifierPart( c );
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns the index after the last identifier character.
 */
private static int skipIdentifierPart(final String text, int i) {
  while (i < text.length()) {
    final int c = text.codePointAt(i);
    if (!Character.isUnicodeIdentifierPart(c)) break;
    i += Character.charCount(c);
  }
  return i;
}

代码示例来源:origin: org.eclipse/org.eclipse.ui.workbench.texteditor

private int getStart(String string, int end) {
  int start= end;
  if (start >= 1 && string.charAt(start - 1) == '$')
    return start - 1;
  while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
    start--;
  if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$')
    return start - 2;
  return end;
}

代码示例来源:origin: org.eclipse/org.eclipse.datatools.sqltools.sqleditor

private int getStart(String string, int end) 
{
  int start= end;
  if (start >= 1 && string.charAt(start - 1) == '$')
  return start - 1;
  while ((start != 0) && Character.isUnicodeIdentifierPart(string.charAt(start - 1)))
  start--;
  if (start >= 2 && string.charAt(start - 1) == '{' && string.charAt(start - 2) == '$')
  return start - 2;
  return end;
}

代码示例来源:origin: opengeospatial/geoapi

/**
 * Returns {@code true} if the given codepoint is an unicode identifier start or part.
 */
private static boolean isUnicodeIdentifier(final int codepoint, final boolean part) {
  return part ? Character.isUnicodeIdentifierPart (codepoint)
        : Character.isUnicodeIdentifierStart(codepoint);
}

代码示例来源:origin: com.tunnelvisionlabs/antlr4-runtime

private boolean NameChar_sempred(RuleContext _localctx, int predIndex) {
  switch (predIndex) {
  case 0:
    return Character.isUnicodeIdentifierPart(_input.LA(-1));
  }
  return true;
}
private boolean NameStartChar_sempred(RuleContext _localctx, int predIndex) {

代码示例来源:origin: org.apache.sis.core/sis-metadata

/**
 * Ensures that the given code point is a valid Unicode code point but not a Unicode identifier part.
 */
private static void ensureValidQuoteOrBracket(final String name, final int code) {
  ensureValidUnicodeCodePoint(name, code);
  if (Character.isUnicodeIdentifierPart(code) || Character.isSpaceChar(code) || code == FRAGMENT_VALUE) {
    throw new IllegalArgumentException(Errors.format(Errors.Keys.IllegalCharacter_2,
        name, String.valueOf(Character.toChars(code))));
  }
}

代码示例来源:origin: com.google.errorprone/javac-shaded

protected Name readIdentifier() {
  int start = bp;
  nextChar();
  while (bp < buflen && Character.isUnicodeIdentifierPart(ch))
    nextChar();
  return names.fromChars(buf, start, bp - start);
}

代码示例来源:origin: com.google.errorprone/javac-shaded

protected Name readTagName() {
  int start = bp;
  nextChar();
  while (bp < buflen
      && (Character.isUnicodeIdentifierPart(ch) || ch == '.'
      || ch == '-' || ch == ':')) {
    nextChar();
  }
  return names.fromChars(buf, start, bp - start);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

protected Name readIdentifier() {
  int start = bp;
  nextChar();
  while (bp < buflen && Character.isUnicodeIdentifierPart(ch))
    nextChar();
  return names.fromChars(buf, start, bp - start);
}

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

protected Name readTagName() {
  int start = bp;
  nextChar();
  while (bp < buflen && (Character.isUnicodeIdentifierPart(ch) || ch == '.'))
    nextChar();
  return names.fromChars(buf, start, bp - start);
}

相关文章

Character类方法