java.util.StringTokenizer.hasMoreElements()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(117)

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

StringTokenizer.hasMoreElements介绍

[英]Returns true if unprocessed tokens remain. This method is implemented in order to satisfy the Enumeration interface.
[中]如果未处理的令牌仍然存在,则返回true。该方法的实现是为了满足枚举接口。

代码示例

代码示例来源:origin: stanfordnlp/CoreNLP

/** Basic string tokenization, skipping over white spaces */
public static ArrayList<String> tokenize(String line) {
 ArrayList<String> tokens = new ArrayList<>();
 StringTokenizer tokenizer = new StringTokenizer(line);
 while (tokenizer.hasMoreElements()) {
  tokens.add(tokenizer.nextToken());
 }
 return tokens;
}

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

public static String deblank(String str) {
  StringTokenizer s = new StringTokenizer(str, " ", false);
  StringBuilder strRet = new StringBuilder();
  while (s.hasMoreElements())
    strRet.append(s.nextElement());
  return strRet.toString();
}

代码示例来源:origin: org.testng/testng

public static Class[] getClassArray(String tagValue, Class[] def) {
 Class[] result = def;
 List vResult = Lists.newArrayList();
 if (tagValue != null) {
  StringTokenizer st = new StringTokenizer(tagValue, " ,");
  while (st.hasMoreElements()) {
   String className = (String) st.nextElement();
   try {
    Class cls = Class.forName(className);
    vResult.add(cls);
   }
   catch (ClassNotFoundException e) {
    e.printStackTrace();
   }
  }
  result = (Class[]) vResult.toArray(new Class[vResult.size()]);
 }
 return result;
}

代码示例来源:origin: DozerMapper/dozer

public List<Class<?>> getHints() {
  if (hints == null) {
    List<Class<?>> list = new ArrayList<>();
    StringTokenizer st = new StringTokenizer(this.hintName, ",");
    while (st.hasMoreElements()) {
      String theHintName = st.nextToken().trim();
      Class<?> clazz = MappingUtils.loadClass(theHintName, beanContainer);
      list.add(clazz);
    }
    hints = list;
  }
  return hints;
}

代码示例来源:origin: linkedin/indextank-engine

private static String getNext(Stack<String> stack, StringTokenizer tokenizer) {
    if (stack.size() > 0) return stack.pop();
    else if (tokenizer.hasMoreElements()) return (String) tokenizer.nextElement();
    else return null;
  }
}

代码示例来源:origin: uber/okbuck

