当前位置: 首页>>代码示例>>Java>>正文


Java Segment.setIndex方法代码示例

本文整理汇总了Java中javax.swing.text.Segment.setIndex方法的典型用法代码示例。如果您正苦于以下问题:Java Segment.setIndex方法的具体用法?Java Segment.setIndex怎么用?Java Segment.setIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.Segment的用法示例。


在下文中一共展示了Segment.setIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNextWordStart

import javax.swing.text.Segment; //导入方法依赖的package包/类
/** This helper method will return the start character of the next
 * word in the buffer from the start position
 */
private static int getNextWordStart(Segment text, int startPos) {
  if (startPos <= text.getEndIndex())
    for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
      if (Character.isLetterOrDigit(ch)) {
        return text.getIndex();
      }
    }
  return -1;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:13,代码来源:DocumentWordTokenizer.java

示例2: getNextWordEnd

import javax.swing.text.Segment; //导入方法依赖的package包/类
/** This helper method will return the end of the next word in the buffer.
 *
 */
private static int getNextWordEnd(Segment text, int startPos) {
  for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
    if (!Character.isLetterOrDigit(ch)) {
      if (ch == '-' || ch == '\'') { // handle ' and - inside words
        char ch2 = text.next();
        text.previous();
        if (ch2 != Segment.DONE && Character.isLetterOrDigit(ch2))
          continue;
      }
      return text.getIndex();
    }
  }
  return text.getEndIndex();
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:18,代码来源:DocumentWordTokenizer.java

示例3: removeEndingWhitespace

import javax.swing.text.Segment; //导入方法依赖的package包/类
/**
 * Removes any spaces or tabs from the end of the segment.
 *
 * @param segment The segment from which to remove tailing whitespace.
 * @return <code>segment</code> with trailing whitespace removed.
 */
private static Segment removeEndingWhitespace(Segment segment) {
	int toTrim = 0;
	char currentChar = segment.setIndex(segment.getEndIndex()-1);
	while ((currentChar==' ' || currentChar=='\t') && currentChar!=Segment.DONE) {
		toTrim++;
		currentChar = segment.previous();
	}
	String stringVal = segment.toString();
	String newStringVal = stringVal.substring(0,stringVal.length()-toTrim);
	return new Segment(newStringVal.toCharArray(), 0, newStringVal.length());
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:18,代码来源:RPrintUtilities.java

示例4: getNextWordStart

import javax.swing.text.Segment; //导入方法依赖的package包/类
/**
 * This helper method will return the start character of the next
 * word in the buffer from the start position
 *
 * @param  text      Description of the Parameter
 * @param  startPos  Description of the Parameter
 * @return           The nextWordStart value
 */
private static int getNextWordStart(Segment text, int startPos) {
	if (startPos <= text.getEndIndex())
		for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
			// changed by Saruta
			if (Character.isLetterOrDigit(ch) || ch == '-' || ch == '\'' || ch == '~') {
				return text.getIndex();
			}
		}
	return -1;
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:19,代码来源:DocumentWordTokenizer.java

示例5: getNextWordEnd

import javax.swing.text.Segment; //导入方法依赖的package包/类
/**
 * This helper method will return the end of the next word in the buffer.
 *
 * @param  text      Description of the Parameter
 * @param  startPos  Description of the Parameter
 * @return           The nextWordEnd value
 */
private static int getNextWordEnd(Segment text, int startPos) {
	for (char ch = text.setIndex(startPos); ch != Segment.DONE; ch = text.next()) {
		if (!Character.isLetterOrDigit(ch)) {
			// changed by Saruta
			if (ch == '-' || ch == '\'' || ch == '~') {
				// handle ' and - inside words
				continue;
			}
			return text.getIndex();
		}
	}
	return text.getEndIndex();
}
 
开发者ID:SarutaSan72,项目名称:Yass,代码行数:21,代码来源:DocumentWordTokenizer.java


注:本文中的javax.swing.text.Segment.setIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。