本文整理了Java中javax.swing.text.Segment.toString()
方法的一些代码示例,展示了Segment.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Segment.toString()
方法的具体详情如下:
包路径:javax.swing.text.Segment
类名称:Segment
方法名:toString
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
/**
* 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());
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
String currentLineString = currentLineSeg.toString();
for (int i=0; i<BREAK_CHARS.length; i++) {
代码示例来源:origin: net.sf.jazzy/jazzy
/** Returns the current text that is being tokenized (includes any changes
* that have been made)
* @return The text, including changes.
*/
public String getContext() {
return text.toString();
}
代码示例来源:origin: stackoverflow.com
for (Segment segment : source) {
if (segment instanceof Tag) {
Tag tag = (Tag) segment;
System.out.println("FOUND TAG: " + tag.getName());
// DO SOMETHING HERE TO SKIP ENTIRE ELEMENT IF IS <A> OR CLASS="noProcess"
continue;
} else if (segment instanceof CharacterReference) {
CharacterReference characterReference = (CharacterReference) segment;
System.out.println("FOUND CHARACTERREFERENCE: " + characterReference.getCharacterReferenceString());
for(Segment child : segment.childNodes()) {
//Use recursion to process child elements
//You will want to put your for loop in a separate method so it can be called recursively.
}
} else {
System.out.println("FOUND PLAIN TEXT: " + segment.toString());
outputDocument.replace(segment, doProcessText(segment.toString()));
}
}
代码示例来源:origin: com.github.houbie/rhino-mod
synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch(javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
if(segment.count > 0) {
history.add(segment.toString());
}
historyIndex = history.size();
inPipe.write(segment.array, segment.offset, segment.count);
append("\n");
outputMark = doc.getLength();
inPipe.write("\n");
inPipe.flush();
console1.flush();
}
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch(javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
if(segment.count > 0) {
history.add(segment.toString());
}
historyIndex = history.size();
inPipe.write(segment.array, segment.offset, segment.count);
append("\n");
outputMark = doc.getLength();
inPipe.write("\n");
inPipe.flush();
console1.flush();
}
代码示例来源:origin: com.github.tntim96/rhino
synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch(javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
if(segment.count > 0) {
history.add(segment.toString());
}
historyIndex = history.size();
inPipe.write(segment.array, segment.offset, segment.count);
append("\n");
outputMark = doc.getLength();
inPipe.write("\n");
inPipe.flush();
console1.flush();
}
代码示例来源:origin: ro.isdc.wro4j/rhino
synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch(javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
if(segment.count > 0) {
history.add(segment.toString());
}
historyIndex = history.size();
inPipe.write(segment.array, segment.offset, segment.count);
append("\n");
outputMark = doc.getLength();
inPipe.write("\n");
inPipe.flush();
console1.flush();
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-editor
/**
* 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());
}
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
/**
* 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());
}
代码示例来源:origin: org.nuiton.thirdparty/rsyntaxtextarea
/**
* 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());
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
"this should not happen (calculated the valid start/length) " , ex);
Matcher matcher = pattern.matcher(segment.toString());
MatchResult currentResult = getMatchResult(matcher, true);
if (currentResult != null) {
代码示例来源:origin: stackoverflow.com
CharacterReference characterReference = (CharacterReference) segment;
} else {
outputDocument.replace(segment, doProcessText(segment.toString()));
代码示例来源:origin: org.jvnet.hudson/embedded-rhino-debugger
/**
* Called when Enter is pressed.
*/
private synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch (javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
String text = segment.toString();
if (debugGui.dim.stringIsCompilableUnit(text)) {
if (text.trim().length() > 0) {
history.add(text);
historyIndex = history.size();
}
append("\n");
String result = debugGui.dim.eval(text);
if (result.length() > 0) {
append(result);
append("\n");
}
append("% ");
outputMark = doc.getLength();
} else {
append("\n");
}
}
代码示例来源:origin: ro.isdc.wro4j/rhino
/**
* Called when Enter is pressed.
*/
private synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch (javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
String text = segment.toString();
if (debugGui.dim.stringIsCompilableUnit(text)) {
if (text.trim().length() > 0) {
history.add(text);
historyIndex = history.size();
}
append("\n");
String result = debugGui.dim.eval(text);
if (result.length() > 0) {
append(result);
append("\n");
}
append("% ");
outputMark = doc.getLength();
} else {
append("\n");
}
}
代码示例来源:origin: com.github.houbie/rhino-mod
/**
* Called when Enter is pressed.
*/
private synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch (javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
String text = segment.toString();
if (debugGui.dim.stringIsCompilableUnit(text)) {
if (text.trim().length() > 0) {
history.add(text);
historyIndex = history.size();
}
append("\n");
String result = debugGui.dim.eval(text);
if (result.length() > 0) {
append(result);
append("\n");
}
append("% ");
outputMark = doc.getLength();
} else {
append("\n");
}
}
代码示例来源:origin: com.github.tntim96/rhino
/**
* Called when Enter is pressed.
*/
private synchronized void returnPressed() {
Document doc = getDocument();
int len = doc.getLength();
Segment segment = new Segment();
try {
doc.getText(outputMark, len - outputMark, segment);
} catch (javax.swing.text.BadLocationException ignored) {
ignored.printStackTrace();
}
String text = segment.toString();
if (debugGui.dim.stringIsCompilableUnit(text)) {
if (text.trim().length() > 0) {
history.add(text);
historyIndex = history.size();
}
append("\n");
String result = debugGui.dim.eval(text);
if (result.length() > 0) {
append(result);
append("\n");
}
append("% ");
outputMark = doc.getLength();
} else {
append("\n");
}
}
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
undoMgr.contentInserted(offset, seg.count, seg.toString(),
!dirty);
代码示例来源:origin: de.sciss/jsyntaxpane
/**
* Gets the line at given position. The line returned will NOT include
* the line terminator '\n'
* @param pos Position (usually from text.getCaretPosition()
* @return the STring of text at given position
* @throws BadLocationException
*/
public String getLineAt(int pos) throws BadLocationException {
Element e = getParagraphElement(pos);
Segment seg = new Segment();
getText(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), seg);
char last = seg.last();
if (last == '\n' || last == '\r') {
seg.count--;
}
return seg.toString();
}
代码示例来源:origin: de.sciss/syntaxpane
/**
* Gets the line at given position. The line returned will NOT include
* the line terminator '\n'
* @param pos Position (usually from text.getCaretPosition()
* @return the String of text at given position
*/
public String getLineAt(int pos) throws BadLocationException {
Element e = getParagraphElement(pos);
Segment seg = new Segment();
getText(e.getStartOffset(), e.getEndOffset() - e.getStartOffset(), seg);
char last = seg.last();
if (last == '\n' || last == '\r') {
seg.count--;
}
return seg.toString();
}
内容来源于网络,如有侵权,请联系作者删除!