System.err.println("--main command switch not provided.");
return 1;
 StringTokenizer stringTokenizer = new StringTokenizer(value, File.pathSeparator);
 while (stringTokenizer.hasMoreElements()) {
  File library = checkPath(stringTokenizer.nextToken());
  invoker.addLibraryManifest(library);
 StringTokenizer stringTokenizer = new StringTokenizer(value, File.pathSeparator);
 while (stringTokenizer.hasMoreElements()) {
  File library = checkPath(stringTokenizer.nextToken());
  invoker.addFlavorAndBuildTypeManifest(library);
   System.out.println(mergedDocument);
  System.err.println(record);

代码示例来源:origin: languagetool-org/languagetool

@Override
public List<String> tokenize(String text) {
 List<String> l = new ArrayList<>();
 StringTokenizer st = new StringTokenizer(text, getTokenizingCharacters(), true);
 while (st.hasMoreElements()) {
  l.add(st.nextToken());
 }
 return joinEMailsAndUrls(l);
}

代码示例来源:origin: stanfordnlp/CoreNLP

/** Basic string tokenization, skipping over white spaces */
public static ArrayList<String> tokenize(String line, String separators) {
 ArrayList<String> tokens = new ArrayList<>();
 StringTokenizer tokenizer = new StringTokenizer(line, separators);
 while (tokenizer.hasMoreElements()) {
  tokens.add(tokenizer.nextToken());
 }
 return tokens;
}

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

public static String deblank(String str) {
  StringTokenizer s = new StringTokenizer(str, " ", false);
  StringBuilder strRet = new StringBuilder();
  while (s.hasMoreElements())
    strRet.append(s.nextElement());
  return strRet.toString();
}

代码示例来源:origin: org.hibernate/hibernate-annotations

private List<ConfigurationArtefactType> parsePrecedence(String s) {
  if ( StringHelper.isEmpty( s ) ) {
    return Collections.emptyList();
  }
  StringTokenizer precedences = new StringTokenizer( s, ",; ", false );
  List<ConfigurationArtefactType> tmpPrecedences = new ArrayList<ConfigurationArtefactType>();
  while ( precedences.hasMoreElements() ) {
    tmpPrecedences.add( ConfigurationArtefactType.parsePrecedence( ( String ) precedences.nextElement() ) );
  }
  return tmpPrecedences;
}

代码示例来源:origin: hibernate/hibernate-orm

public JPAIndexHolder(Index index) {
  StringTokenizer tokenizer = new StringTokenizer( index.columnList(), "," );
  List<String> tmp = new ArrayList<String>();
  while ( tokenizer.hasMoreElements() ) {
    tmp.add( tokenizer.nextToken().trim() );
  }
  this.name = index.name();
  this.columns = new String[tmp.size()];
  this.ordering = new String[tmp.size()];
  this.unique = index.unique();
  initializeColumns( columns, ordering, tmp );
}

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

public String[] getDropStrings( String str, String sep ) {
 StringTokenizer strtok = new StringTokenizer( str, sep );
 String[] retval = new String[ strtok.countTokens() ];
 int i = 0;
 while ( strtok.hasMoreElements() ) {
  retval[ i ] = strtok.nextToken();
  i++;
 }
 return retval;
}

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

StringTokenizer tokens = new StringTokenizer(value);
while (tokens.hasMoreElements()) {
String token = (String)tokens.nextElement();
if (token.startsWith("href"))
  href = getTokenValue(token);

代码示例来源:origin: org.eclipse.core/runtime

private URL[] readPluginPath(InputStream input) {
  Properties ini = new Properties();
  try {
    ini.load(input);
  } catch (IOException e) {
    return null;
  }
  List<URL>result = new ArrayList<URL>(5);
  for (Enumeration<?> groups = ini.propertyNames(); groups.hasMoreElements();) {
    String group = (String) groups.nextElement();
    for (StringTokenizer entries = new StringTokenizer(ini.getProperty(group), ";"); entries.hasMoreElements();) { //$NON-NLS-1$
      String entry = (String) entries.nextElement();
      if (!entry.equals("")) //$NON-NLS-1$
        try {
          result.add(new URL(entry));
        } catch (MalformedURLException e) {
          //intentionally ignore bad URLs
          System.err.println("Ignoring plugin: " + entry); //$NON-NLS-1$
        }
    }
  }
  return result.toArray(new URL[result.size()]);
}

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

StringTokenizer semiColonSplitter = new StringTokenizer(rawOptionString, ";");
while (semiColonSplitter.hasMoreElements()) {
  String curKVP = semiColonSplitter.nextToken();
  if (values.indexOf(",") != -1) {
    List valueList = new ArrayList();
    StringTokenizer commaSplitter = new StringTokenizer(values, ",");
    while (commaSplitter.hasMoreElements()) valueList.add(commaSplitter.nextToken());

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

private static Set<String> parseFile(String fileName) throws IOException {
  File file = new File(fileName);
  Set<String> wordSet = new HashSet<>();
  if (!file.exists()) {
    return wordSet;
  }
  StringTokenizer tokens = new StringTokenizer(readFile(file).toString(), "\r\n");
  while (tokens.hasMoreElements()) {
    wordSet.add(tokens.nextToken());
  }
  LOG.debug("parseFile {}", wordSet);
  return wordSet;
}

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

StringTokenizer queryTokenizer = new StringTokenizer(query, "&");
while (queryTokenizer.hasMoreElements()) {
 String token = (String) queryTokenizer.nextElement();
 CharSequence value = null;
 int equalsIndex = token.indexOf('=');

代码示例来源:origin: Impetus/Kundera

final String space = " ";
StringTokenizer tokenizer = new StringTokenizer(ordering, comma);
  String order = (String) tokenizer.nextElement();
  StringTokenizer token = new StringTokenizer(order, space);
  SortOrder orderType = SortOrder.ASC;
  String colName = (String) token.nextElement();
  while (token.hasMoreElements()) {
    String nextOrder = (String) token.nextElement();
  sortOrders.add(new SortOrdering(colName, orderType));

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

protected List<String> toLines(String input) {
  StringTokenizer tokenizer = new StringTokenizer(input, "\n\r");
  List<String> output = new ArrayList<String>();
  while (tokenizer.hasMoreElements()) {
    output.add(tokenizer.nextToken());
  }
  return output;
}

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

protected static FileHandle getRelativeFileHandle (FileHandle file, String path) {
  StringTokenizer tokenizer = new StringTokenizer(path, "\\/");
  FileHandle result = file.parent();
  while (tokenizer.hasMoreElements()) {
    String token = tokenizer.nextToken();
    if (token.equals(".."))
      result = result.parent();
    else {
      result = result.child(token);
    }
  }
  return result;
}

相关文章