org.modeshape.common.xml.XmlCharacters.isValidNameStart()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(84)

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

XmlCharacters.isValidNameStart介绍

[英]Determine whether the supplied character is a valid first character in an XML Name. The first character in an XML name is more restrictive than the #isValidName(int).
[中]确定提供的字符是否为XML名称中的有效第一个字符。XML名称中的第一个字符比#isValidName(int)更具限制性。

代码示例

代码示例来源:origin: org.fcrepo/modeshape-common

/**
 * Determine if the supplied name is a valid XML Name.
 * 
 * @param name the string being checked
 * @return true if the supplied name is indeed a valid XML Name, or false otherwise
 */
public static boolean isValidName( String name ) {
  if (name == null || name.length() == 0) return false;
  CharacterIterator iter = new StringCharacterIterator(name);
  char c = iter.first();
  if (!isValidNameStart(c)) return false;
  while (c != CharacterIterator.DONE) {
    if (!isValidName(c)) return false;
    c = iter.next();
  }
  return true;
}

代码示例来源:origin: org.modeshape/modeshape-common

/**
 * Determine if the supplied name is a valid XML Name.
 * 
 * @param name the string being checked
 * @return true if the supplied name is indeed a valid XML Name, or false otherwise
 */
public static boolean isValidName( String name ) {
  if (name == null || name.length() == 0) return false;
  CharacterIterator iter = new StringCharacterIterator(name);
  char c = iter.first();
  if (!isValidNameStart(c)) return false;
  while (c != CharacterIterator.DONE) {
    if (!isValidName(c)) return false;
    c = iter.next();
  }
  return true;
}

代码示例来源:origin: ModeShape/modeshape

/**
 * Determine if the supplied name is a valid XML Name.
 * 
 * @param name the string being checked
 * @return true if the supplied name is indeed a valid XML Name, or false otherwise
 */
public static boolean isValidName( String name ) {
  if (name == null || name.length() == 0) return false;
  CharacterIterator iter = new StringCharacterIterator(name);
  char c = iter.first();
  if (!isValidNameStart(c)) return false;
  while (c != CharacterIterator.DONE) {
    if (!isValidName(c)) return false;
    c = iter.next();
  }
  return true;
}

代码示例来源:origin: ModeShape/modeshape

@Test
public void shouldNotAllowDigitAsFirstCharacterInName() {
  assertThat(XmlCharacters.isValidNameStart('0'), is(false));
  assertThat(XmlCharacters.isValidNameStart('1'), is(false));
  assertThat(XmlCharacters.isValidNameStart('2'), is(false));
  assertThat(XmlCharacters.isValidNameStart('3'), is(false));
  assertThat(XmlCharacters.isValidNameStart('4'), is(false));
  assertThat(XmlCharacters.isValidNameStart('5'), is(false));
  assertThat(XmlCharacters.isValidNameStart('6'), is(false));
  assertThat(XmlCharacters.isValidNameStart('7'), is(false));
  assertThat(XmlCharacters.isValidNameStart('8'), is(false));
  assertThat(XmlCharacters.isValidNameStart('9'), is(false));
}

代码示例来源:origin: ModeShape/modeshape

@Test
public void shouldAllowLettersAsFirstCharacterInName() {
  for (char c = 'a'; c <= 'z'; ++c) {
    assertThat(XmlCharacters.isValidNameStart(c), is(true));
  }
  for (char c = 'A'; c <= 'Z'; ++c) {
    assertThat(XmlCharacters.isValidNameStart(c), is(true));
  }
}

相关文章