bugged
stringlengths
6
599k
fixed
stringlengths
6
40.8M
__index_level_0__
int64
0
3.24M
public int next() { int end = iter.getEndIndex(); if (iter.getIndex() == end) return DONE; while (iter.getIndex() < end) { char c = iter.current(); if (c == CharacterIterator.DONE) break; int type = Character.getType(c); char n = iter.next(); if (n == CharacterIterator.DONE) break; // Always break after paragraph separator. if (type == Character.PARAGRAPH_SEPARATOR) break; if (c == '!' || c == '?') { // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.next(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.next(); // There's always a break somewhere after `!' or `?'. break; } if (c == '.') { int save = iter.getIndex(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.next(); // Skip (java) space, line and paragraph separators. // We keep count because we need at least one for this period to // represent a terminator. int spcount = 0; while (n != CharacterIterator.DONE && Character.isWhitespace(n)) { n = iter.next(); ++spcount; } if (spcount > 0) { int save2 = iter.getIndex(); // Skip over open puncutation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.next(); // Next character must not be lower case. if (n == CharacterIterator.DONE || !Character.isLowerCase(n)) { iter.setIndex(save2); break; } } iter.setIndex(save); } } return iter.getIndex(); }
public int next() { int end = iter.getEndIndex(); if (iter.getIndex() == end) return DONE; while (iter.getIndex() < end) { char c = iter.current(); if (c == CharacterIterator.DONE) break; int type = Character.getType(c); char n = iter.next(); if (n == CharacterIterator.DONE) break; // Always break after paragraph separator. if (type == Character.PARAGRAPH_SEPARATOR) break; if (c == '!' || c == '?') { // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.next(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.next(); // There's always a break somewhere after `!' or `?'. break; } if (c == '.') { int save = iter.getIndex(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.next(); // Skip (java) space, line and paragraph separators. // We keep count because we need at least one for this period to // represent a terminator. int spcount = 0; while (n != CharacterIterator.DONE && Character.isWhitespace(n)) { n = iter.next(); ++spcount; } if (spcount > 0) { int save2 = iter.getIndex(); // Skip over open puncutation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.next(); // Next character must not be lower case. if (n == CharacterIterator.DONE || !Character.isLowerCase(n)) { iter.setIndex(save2); break; } } iter.setIndex(save); } } return iter.getIndex(); }
5,060
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
5,061
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
5,062
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
public int previous() { // We want to skip over the first sentence end to the second one. // However, at the end of the string we want the first end. int here = iter.getIndex(); period = here; int first = previous_internal(); if (here == iter.getEndIndex() || first == DONE) return first; iter.setIndex(period); return previous_internal(); }
5,063
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,064
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,065
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,066
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,067
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,068
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,069
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,070
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,071
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,072
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,073
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,074
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,075
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,076
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
private final int previous_internal() { int start = iter.getBeginIndex(); if (iter.getIndex() == start) return DONE; while (iter.getIndex() >= start) { char c = iter.previous(); if (c == CharacterIterator.DONE) break; char n = iter.previous(); if (n == CharacterIterator.DONE) break; iter.next(); int nt = Character.getType(n); if (!Character.isLowerCase(c) && (nt == Character.START_PUNCTUATION || Character.isWhitespace(n))) { int save = iter.getIndex(); int save_nt = nt; char save_n = n; // Skip open punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.START_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE) break; if (Character.isWhitespace(n)) { // Must have at least one (java) space after the `.'. int save2 = iter.getIndex(); while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); if (n == CharacterIterator.DONE || n == '.') { // Communicate location of actual end. period = iter.getIndex(); iter.setIndex(save2); break; } } iter.setIndex(save); nt = save_nt; n = save_n; } if (nt == Character.PARAGRAPH_SEPARATOR) { // Communicate location of actual end. period = iter.getIndex(); break; } else if (Character.isWhitespace(n) || nt == Character.END_PUNCTUATION) { int save = iter.getIndex(); // Skip (java) space, line and paragraph separators. while (n != CharacterIterator.DONE && Character.isWhitespace(n)) n = iter.previous(); // Skip close punctuation. while (n != CharacterIterator.DONE && Character.getType(n) == Character.END_PUNCTUATION) n = iter.previous(); int here = iter.getIndex(); iter.setIndex(save); if (n == CharacterIterator.DONE || n == '!' || n == '?') { // Communicate location of actual end. period = here; break; } } else if (n == '!' || n == '?') { // Communicate location of actual end. period = iter.getIndex(); break; } } return iter.getIndex(); }
5,077
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
5,078
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
5,079
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
5,080
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
public final int getLineNr() { if (isInterpreted()) { final VmByteCode bc = sfMethod.getBytecode(); if (bc != null) { return bc.getLineNr(sfPc - 1); } else { return -1; } } else { final VmCompiledCode cc = sfMethod.getCompiledCode(getMagic()); if ((cc != null) && (sfInstructionPointer != null)) { return cc.getLineNr(sfInstructionPointer); } else { return -1; } } }
5,081
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
5,082
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
5,083
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; } else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; } else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
public String toString() { final VmMethod method = sfMethod; final VmType vmClass = (method == null) ? null : method.getDeclaringClass(); final String cname = (vmClass == null) ? "<unknown class>" : vmClass.getName(); final String mname = (method == null) ? "<unknown method>" : method.getName(); final int lineNr = getLineNr(); final String linePrefix; final String line; if (isInterpreted()) { linePrefix = ""; }*/ line = lineNr; else { linePrefix = "*"; } if (lineNr < 0) { line = "?"; }*/ line = lineNr; else { line = String.valueOf(lineNr); } return cname + "!" + mname + " (" + linePrefix + line + ")"; }
5,084
public int getLineNr(Address address) { if (this.bytecode != null) { final int offset = (int) Address.distance(nativeCode, address); final int pc = addressTable.findPC(offset); return bytecode.getLineNr(pc); //return offset; } return -1; }
public int getLineNr(Address address) { if (this.bytecode != null) { final int offset = (int) Address.distance(nativeCode, address); final int pc = addressTable.findPC(offset); return bytecode.getLineNr(pc); //return offset; } return -1; }
5,085
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { if (hasMoreData) { writeOut(outputstream, getStringData(locator)); } else return; } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
5,086
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
5,087
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) { hasMoreData = false; //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
5,088
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
5,089
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
private void recursiveWriteFormattedData(OutputStream outputstream, Locator locator, List commands, AxisInterface fastestAxis, String[] noDataValues) { int stop = commands.size(); for (int i = 0; i<stop; i++) { FormattedIOCmd command = (FormattedIOCmd) commands.get(i); if (command instanceof RepeatFormattedIOCmd) { int end = ((RepeatFormattedIOCmd) command).getCount().intValue(); List repeatCommandList = ((RepeatFormattedIOCmd)command).getCommands(); for (int j = 0; j < end; j ++) { recursiveWriteFormattedData(outputstream, locator, repeatCommandList, fastestAxis, noDataValues); } } else { if (command instanceof SkipCharFormattedIOCmd) { try { writeOut(outputstream, getStringData(locator)); } catch (NoDataException e) { String noData = noDataValues[locator.getAxisLocation(fastestAxis)]; if (noData != null) writeOut(outputstream, noData); } String output=((SkipCharFormattedIOCmd) command).getOutput(); if (output == null) { writeOut(outputstream, SkipCharFormattedIOCmd.DefaultOutput) ; } else { writeOut(outputstream, output); } if (!locator.next()) //no more data, we are done return; } } //done dealing with SkipCharFormattedIOCmd } //end of outer for loop }
5,090
protected void writeFormattedData(OutputStream outputstream , Locator locator, FormattedXMLDataIOStyle readObj, AxisInterface fastestAxis, String[] noDataValues) { writeOut(outputstream, "<![CDATA["); List commands = readObj.getCommands(); while (locator.next()) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues); writeOut(outputstream, "]]>"); }
protected void writeFormattedData(OutputStream outputstream , Locator locator, FormattedXMLDataIOStyle readObj, AxisInterface fastestAxis, String[] noDataValues) { writeOut(outputstream, "<![CDATA["); List commands = readObj.getCommands(); while (locator.next()) recursiveWriteFormattedData(outputstream, locator, commands, fastestAxis, noDataValues); writeOut(outputstream, "]]>"); }
5,091
public ThreadListState(DebugState parent, int threadState) { super(STATE_NAMES[threadState], parent); threads = getAllThreads(threadState); threadIterator = threads.values().iterator(); index = 1; }
public ThreadListState(DebugState parent, int threadState) { super(STATE_NAMES[threadState], parent); threads = getAllThreads(threadState); threadIterator = threads.values().iterator(); index = 1; }
5,093
public FileSystem create(Device device, boolean readOnly) throws FileSystemException { Ext2FileSystem fs = new Ext2FileSystem(device, readOnly); fs.read(); return fs; }
public FileSystem create(Device device, boolean readOnly) throws FileSystemException { Ext2FileSystem fs = new Ext2FileSystem(device, readOnly); fs.read(); return fs; }
5,095
public FileSystem format(Device device, Object specificOptions) throws FileSystemException { //throw new FileSystemException("Not ye implemented"); //currently the only option is the block size int blockSize = 1024*((Integer)specificOptions).intValue(); Ext2FileSystem fs = new Ext2FileSystem(device, false); fs.create(blockSize); return fs; }
public synchronized FileSystem format(Device device, Object specificOptions) throws FileSystemException { //throw new FileSystemException("Not ye implemented"); //currently the only option is the block size int blockSize = 1024*((Integer)specificOptions).intValue(); Ext2FileSystem fs = new Ext2FileSystem(device, false); fs.create(blockSize); return fs; }
5,096
public void read(cdrInput in) { try { request_id = in.read_ulong(); response_flags = (byte) in.read(); // Skip 3 reserved octets: in.skip(3); // Read target address. AddressingDisposition = in.read_ushort(); switch (AddressingDisposition) { case KeyAddr : object_key = in.read_sequence(); break; // TODO FIXME add other addressing methods. case ProfileAddr : throw new NO_IMPLEMENT("Object addressing by IOP tagged profile"); case ReferenceAddr : throw new NO_IMPLEMENT("Object addressing by by IOR addressing info"); default : throw new MARSHAL("Unknow addressing method in request, " + AddressingDisposition ); } operation = in.read_string(); service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in); // No requesting principal in this new format. in.setCodeSet(cxCodeSet.find(service_context)); } catch (IOException ex) { MARSHAL t = new MARSHAL(); t.initCause(ex); throw t; } }
public void read(cdrInput in) { try { request_id = in.read_ulong(); response_flags = (byte) in.read(); // Skip 3 reserved octets: in.skip(3); // Read target address. AddressingDisposition = in.read_ushort(); switch (AddressingDisposition) { case KeyAddr : object_key = in.read_sequence(); break; // TODO FIXME add other addressing methods. case ProfileAddr : throw new NO_IMPLEMENT("Object addressing by IOP tagged profile"); case ReferenceAddr : throw new NO_IMPLEMENT("Object addressing by by IOR addressing info"); default : MARSHAL m = new MARSHAL("Unknow addressing method in request, " + AddressingDisposition ); } operation = in.read_string(); service_context = gnu.CORBA.GIOP.ServiceContext.readSequence(in); // No requesting principal in this new format. in.setCodeSet(cxCodeSet.find(service_context)); } catch (IOException ex) { MARSHAL t = new MARSHAL(); t.initCause(ex); throw t; } }
5,097
public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorActive(false);// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming();// screen52.setKeyboardLocked(false); pendingUnlock = true; cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); if (!firstScreen) { firstScreen = true; controller.fireSessionChanged(TN5250jConstants.STATE_CONNECTED); signOnSave = screen52.getScreenAsChars(); System.out.println("Signon saved"); } break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorActive(true); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorActive(true); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try {// SwingUtilities.invokeAndWait(// new Runnable () {// public void run() {// screen52.updateDirty();// }// }// ); screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); exd.printStackTrace(); } if (pendingUnlock && !screen52.isStatusErrorCode()) { screen52.setKeyboardLocked(false); } if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorActive(true); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } }
public void run () { while (keepTrucking) { try { bk = (Stream5250)dsq.get(); } catch (InterruptedException ie) { System.out.println(" vt thread interrupted and stopping "); keepTrucking = false; continue; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); invited = false; screen52.setCursorActive(false);// System.out.println("operation code: " + bk.getOpCode()); if (bk == null) continue; switch (bk.getOpCode()) { case 00:// System.out.println("No operation"); break; case 1:// System.out.println("Invite Operation"); parseIncoming();// screen52.setKeyboardLocked(false); pendingUnlock = true; cursorOn = true; setInvited(); break; case 2:// System.out.println("Output Only"); parseIncoming();// System.out.println(screen52.dirty); screen52.updateDirty(); // invited = true; break; case 3:// System.out.println("Put/Get Operation"); parseIncoming();// inviteIt =true; setInvited(); if (!firstScreen) { firstScreen = true; controller.fireSessionChanged(TN5250jConstants.STATE_CONNECTED); signOnSave = screen52.getScreenAsChars(); System.out.println("Signon saved"); } break; case 4:// System.out.println("Save Screen Operation"); parseIncoming(); break; case 5:// System.out.println("Restore Screen Operation"); parseIncoming(); break; case 6:// System.out.println("Read Immediate"); sendAidKey(0); break; case 7:// System.out.println("Reserved"); break; case 8:// System.out.println("Read Screen Operation"); try { readScreen(); } catch (IOException ex) { } break; case 9:// System.out.println("Reserved"); break; case 10:// System.out.println("Cancel Invite Operation"); cancelInvite(); break; case 11:// System.out.println("Turn on message light"); screen52.setMessageLightOn(); screen52.setCursorActive(true); break; case 12:// System.out.println("Turn off Message light"); screen52.setMessageLightOff(); screen52.setCursorActive(true); break; default: break; } if (screen52.isUsingGuiInterface()) screen52.drawFields();// if (screen52.screen[0][1].getChar() == '#' &&// screen52.screen[0][2].getChar() == '!')// execCmd();// else { if (screen52.isHotSpots()) { screen52.checkHotSpots(); } try {// SwingUtilities.invokeAndWait(// new Runnable () {// public void run() {// screen52.updateDirty();// }// }// ); screen52.updateDirty(); } catch (Exception exd ) { System.out.println(" tnvt.run: " + exd.getMessage()); exd.printStackTrace(); } if (pendingUnlock && !screen52.isStatusErrorCode()) { screen52.setKeyboardLocked(false); } if (cursorOn && !screen52.isKeyboardLocked()) { screen52.setCursorActive(true); cursorOn = false; } // lets play nicely with the others on the playground// me.yield(); pthread.yield(); } }
5,099
tnvt (Screen5250 screen52) { this(screen52,false,false); }
tnvt (Properties props, Screen5250 screen52, boolean type, boolean support132) { this(screen52,false,false); }
5,100
tnvt (Screen5250 screen52) { this(screen52,false,false); }
tnvt (Screen5250 screen52) { enhanced = type; this.support132 = support132; }
5,101
public void addAddedElement (Element e) { if (!added.contains(e)) added.add(e); }
public void addAddedElement(Element e) { if (!added.contains(e)) added.add(e); }
5,103
public void addAddedElement (Element e) { if (!added.contains(e)) added.add(e); }
public void addAddedElement (Element e) { if (!contains(added, e)) added.add(e); }
5,104
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
public void addAddedElements(Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
5,105
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!added.contains(e[i])) added.add(e[i]); } }
public void addAddedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!contains(added, e[i])) added.add(e[i]); } }
5,106
public void addRemovedElement (Element e) { if (!removed.contains(e)) removed.add(e); }
public void addRemovedElement(Element e) { if (!removed.contains(e)) removed.add(e); }
5,107
public void addRemovedElement (Element e) { if (!removed.contains(e)) removed.add(e); }
public void addRemovedElement (Element e) { if (!contains(removed, e)) removed.add(e); }
5,108
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
public void addRemovedElements(Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
5,109
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!removed.contains(e[i])) removed.add(e[i]); } }
public void addRemovedElements (Element[] e) { if (e == null || e.length == 0) return; for (int i = 0; i < e.length; i++) { if (!contains(removed, e[i])) removed.add(e[i]); } }
5,110
public void change(int offset, int length, DefaultDocumentEvent ev) { this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
public void change(int offset, int length, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; documentEvent = ev; changeUpdate(); }
5,111
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0, el.getElementIndex(offset)); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,113
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,114
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,115
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,116
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,117
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0, el.getElementIndex(endOffset)); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,118
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[0] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[0] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,119
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,120
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[] { res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[] { res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,121
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,122
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } }
protected void changeUpdate() { // Split up the element at the start offset if necessary. Element el = getCharacterElement(offset); Element[] res = split(el, offset, 0); BranchElement par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; index++; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } int endOffset = offset + length; el = getCharacterElement(endOffset); res = split(el, endOffset, 0); par = (BranchElement) el.getParentElement(); if (res[1] != null) { int index = par.getElementIndex(offset); Element[] removed; Element[] added; if (res[1] == null) { removed = new Element[0]; added = new Element[]{ res[1] }; } else { removed = new Element[]{ el }; added = new Element[]{ res[0], res[1] }; } edit.addRemovedElements(removed); edit.addAddedElements(added); } }
5,123
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
5,124
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
5,125
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } edit.addRemovedElement(child); }
private void createFracture(ElementSpec[] data) { // FIXME: This method is not complete. We must handle the elementStack // properly and make sure the appropriate Elements are pushed onto the // top of the stack so future inserts go to the appropriate paragraph. BranchElement paragraph = (BranchElement)elementStack.peek(); int index = paragraph.getElementIndex(offset); Element child = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (offset != 0) { Element newEl1 = createLeafElement(paragraph, child.getAttributes(), child.getStartOffset(), offset); edit.addAddedElement(newEl1); } }
5,126
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
5,127
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
5,128
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); addEdit(e, curr.index, removed, added); } }
public void insert(int offset, int length, ElementSpec[] data, DefaultDocumentEvent ev) { if (length == 0) return; this.offset = offset; this.length = length; this.endOffset = offset + length; documentEvent = ev; // Push the root and the paragraph at offset onto the element stack. edits.clear(); elementStack.clear(); Element current = root; int index; while (!current.isLeaf()) { index = current.getElementIndex(offset); elementStack.push(current); current = current.getElement(index); } insertUpdate(data); // This for loop applies all the changes that were made and updates the // DocumentEvent. int size = edits.size(); for (int i = 0; i < size; i++) { Edit curr = (Edit) edits.get(i); BranchElement e = (BranchElement) curr.e; Element[] removed = curr.getRemovedElements(); Element[] added = curr.getAddedElements(); e.replace(curr.index, removed.length, added); ElementEdit ee = new ElementEdit(e, curr.index, removed, added); ev.addEdit(ee); } }
5,129
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinNextDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,130
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,131
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); Edit edit = getEditForParagraphAndIndex(paragraph, index); if (paragraph.getStartOffset() > pos) { Element first = paragraph.getElement(0); Element newEl = createLeafElement(paragraph, first.getAttributes(), pos, first.getEndOffset()); edit.addAddedElement(newEl); edit.addRemovedElement(first); } else if (paragraph.getElementCount() > (index + 1) && (pos == target.getStartOffset() && !target.equals(lastFractured))) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,132
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,133
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,134
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,135
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
5,136
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } offset += len; }
private void insertContentTag(ElementSpec tag) { int len = tag.getLength(); int dir = tag.getDirection(); AttributeSet tagAtts = tag.getAttributes(); if (dir == ElementSpec.JoinPreviousDirection) { // The mauve tests to this class show that a JoinPrevious insertion // does not add any edits to the document event. To me this means // that nothing is done here. The previous element naturally should // expand so that it covers the new characters. } else if (dir == ElementSpec.JoinNextDirection) { // FIXME: // Have to handle JoinNext differently depending on whether // or not it comes after a fracture. If comes after a fracture, // the insertFracture method takes care of everything and nothing // needs to be done here. Otherwise, we need to adjust the // Element structure. For now, I check if the elementStack's // top Element is the immediate parent of the LeafElement at // offset - if so, we did not come immediately after a // fracture. This seems awkward and should probably be improved. // We may be doing too much in insertFracture because we are // adjusting the offsets, the correct thing to do may be to // create a new branch element and push it on to element stack // and then this method here can be more general. BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element target = paragraph.getElement(index); if (target.isLeaf() && paragraph.getElementCount() > (index + 1)) { Element next = paragraph.getElement(index + 1); Element newEl1 = createLeafElement(paragraph, target.getAttributes(), target.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElement(target); edit.addRemovedElement(next); edit.addAddedElement (newEl1); edit.addAddedElement (newEl2); } } else if (dir == ElementSpec.OriginateDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); Element[] added; Element[] removed = new Element[] {current}; Element[] splitRes = split(current, offset, length); if (splitRes[0] == null) { added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; removed = new Element[0]; index++; } else if (current.getStartOffset() == offset) { // This is if the new insertion happens immediately before // the <code>current</code> Element. In this case there are 2 // resulting Elements. added = new Element[2]; added[0] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[1] = splitRes[1]; } else if (current.getEndOffset() == endOffset) { // This is if the new insertion happens right at the end of // the <code>current</code> Element. In this case there are // 2 resulting Elements. added = new Element[2]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); } else { // This is if the new insertion is in the middle of the // <code>current</code> Element. In this case // there will be 3 resulting Elements. added = new Element[3]; added[0] = splitRes[0]; added[1] = createLeafElement(paragraph, tagAtts, offset, endOffset); added[2] = splitRes[1]; } Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { int end = pos + len; Element leaf = createLeafElement(paragraph, tag.getAttributes(), pos, end); if (paragraph.getElementCount() > 0) { int index = paragraph.getElementIndex(pos); Element target = paragraph.getElement(index); boolean onlyContent = target.isLeaf(); BranchElement toRec = paragraph; if (!onlyContent) toRec = (BranchElement) target; if (pos > target.getStartOffset()) index++; Edit edit = getEditForParagraphAndIndex(paragraph, index); edit.addAddedElement(leaf); if (end != toRec.getEndOffset()) { recreateLeaves(end, toRec, onlyContent); if (onlyContent) edit.addRemovedElement(target); } } else paragraph.replace(0, 0, new Element[] { leaf }); } pos += len; }
5,137
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data){// FIXME: This method is not complete.It needs to properly recreate the// leaves when the spec's direction is JoinPreviousDirection.ElementSpec first = data[0];BranchElement paragraph = (BranchElement) elementStack.peek();int index = paragraph.getElementIndex(offset);Element current = paragraph.getElement(index);int newEndOffset = offset + first.length;Edit edit = getEditForParagraphAndIndex(paragraph, index);switch (first.getDirection()){case ElementSpec.JoinPreviousDirection:if (current.getEndOffset() != newEndOffset){Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset);edit.addRemovedElement(current);edit.addAddedElement(newEl1);if (current.getEndOffset() != newEndOffset){// This means all the leaves that were there previously need// to be recreated after all the new Elements are inserted.}}break;case ElementSpec.JoinNextDirection:if (offset != 0){Element next = paragraph.getElement(index + 1);Element[] removed = new Element[] { current, next };Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset);Element[] added = new Element[2];added[0] = newEl1;if (data.length == 1)added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset());elseadded[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset);edit.addRemovedElements(removed);edit.addAddedElements(added);}break;case ElementSpec.OriginateDirection:if (current.getStartOffset() != offset){Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset);edit.addAddedElement(newEl1);}Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset);edit.addRemovedElement(current);edit.addAddedElement(newEl2);if (current.getEndOffset() != endOffset && (data.length == 1)){// This means all the leaves that were there previously need// to be recreated after all the new Elements are inserted.Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset());edit.addAddedElement(newCurrent);}break;default:break;}offset = newEndOffset; }
5,138
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset && !onlyContent) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset && !onlyContent) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,139
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addAddedElement(newEl1); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,140
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,141
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,142
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,143
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,144
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,145
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
5,146
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } offset = newEndOffset; }
private void insertFirstContentTag(ElementSpec[] data) { // FIXME: This method is not complete. It needs to properly recreate the // leaves when the spec's direction is JoinPreviousDirection. ElementSpec first = data[0]; BranchElement paragraph = (BranchElement) elementStack.peek(); int index = paragraph.getElementIndex(offset); Element current = paragraph.getElement(index); int newEndOffset = offset + first.length; Edit edit = getEditForParagraphAndIndex(paragraph, index); switch (first.getDirection()) { case ElementSpec.JoinPreviousDirection: if (current.getEndOffset() != newEndOffset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl1); if (current.getEndOffset() != newEndOffset) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. } } break; case ElementSpec.JoinNextDirection: if (offset != 0) { Element next = paragraph.getElement(index + 1); Element[] removed = new Element[] { current, next }; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element[] added = new Element[2]; added[0] = newEl1; if (data.length == 1) added[1] = createLeafElement(paragraph, next.getAttributes(), offset, next.getEndOffset()); else added[1] = createLeafElement(paragraph, next.getAttributes(), offset, newEndOffset); edit.addRemovedElements(removed); edit.addAddedElements(added); } break; case ElementSpec.OriginateDirection: if (current.getStartOffset() != offset) { Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); edit.addAddedElement(newEl1); } Element newEl2 = createLeafElement(paragraph, first.getAttributes(), offset, newEndOffset); edit.addRemovedElement(current); edit.addAddedElement(newEl2); if (current.getEndOffset() != endOffset && (data.length == 1)) { // This means all the leaves that were there previously need // to be recreated after all the new Elements are inserted. Element newCurrent = createLeafElement(paragraph, current.getAttributes(), newEndOffset, current.getEndOffset()); edit.addAddedElement(newCurrent); } break; default: break; } }
5,147
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
5,148
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
private void insertFracture(ElementSpec tag) { // FIXME: This method may be incomplete. We must make sure the // appropriate edits were added and the correct paragraph element // is pushed onto the top of the elementStack so future inserts go // to the right paragraph. // This is the parent of the paragraph about to be fractured. We will // create a new child of this parent. BranchElement parent = (BranchElement) elementStack.peek(); int parentIndex = parent.getElementIndex(offset); // This is the old paragraph. We must remove all its children that // occur after offset and move them to a new paragraph. We must // also recreate its child that occurs at offset to have the proper // end offset. The remainder of this child will also go in the new // paragraph. BranchElement previous = (BranchElement) parent.getElement(parentIndex); // This is the new paragraph. BranchElement newBranch = (BranchElement) createBranchElement(parent, previous.getAttributes()); // The steps we must take to properly fracture are: // 1. Recreate the LeafElement at offset to have the correct end offset. // 2. Create a new LeafElement with the remainder of the LeafElement in // #1 ==> this is whatever was in that LeafElement to the right of the // inserted newline. // 3. Find the paragraph at offset and remove all its children that // occur _after_ offset. These will be moved to the newly created // paragraph. // 4. Move the LeafElement created in #2 and all the LeafElements removed // in #3 to the newly created paragraph. // 5. Add the new paragraph to the parent. int previousIndex = previous.getElementIndex(offset); int numReplaced = previous.getElementCount() - previousIndex; Element previousLeaf = previous.getElement(previousIndex); AttributeSet prevLeafAtts = previous.getAttributes(); // This recreates the child at offset to have the proper end offset. // (Step 1). Element newPreviousLeaf = createLeafElement(previous, prevLeafAtts, previousLeaf.getStartOffset(), offset); // This creates the new child, which is the remainder of the old child. // (Step 2). Element firstLeafInNewBranch = createLeafElement(newBranch, prevLeafAtts, offset, previousLeaf.getEndOffset()); // Now we move the new LeafElement and all the old children that occurred // after the offset to the new paragraph. (Step 4). Element[] newLeaves = new Element[numReplaced]; newLeaves[0] = firstLeafInNewBranch; for (int i = 1; i < numReplaced; i++) newLeaves[i] = previous.getElement(previousIndex + i); newBranch.replace(0, 0, newLeaves); // Now we remove the children after the offset from the previous // paragraph. (Step 3). int removeSize = previous.getElementCount() - previousIndex; Element[] remove = new Element[removeSize]; for (int j = 0; j < removeSize; j++) remove[j] = previous.getElement(previousIndex + j); Edit edit = getEditForParagraphAndIndex(previous, previousIndex); edit.addRemovedElements(remove); // Finally we add the new paragraph to the parent. (Step 5). int index = parentIndex + 1; Edit edit2 = getEditForParagraphAndIndex(parent, index); edit2.addAddedElement(newBranch); elementStack.push(newBranch); }
5,149
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,150
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[] { res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,151
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[] { ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,152
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[] { current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,153
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[] { res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,154
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[] { res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,155
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,156
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
private Element insertParagraph(BranchElement par, int offset) { Element current = par.getElement(par.getElementIndex(offset)); Element[] res = split(current, offset, 0); int index = par.getElementIndex(offset); Element ret; if (res[1] != null) { Element[] removed; Element[] added; if (res[0] == null) { removed = new Element[0]; if (res[1] instanceof BranchElement) { added = new Element[]{ res[1] }; ret = res[1]; } else { ret = createBranchElement(par, null); added = new Element[]{ ret, res[1] }; } index++; } else { removed = new Element[]{ current }; if (res[1] instanceof BranchElement) { ret = res[1]; added = new Element[]{ res[0], res[1] }; } else { ret = createBranchElement(par, null); added = new Element[]{ res[0], ret, res[1] }; } } Edit edit = getEditForParagraphAndIndex(par, index); edit.addRemovedElements(removed); edit.addAddedElements(added); } else { ret = createBranchElement(par, null); Edit edit = getEditForParagraphAndIndex(par, index); edit.addAddedElement(ret); } return ret; }
5,157
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
protected void insertUpdate(ElementSpec[] data) { int i = 0; int type = data[0].getType(); if (type == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
5,158
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
5,159
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
protected void insertUpdate(ElementSpec[] data) { int i = 0; if (data[0].getType() == ElementSpec.ContentType) { // If the first tag is content we must treat it separately to allow // for joining properly to previous Elements and to ensure that // no extra LeafElements are erroneously inserted. i = 1; insertFirstContentTag(data); } else createFracture(data); // Handle each ElementSpec individually. for (; i < data.length; i++) { BranchElement paragraph = (BranchElement) elementStack.peek(); switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: // Fracture the tree and ensure the appropriate element // is on top of the stack. insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: // Push the next paragraph element onto the stack so // future insertions are added to it. int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: // Create a new paragraph and push it onto the stack. Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: elementStack.pop(); break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } }
5,160
protected void removeUpdate() { int startParagraph = root.getElementIndex(offset); int endParagraph = root.getElementIndex(offset + length); Element[] empty = new Element[0]; int removeStart = -1; int removeEnd = -1; for (int i = startParagraph; i < endParagraph; i++) { BranchElement paragraph = (BranchElement) root.getElement(i); int contentStart = paragraph.getElementIndex(offset); int contentEnd = paragraph.getElementIndex(offset + length); if (contentStart == paragraph.getStartOffset() && contentEnd == paragraph.getEndOffset()) { // In this case we only need to remove the whole paragraph. We // do this in one go after this loop and only record the indices // here. if (removeStart == -1) { removeStart = i; removeEnd = i; } else removeEnd = i; } else { // In this case we remove a couple of child elements from this // paragraph. int removeLen = contentEnd - contentStart; Element[] removed = new Element[removeLen]; for (int j = contentStart; j < contentEnd; j++) removed[j] = paragraph.getElement(j); Edit edit = getEditForParagraphAndIndex(paragraph, contentStart); edit.addRemovedElements(removed); } } // Now we remove paragraphs from the root that have been tagged for // removal. if (removeStart != -1) { int removeLen = removeEnd - removeStart; Element[] removed = new Element[removeLen]; for (int i = removeStart; i < removeEnd; i++) removed[i] = root.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement)root, removeStart); edit.addRemovedElements(removed); } }
protected void removeUpdate() { int startParagraph = root.getElementIndex(offset); int endParagraph = root.getElementIndex(offset + length); Element[] empty = new Element[0]; int removeStart = -1; int removeEnd = -1; for (int i = startParagraph; i < endParagraph; i++) { BranchElement paragraph = (BranchElement) root.getElement(i); int contentStart = paragraph.getElementIndex(offset); int contentEnd = paragraph.getElementIndex(offset + length); if (contentStart == paragraph.getStartOffset() && contentEnd == paragraph.getEndOffset()) { // In this case we only need to remove the whole paragraph. We // do this in one go after this loop and only record the indices // here. if (removeStart == -1) { removeStart = i; removeEnd = i; } else removeEnd = i; } else { // In this case we remove a couple of child elements from this // paragraph. int removeLen = contentEnd - contentStart; Element[] removed = new Element[removeLen]; for (int j = contentStart; j < contentEnd; j++) removed[j] = paragraph.getElement(j); Edit edit = getEditForParagraphAndIndex(paragraph, contentStart); edit.addRemovedElements(removed); } } // Now we remove paragraphs from the root that have been tagged for // removal. if (removeStart != -1) { int removeLen = removeEnd - removeStart; Element[] removed = new Element[removeLen]; for (int i = removeStart; i < removeEnd; i++) removed[i] = root.getElement(i); Edit edit = getEditForParagraphAndIndex((BranchElement) root, removeStart); edit.addRemovedElements(removed); } }
5,163
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
5,164
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
5,165
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
private Element[] split(Element el, int offset, int space) { // If we are at an element boundary, then return an empty array. if ((offset == el.getStartOffset() || offset == el.getEndOffset()) && space == 0 && el.isLeaf()) return new Element[2]; // If the element is an instance of BranchElement, then we recursivly // call this method to perform the split. Element[] res = new Element[2]; if (el instanceof BranchElement) { int index = el.getElementIndex(offset); Element child = el.getElement(index); Element[] result = split(child, offset, space, editIndex); Element[] removed; Element[] added; Element[] newAdded; int count = el.getElementCount(); if (!(result[1] == null)) { // This is the case when we can keep the first element. if (result[0] == null) { removed = new Element[count - index - 1]; newAdded = new Element[count - index - 1]; added = new Element[]{}; } // This is the case when we may not keep the first element. else { removed = new Element[count - index]; newAdded = new Element[count - index]; added = new Element[]{result[0]}; } newAdded[0] = result[1]; for (int i = index; i < count; i++) { Element el2 = el.getElement(i); int ind = i - count + removed.length; removed[ind] = el2; if (ind != 0) newAdded[ind] = el2; } Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(newAdded); res = new Element[]{ null, newPar }; } else { removed = new Element[count - index]; for (int i = index; i < count; ++i) removed[i - index] = el.getElement(i); added = new Element[0]; Edit edit = getEditForParagraphAndIndex((BranchElement)el, index); edit.addRemovedElements(removed); edit.addAddedElements(added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); Edit edit2 = getEditForParagraphAndIndex(newPar, 0); edit2.addAddedElements(removed); res = new Element[]{ null, newPar }; } } else if (el instanceof LeafElement) { BranchElement par = (BranchElement) el.getParentElement(); Element el1 = createLeafElement(par, el.getAttributes(), el.getStartOffset(), offset); Element el2 = createLeafElement(par, el.getAttributes(), offset + space, el.getEndOffset()); res = new Element[]{ el1, el2 }; } return res; }
5,166