bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public DataBufferByte(int size, int numBanks) { super(TYPE_BYTE, size, numBanks); bankData = new byte[numBanks][size]; data = bankData[0]; }
|
public DataBufferByte(int size, int numBanks) { super(TYPE_BYTE, size, numBanks); bankData = new byte[numBanks][size]; data = bankData[0]; }
| 10,250
|
protected DataBuffer(int dataType, int size, int numBanks, int offset) { this(dataType, size, numBanks); java.util.Arrays.fill(offsets, offset); this.offset = offset; }
|
protected DataBuffer(int dataType, int size, int numBanks, int offset) { this(dataType, size, numBanks); java.util.Arrays.fill(offsets, offset); this.offset = offset; }
| 10,251
|
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { throw new Error("not implemented"); }
|
public PaintContext createContext(ColorModel cm, Rectangle deviceBounds, Rectangle2D userBounds, AffineTransform xform, RenderingHints hints) { Point2D xp1 = xform.transform(getPoint1(), null); Point2D xp2 = xform.transform(getPoint2(), null); return new GradientPaintContext((float) xp1.getX(), (float) xp1.getY(), c1, (float) xp2.getX(), (float) xp2.getY(), c2, cyclic); }
| 10,252
|
public int getTransparency() { throw new Error("not implemented"); }
|
public int getTransparency() { if (c1.getAlpha() == 255 && c2.getAlpha() == 255) return Transparency.OPAQUE; else return Transparency.TRANSLUCENT; }
| 10,253
|
public abstract int getVisibleChildCount(TreePath value0);
|
public abstract int getVisibleChildCount(TreePath path);
| 10,254
|
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] }; } par.replace(index, removed.length, added); addEdit(par, index, removed, 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] }; } par.replace(index, removed.length, added); addEdit(par, index, removed, 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] }; } par.replace(index, removed.length, added); edits.add(new Edit(par, index, removed, 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] }; } par.replace(index, removed.length, added); edits.add(new Edit(par, index, removed, added)); } }
| 10,255
|
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. elementStack.clear(); elementStack.push(root); elementStack.push(root.getElement(root.getElementIndex(offset))); numEndTags = 0; numStartTags = 0; insertUpdate(data); }
|
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. elementStack.clear(); elementStack.push(root); elementStack.push(root.getElement(root.getElementIndex(offset))); numEndTags = 0; numStartTags = 0; insertUpdate(data); }
| 10,256
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,258
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,259
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,260
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,261
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,262
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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.OriginateDirection) if (dir == ElementSpec.JoinNextDirection) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } } 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 (dir == ElementSpec.OriginateDirection) 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 (dir == ElementSpec.OriginateDirection) 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 if (dir == ElementSpec.OriginateDirection) { // 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
| 10,263
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); addEdit(paragraph, index, removed, added); } offset += len; }
|
private void insertContentTag(ElementSpec tag) { prepareContentInsertion(); 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) { BranchElement paragraph = (BranchElement) elementStack.peek(); int currentIndex = paragraph.getElementIndex(offset); Element current = paragraph.getElement(currentIndex); Element next = paragraph.getElement(currentIndex + 1); if (next == null) return; Element newEl1 = createLeafElement(paragraph, current.getAttributes(), current.getStartOffset(), offset); Element newEl2 = createLeafElement(paragraph, current.getAttributes(), offset, next.getEndOffset()); Element[] add = new Element[] { newEl1, newEl2 }; Element[] remove = new Element[] { current, next }; paragraph.replace(currentIndex, 2, add); // Add this action to the document event. addEdit(paragraph, currentIndex, remove, add); } else { 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]; } paragraph.replace(index, removed.length, added); edits.add(new Edit(paragraph, index, removed, added)); } offset += len; }
| 10,264
|
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] }; } } par.replace(index, removed.length, added); addEdit(par, index, removed, added); } else { ret = createBranchElement(par, null); Element[] added = new Element[]{ ret }; par.replace(index, 0, added); addEdit(par, index, new Element[0], added); } 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] }; } } par.replace(index, removed.length, added); edits.add(new Edit(par, index, removed, added)); } else { ret = createBranchElement(par, null); Element[] added = new Element[]{ ret }; par.replace(index, 0, added); addEdit(par, index, new Element[0], added); } return ret; }
| 10,265
|
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] }; } } par.replace(index, removed.length, added); addEdit(par, index, removed, added); } else { ret = createBranchElement(par, null); Element[] added = new Element[]{ ret }; par.replace(index, 0, added); addEdit(par, index, new Element[0], added); } 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] }; } } par.replace(index, removed.length, added); addEdit(par, index, removed, added); } else { ret = createBranchElement(par, null); Element[] added = new Element[]{ ret }; par.replace(index, 0, added); edits.add(new Edit(par, index, new Element[0], added)); } return ret; }
| 10,266
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } endEdit(); }
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: switch (data[i].getDirection()) { case ElementSpec.JoinFractureDirection: insertFracture(data[i]); break; case ElementSpec.JoinNextDirection: int index = paragraph.getElementIndex(offset); elementStack.push(paragraph.getElement(index)); break; case ElementSpec.OriginateDirection: Element current = (Element) elementStack.peek(); Element newParagraph = insertParagraph((BranchElement) current, offset); elementStack.push(newParagraph); break; default: break; } break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } endEdit(); }
| 10,267
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } endEdit(); }
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: elementStack.pop(); break; default: insertContentTag(data[i]); break; } } endEdit(); }
| 10,268
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } endEdit(); }
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; case ElementSpec.ContentType: insertContentTag(data[i]); break; } } endEdit(); }
| 10,269
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } endEdit(); }
|
protected void insertUpdate(ElementSpec[] data) { for (int i = 0; i < data.length; i++) { switch (data[i].getType()) { case ElementSpec.StartTagType: numStartTags++; break; case ElementSpec.EndTagType: numEndTags++; break; default: insertContentTag(data[i]); break; } } }
| 10,270
|
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; } ((BranchElement) el).replace(index, removed.length, added); addEdit(el, index, removed, added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, 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]; ((BranchElement) el).replace(index, removed.length, added); addEdit(el, index, removed, added); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, 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; } ((BranchElement) el).replace(index, removed.length, added); edits.add(new Edit(el, index, removed, added)); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, 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]; ((BranchElement) el).replace(index, removed.length, added); edits.add(new Edit(el, index, removed, added)); BranchElement newPar = (BranchElement) createBranchElement(el.getParentElement(), el.getAttributes()); newPar.replace(0, 0, 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; }
| 10,271
|
public String toString() { StringBuilder b = new StringBuilder(); b.append('<'); switch (type) { case StartTagType: b.append("StartTag"); break; case EndTagType: b.append("EndTag"); break; case ContentType: b.append("Content"); break; default: b.append("??"); break; } b.append(':'); switch (direction) { case JoinPreviousDirection: b.append("JoinPrevious"); break; case JoinNextDirection: b.append("JoinNext"); break; case OriginateDirection: b.append("Originate"); break; case JoinFractureDirection: b.append("Fracture"); break; default: b.append("??"); break; } b.append(':'); b.append(length); return b.toString(); }
|
public String toString() { StringBuilder b = new StringBuilder(); switch (type) { case StartTagType: b.append("StartTag"); break; case EndTagType: b.append("EndTag"); break; case ContentType: b.append("Content"); break; default: b.append("??"); break; } b.append(':'); switch (direction) { case JoinPreviousDirection: b.append("JoinPrevious"); break; case JoinNextDirection: b.append("JoinNext"); break; case OriginateDirection: b.append("Originate"); break; case JoinFractureDirection: b.append("Fracture"); break; default: b.append("??"); break; } b.append(':'); b.append(length); return b.toString(); }
| 10,272
|
protected AbstractDocument.AbstractElement createDefaultRoot() { Element[] tmp; // FIXME: Create a SecionElement here instead of a BranchElement. // Use createBranchElement() and createLeafElement instead. SectionElement section = new SectionElement(); BranchElement paragraph = new BranchElement(section, null); paragraph.setResolveParent(getStyle(StyleContext.DEFAULT_STYLE)); tmp = new Element[1]; tmp[0] = paragraph; section.replace(0, 0, tmp); LeafElement leaf = new LeafElement(paragraph, null, 0, 1); tmp = new Element[1]; tmp[0] = leaf; paragraph.replace(0, 0, tmp); return section; }
|
protected AbstractDocument.AbstractElement createDefaultRoot() { Element[] tmp; // FIXME: Create a SecionElement here instead of a BranchElement. // Use createBranchElement() and createLeafElement instead. SectionElement section = new SectionElement(); BranchElement paragraph = new BranchElement(section, null); tmp = new Element[1]; tmp[0] = paragraph; section.replace(0, 0, tmp); LeafElement leaf = new LeafElement(paragraph, null, 0, 1); tmp = new Element[1]; tmp[0] = leaf; paragraph.replace(0, 0, tmp); return section; }
| 10,273
|
protected void insert(int offset, ElementSpec[] data) throws BadLocationException { try { // writeLock() and writeUnlock() should always be in a try/finally // block so that locking balance is guaranteed even if some // exception is thrown. writeLock(); // First we collect the content to be inserted. StringBuffer contentBuffer = new StringBuffer(); for (int i = 0; i < data.length; i++) { // Collect all inserts into one so we can get the correct // ElementEdit ElementSpec spec = data[i]; if (spec.getArray() != null && spec.getLength() > 0) contentBuffer.append(spec.getArray(), spec.getOffset(), spec.getLength()); } int length = contentBuffer.length(); // If there was no content inserted then exit early. if (length == 0) return; UndoableEdit edit = content.insertString(offset, contentBuffer.toString()); // Create the DocumentEvent with the ElementEdit added DefaultDocumentEvent ev = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.INSERT); ev.addEdit(edit); for (int i = 0; i < data.length; i++) { ElementSpec spec = data[i]; AttributeSet atts = spec.getAttributes(); if (atts != null) insertUpdate(ev, atts); } // Finally we must update the document structure and fire the insert // update event. buffer.insert(offset, length, data, ev); fireInsertUpdate(ev); } finally { writeUnlock(); } }
|
protected void insert(int offset, ElementSpec[] data) throws BadLocationException { try { // writeLock() and writeUnlock() should always be in a try/finally // block so that locking balance is guaranteed even if some // exception is thrown. writeLock(); // First we collect the content to be inserted. StringBuffer contentBuffer = new StringBuffer(); for (int i = 0; i < data.length; i++) { // Collect all inserts into one so we can get the correct // ElementEdit ElementSpec spec = data[i]; if (spec.getArray() != null && spec.getLength() > 0) contentBuffer.append(spec.getArray(), spec.getOffset(), spec.getLength()); } int length = contentBuffer.length(); // If there was no content inserted then exit early. if (length == 0) return; UndoableEdit edit = content.insertString(offset, contentBuffer.toString()); // Create the DocumentEvent with the ElementEdit added DefaultDocumentEvent ev = new DefaultDocumentEvent(offset, length, DocumentEvent.EventType.INSERT); ev.addEdit(edit); for (int i = 0; i < data.length; i++) { ElementSpec spec = data[i]; AttributeSet atts = spec.getAttributes(); if (atts != null) insertUpdate(ev, atts); } // Finally we must update the document structure and fire the insert // update event. buffer.insert(offset, length, data, ev); fireInsertUpdate(ev); } finally { writeUnlock(); } }
| 10,274
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
| 10,277
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
| 10,278
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
| 10,279
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (last.getType() == ElementSpec.ContentType) { Element currentRun = prevParagraph.getElement(prevParagraph.getElementIndex(offset)); if (currentRun.getEndOffset() == endOffset) { if (endOffset < getLength() && next.getAttributes().isEqual(attr) && last.getType() == ElementSpec.ContentType) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
| 10,280
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr)) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
|
protected void insertUpdate(DefaultDocumentEvent ev, AttributeSet attr) { super.insertUpdate(ev, attr); // If the attribute set is null, use an empty attribute set. if (attr == null) attr = SimpleAttributeSet.EMPTY; int offset = ev.getOffset(); int length = ev.getLength(); int endOffset = offset + length; AttributeSet paragraphAttributes = getParagraphElement(endOffset).getAttributes(); Segment txt = new Segment(); try { getText(offset, length, txt); } catch (BadLocationException ex) { AssertionError ae = new AssertionError("Unexpected bad location"); ae.initCause(ex); throw ae; } int len = 0; Vector specs = new Vector(); Element prev = getCharacterElement(offset); Element next = getCharacterElement(endOffset); int segmentEnd = txt.offset + txt.count; for (int i = txt.offset; i < segmentEnd; ++i) { len++; if (txt.array[i] == '\n') { ElementSpec spec = new ElementSpec(attr, ElementSpec.ContentType, len); specs.add(spec); // Add ElementSpecs for the newline. ElementSpec endTag = new ElementSpec(null, ElementSpec.EndTagType); specs.add(endTag); ElementSpec startTag = new ElementSpec(paragraphAttributes, ElementSpec.StartTagType); startTag.setDirection(ElementSpec.JoinFractureDirection); specs.add(startTag); len = 0; } } // Create last element if last character hasn't been a newline. if (len > 0) specs.add(new ElementSpec(attr, ElementSpec.ContentType, len)); // If we are at the last index, then check if we could probably be // joined with the next element. ElementSpec last = (ElementSpec) specs.lastElement(); if (next.getAttributes().isEqual(attr)) last.setDirection(ElementSpec.JoinNextDirection); // If we are at the first new element, then check if it could be // joined with the previous element. ElementSpec first = (ElementSpec) specs.firstElement(); if (prev.getAttributes().isEqual(attr) && first.getType() == ElementSpec.ContentType) first.setDirection(ElementSpec.JoinPreviousDirection); ElementSpec[] elSpecs = (ElementSpec[]) specs.toArray(new ElementSpec[specs.size()]); buffer.insert(offset, length, elSpecs, ev); }
| 10,281
|
public GapContent(int size) { buf.append("\n"); }
|
public GapContent() { buf.append("\n"); }
| 10,283
|
public GapContent(int size) { buf.append("\n"); }
|
public GapContent(int size) { this(10); }
| 10,284
|
protected AbstractDocument(Content doc, AttributeContext ctx) { content = doc; context = ctx; }
|
protected AbstractDocument(Content doc) { content = doc; context = ctx; }
| 10,285
|
protected AbstractDocument(Content doc, AttributeContext ctx) { content = doc; context = ctx; }
|
protected AbstractDocument(Content doc, AttributeContext ctx) { content = doc; context = ctx; }
| 10,286
|
public Color getBackground(AttributeSet set);
|
Color getBackground(AttributeSet set);
| 10,287
|
public Font getFont(AttributeSet set);
|
Font getFont(AttributeSet set);
| 10,288
|
public Color getForeground(AttributeSet set);
|
Color getForeground(AttributeSet set);
| 10,289
|
public void getText(int offset, int length, Segment segment) throws BadLocationException { content.getChars(offset, length, segment); }
|
public void getText(int offset, int length, Segment segment) throws BadLocationException { content.getChars(offset, length, segment); }
| 10,290
|
public void setParagraphAttributes(int offset, int length, AttributeSet set, boolean replace);
|
void setParagraphAttributes(int offset, int length, AttributeSet set, boolean replace);
| 10,291
|
protected void addImpl(Component comp, Object constraints, int index) { int left = 0; int right = 1; int div = 2; int place; if (constraints == null) { if (leftComponent == null) constraints = LEFT; else if (rightComponent == null) constraints = RIGHT; } if (constraints instanceof String) { String placement = (String) constraints; if (placement.equals(BOTTOM) || placement.equals(RIGHT)) { if (rightComponent != null) remove(rightComponent); rightComponent = comp; } else if (placement.equals(LEFT) || placement.equals(TOP)) { if (leftComponent != null) remove(leftComponent); leftComponent = comp; } else if (placement.equals(DIVIDER)) constraints = null; else throw new IllegalArgumentException("Constraints is not a known identifier."); super.addImpl(comp, constraints, index); } invalidate(); layout(); }
|
protected void addImpl(Component comp, Object constraints, int index) { int left = 0; int right = 1; int div = 2; int place; if (constraints == null) { if (leftComponent == null) constraints = LEFT; else if (rightComponent == null) constraints = RIGHT; } if (constraints instanceof String) { String placement = (String) constraints; if (placement.equals(BOTTOM) || placement.equals(RIGHT)) { if (rightComponent != null) remove(rightComponent); rightComponent = comp; } else if (placement.equals(LEFT) || placement.equals(TOP)) { if (leftComponent != null) remove(leftComponent); leftComponent = comp; } else if (placement.equals(DIVIDER)) constraints = null; else throw new IllegalArgumentException("Constraints is not a known identifier."); super.addImpl(comp, constraints, index); } invalidate(); layout(); }
| 10,292
|
private void resetSelectedValue() { if (inputComponent != null) { Object init = optionPane.getInitialSelectionValue(); if (init == null) return; if (inputComponent instanceof JTextField) ((JTextField) inputComponent).setText((String) init); else if (inputComponent instanceof JComboBox) ((JComboBox) inputComponent).setSelectedItem(init); else if (inputComponent instanceof JList) { // ((JList) inputComponent).setSelectedValue(init, true); } } }
|
void resetSelectedValue() { if (inputComponent != null) { Object init = optionPane.getInitialSelectionValue(); if (init == null) return; if (inputComponent instanceof JTextField) ((JTextField) inputComponent).setText((String) init); else if (inputComponent instanceof JComboBox) ((JComboBox) inputComponent).setSelectedItem(init); else if (inputComponent instanceof JList) { // ((JList) inputComponent).setSelectedValue(init, true); } } }
| 10,293
|
Object invoke (Remote obj, Method method, Object[] params, long opnum) throws Exception;
|
Object invoke (Remote obj, Method method, Object[] params, long opnum) throws Exception;
| 10,294
|
public void update (int bval);
|
void update (int bval);
| 10,295
|
public DataFormatException(String msg) { super(msg); }
|
public DataFormatException() { super(msg); }
| 10,296
|
public DataFormatException(String msg) { super(msg); }
|
public DataFormatException(String msg) { }
| 10,297
|
TemplateNode clone(Stylesheet stylesheet) { TemplateNode ret = new ParameterNode(name, select.clone(stylesheet), type); if (children != null) { ret.children = children.clone(stylesheet); } if (next != null) { ret.next = next.clone(stylesheet); } return ret; }
|
TemplateNode clone(Stylesheet stylesheet) TemplateNode ret = new ParameterNode(name, select.clone(stylesheet), type); if (children != null) ret.children = children.clone(stylesheet); } if (next != null) ret.next = next.clone(stylesheet); } return ret; }
| 10,298
|
TemplateNode clone(Stylesheet stylesheet) { TemplateNode ret = new ParameterNode(name, select.clone(stylesheet), type); if (children != null) { ret.children = children.clone(stylesheet); } if (next != null) { ret.next = next.clone(stylesheet); } return ret; }
|
TemplateNode clone(Stylesheet stylesheet) { TemplateNode ret = new ParameterNode(name, select.clone(stylesheet), type); if (children != null) { ret.children = children.clone(stylesheet); if (next != null) { ret.next = next.clone(stylesheet); return ret;
| 10,299
|
public int compareTo(Object other) { if (other instanceof ParameterNode) { ParameterNode pn = (ParameterNode) other; boolean r1 = references(pn.name); boolean r2 = pn.references(name); if (r1 && r2) { throw new IllegalArgumentException("circular definitions"); } if (r1) { return 1; } if (r2) { return -1; } } return 0; }
|
public int compareTo(Object other) if (other instanceof ParameterNode) ParameterNode pn = (ParameterNode) other; boolean r1 = references(pn.name); boolean r2 = pn.references(name); if (r1 && r2) throw new IllegalArgumentException("circular definitions"); } if (r1) return 1; } if (r2) return -1; } } return 0; }
| 10,300
|
public int compareTo(Object other) { if (other instanceof ParameterNode) { ParameterNode pn = (ParameterNode) other; boolean r1 = references(pn.name); boolean r2 = pn.references(name); if (r1 && r2) { throw new IllegalArgumentException("circular definitions"); } if (r1) { return 1; } if (r2) { return -1; } } return 0; }
|
public int compareTo(Object other) { if (other instanceof ParameterNode) { ParameterNode pn = (ParameterNode) other; boolean r1 = references(pn.name); boolean r2 = pn.references(name); if (r1 && r2) { throw new IllegalArgumentException("circular definitions"); if (r1) { return 1; if (r2) { return -1; return 0;
| 10,301
|
void doApply(Stylesheet stylesheet, QName mode, Node context, int pos, int len, Node parent, Node nextSibling) throws TransformerException { // push the variable context stylesheet.bindings.push(type); // set the variable Object value = getValue(stylesheet, mode, context, pos, len); if (value != null) { stylesheet.bindings.set(name, value, type); if (stylesheet.debug) { System.err.println(this + ": set to " + value); } } // variable and param don't process children as such // all subsequent instructions are processed with that variable context if (next != null) { next.apply(stylesheet, mode, context, pos, len, parent, nextSibling); } // pop the variable context stylesheet.bindings.pop(type); }
|
void doApply(Stylesheet stylesheet, QName mode, Node context, int pos, int len, Node parent, Node nextSibling) throws TransformerException // push the variable context stylesheet.bindings.push(type); // set the variable Object value = getValue(stylesheet, mode, context, pos, len); if (value != null) stylesheet.bindings.set(name, value, type); if (stylesheet.debug) System.err.println(this + ": set to " + value); } } // variable and param don't process children as such // all subsequent instructions are processed with that variable context if (next != null) next.apply(stylesheet, mode, context, pos, len, parent, nextSibling); } // pop the variable context stylesheet.bindings.pop(type); }
| 10,302
|
void doApply(Stylesheet stylesheet, QName mode, Node context, int pos, int len, Node parent, Node nextSibling) throws TransformerException { // push the variable context stylesheet.bindings.push(type); // set the variable Object value = getValue(stylesheet, mode, context, pos, len); if (value != null) { stylesheet.bindings.set(name, value, type); if (stylesheet.debug) { System.err.println(this + ": set to " + value); } } // variable and param don't process children as such // all subsequent instructions are processed with that variable context if (next != null) { next.apply(stylesheet, mode, context, pos, len, parent, nextSibling); } // pop the variable context stylesheet.bindings.pop(type); }
|
void doApply(Stylesheet stylesheet, QName mode, Node context, int pos, int len, Node parent, Node nextSibling) throws TransformerException { // push the variable context stylesheet.bindings.push(type); // set the variable Object value = getValue(stylesheet, mode, context, pos, len); if (value != null) { stylesheet.bindings.set(name, value, type); if (stylesheet.debug) { System.err.println(this + ": set to " + value); // variable and param don't process children as such // all subsequent instructions are processed with that variable context if (next != null) { next.apply(stylesheet, mode, context, pos, len, parent, nextSibling); // pop the variable context stylesheet.bindings.pop(type);
| 10,303
|
Object getValue(Stylesheet stylesheet, QName mode, Node context, int pos, int len) throws TransformerException { if (select != null) { return select.evaluate(context, pos, len); } else if (children != null) { Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); DocumentFragment fragment = doc.createDocumentFragment(); children.apply(stylesheet, mode, context, pos, len, fragment, null); return Collections.singleton(fragment); } else { return null; } }
|
Object getValue(Stylesheet stylesheet, QName mode, Node context, int pos, int len) throws TransformerException if (select != null) return select.evaluate(context, pos, len); } else if (children != null) Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); DocumentFragment fragment = doc.createDocumentFragment(); children.apply(stylesheet, mode, context, pos, len, fragment, null); return Collections.singleton(fragment); } else return null; } }
| 10,304
|
Object getValue(Stylesheet stylesheet, QName mode, Node context, int pos, int len) throws TransformerException { if (select != null) { return select.evaluate(context, pos, len); } else if (children != null) { Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); DocumentFragment fragment = doc.createDocumentFragment(); children.apply(stylesheet, mode, context, pos, len, fragment, null); return Collections.singleton(fragment); } else { return null; } }
|
Object getValue(Stylesheet stylesheet, QName mode, Node context, int pos, int len) throws TransformerException { if (select != null) { return select.evaluate(context, pos, len); else if (children != null) { Document doc = (context instanceof Document) ? (Document) context : context.getOwnerDocument(); DocumentFragment fragment = doc.createDocumentFragment(); children.apply(stylesheet, mode, context, pos, len, fragment, null); return Collections.singleton(fragment); else { return null;
| 10,305
|
public boolean references(QName var) { if (select != null && select.references(var)) { return true; } return super.references(var); }
|
public boolean references(QName var) if (select != null && select.references(var)) return true; } return super.references(var); }
| 10,306
|
public boolean references(QName var) { if (select != null && select.references(var)) { return true; } return super.references(var); }
|
public boolean references(QName var) { if (select != null && select.references(var)) { return true; return super.references(var);
| 10,307
|
public String toString() { StringBuffer buf = new StringBuffer(getClass().getName()); buf.append('['); buf.append("name="); buf.append(name); if (select != null) { buf.append(",select="); buf.append(select); } buf.append(",type="); switch (type) { case Bindings.VARIABLE: buf.append("variable"); break; case Bindings.PARAM: buf.append("param"); break; case Bindings.WITH_PARAM: buf.append("with-param"); break; } buf.append(']'); return buf.toString(); }
|
public String toString() { StringBuffer buf = new StringBuffer(getClass().getName()); buf.append('['); buf.append("name="); buf.append(name); if (select != null) { buf.append(",select="); buf.append(select); } buf.append(",type="); switch (type) { case Bindings.VARIABLE: buf.append("variable"); break; case Bindings.PARAM: buf.append("param"); break; case Bindings.WITH_PARAM: buf.append("with-param"); break; } buf.append(']'); return buf.toString(); }
| 10,308
|
public String format(LogRecord record) { StringBuffer buf = new StringBuffer(400); Level level = record.getLevel(); long millis = record.getMillis(); Object[] params = record.getParameters(); ResourceBundle bundle = record.getResourceBundle(); String key, message; buf.append("<record>"); buf.append(lineSep); appendTag(buf, 1, "date", iso8601.format(new Date(millis))); appendTag(buf, 1, "millis", record.getMillis()); appendTag(buf, 1, "sequence", record.getSequenceNumber()); appendTag(buf, 1, "logger", record.getLoggerName()); if (level.isStandardLevel()) appendTag(buf, 1, "level", level.toString()); else appendTag(buf, 1, "level", level.intValue()); appendTag(buf, 1, "class", record.getSourceClassName()); appendTag(buf, 1, "method", record.getSourceMethodName()); appendTag(buf, 1, "thread", record.getThreadID()); /* The Sun J2SE 1.4 reference implementation does not emit the * message in localized form. This is in violation of the API * specification. The GNU Classpath implementation intentionally * replicates the buggy behavior of the Sun implementation, as * different log files might be a big nuisance to users. */ try { record.setResourceBundle(null); message = formatMessage(record); } finally { record.setResourceBundle(bundle); } appendTag(buf, 1, "message", message); /* The Sun J2SE 1.4 reference implementation does not * emit key, catalog and param tags. This is in violation * of the API specification. The Classpath implementation * intentionally replicates the buggy behavior of the * Sun implementation, as different log files might be * a big nuisance to users. * * FIXME: File a bug report with Sun. Insert bug number here. * * * key = record.getMessage(); * if (key == null) * key = ""; * * if ((bundle != null) && !key.equals(message)) * { * appendTag(buf, 1, "key", key); * appendTag(buf, 1, "catalog", record.getResourceBundleName()); * } * * if (params != null) * { * for (int i = 0; i < params.length; i++) * appendTag(buf, 1, "param", params[i].toString()); * } */ /* FIXME: We have no way to obtain the stacktrace before free JVMs * support the corresponding method in java.lang.Throwable. Well, * it would be possible to parse the output of printStackTrace, * but this would be pretty kludgy. Instead, we postpose the * implementation until Throwable has made progress. */ Throwable thrown = record.getThrown(); if (thrown != null) { buf.append(" <exception>"); buf.append(lineSep); /* The API specification is not clear about what exactly * goes into the XML record for a thrown exception: It * could be the result of getMessage(), getLocalizedMessage(), * or toString(). Therefore, it was necessary to write a * Mauve testlet and run it with the Sun J2SE 1.4 reference * implementation. It turned out that the we need to call * toString(). * * FIXME: File a bug report with Sun, asking for clearer * specs. */ appendTag(buf, 2, "message", thrown.toString()); /* FIXME: The Logging DTD specifies: * * <!ELEMENT exception (message?, frame+)> * * However, java.lang.Throwable.getStackTrace() is * allowed to return an empty array. So, what frame should * be emitted for an empty stack trace? We probably * should file a bug report with Sun, asking for the DTD * to be changed. */ buf.append(" </exception>"); buf.append(lineSep); } buf.append("</record>"); buf.append(lineSep); return buf.toString(); }
|
public String format(LogRecord record) { StringBuffer buf = new StringBuffer(400); Level level = record.getLevel(); long millis = record.getMillis(); Object[] params = record.getParameters(); ResourceBundle bundle = record.getResourceBundle(); String message; buf.append("<record>"); buf.append(lineSep); appendTag(buf, 1, "date", iso8601.format(new Date(millis))); appendTag(buf, 1, "millis", record.getMillis()); appendTag(buf, 1, "sequence", record.getSequenceNumber()); appendTag(buf, 1, "logger", record.getLoggerName()); if (level.isStandardLevel()) appendTag(buf, 1, "level", level.toString()); else appendTag(buf, 1, "level", level.intValue()); appendTag(buf, 1, "class", record.getSourceClassName()); appendTag(buf, 1, "method", record.getSourceMethodName()); appendTag(buf, 1, "thread", record.getThreadID()); /* The Sun J2SE 1.4 reference implementation does not emit the * message in localized form. This is in violation of the API * specification. The GNU Classpath implementation intentionally * replicates the buggy behavior of the Sun implementation, as * different log files might be a big nuisance to users. */ try { record.setResourceBundle(null); message = formatMessage(record); } finally { record.setResourceBundle(bundle); } appendTag(buf, 1, "message", message); /* The Sun J2SE 1.4 reference implementation does not * emit key, catalog and param tags. This is in violation * of the API specification. The Classpath implementation * intentionally replicates the buggy behavior of the * Sun implementation, as different log files might be * a big nuisance to users. * * FIXME: File a bug report with Sun. Insert bug number here. * * * key = record.getMessage(); * if (key == null) * key = ""; * * if ((bundle != null) && !key.equals(message)) * { * appendTag(buf, 1, "key", key); * appendTag(buf, 1, "catalog", record.getResourceBundleName()); * } * * if (params != null) * { * for (int i = 0; i < params.length; i++) * appendTag(buf, 1, "param", params[i].toString()); * } */ /* FIXME: We have no way to obtain the stacktrace before free JVMs * support the corresponding method in java.lang.Throwable. Well, * it would be possible to parse the output of printStackTrace, * but this would be pretty kludgy. Instead, we postpose the * implementation until Throwable has made progress. */ Throwable thrown = record.getThrown(); if (thrown != null) { buf.append(" <exception>"); buf.append(lineSep); /* The API specification is not clear about what exactly * goes into the XML record for a thrown exception: It * could be the result of getMessage(), getLocalizedMessage(), * or toString(). Therefore, it was necessary to write a * Mauve testlet and run it with the Sun J2SE 1.4 reference * implementation. It turned out that the we need to call * toString(). * * FIXME: File a bug report with Sun, asking for clearer * specs. */ appendTag(buf, 2, "message", thrown.toString()); /* FIXME: The Logging DTD specifies: * * <!ELEMENT exception (message?, frame+)> * * However, java.lang.Throwable.getStackTrace() is * allowed to return an empty array. So, what frame should * be emitted for an empty stack trace? We probably * should file a bug report with Sun, asking for the DTD * to be changed. */ buf.append(" </exception>"); buf.append(lineSep); } buf.append("</record>"); buf.append(lineSep); return buf.toString(); }
| 10,310
|
public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { /* return new XMLStreamReaderImpl(reader, null, null, resolver, reporter, validating, namespaceAware, coalescing, replacingEntityReferences, externalEntities, supportDTD); */ XMLParser ret = new XMLParser(reader, null, validating, namespaceAware, coalescing, replacingEntityReferences, externalEntities, supportDTD, baseAware, stringInterning, reporter, resolver); if (xIncludeAware) return new XIncludeFilter(ret, null, namespaceAware, validating, replacingEntityReferences); return ret; }
|
public XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException { /* return new XMLStreamReaderImpl(reader, null, null, resolver, reporter, validating, namespaceAware, coalescing, replacingEntityReferences, externalEntities, supportDTD); */ XMLParser ret = new XMLParser(reader, null, validating, namespaceAware, coalescing, replacingEntityReferences, externalEntities, supportDTD, baseAware, stringInterning, reporter, resolver); if (xIncludeAware) return new XIncludeFilter(ret, null, namespaceAware, validating, replacingEntityReferences); return ret; }
| 10,311
|
public Dimension getPreferredSize(JComponent c) { maybeUpdateLayoutState(); if (list.getModel().getSize() == 0) return new Dimension(0, 0); Rectangle bounds = getCellBounds(list, 0, list.getModel().getSize() - 1); return bounds.getSize(); }
|
public Dimension getPreferredSize(JComponent c) { maybeUpdateLayoutState(); if (list.getModel().getSize() == 0) return new Dimension(0, 0); int nrows = Math.min(list.getVisibleRowCount(), list.getModel().getSize()); Rectangle bounds = getCellBounds(list, 0, nrows - 1); return bounds.getSize(); }
| 10,313
|
public Point indexToLocation(JList list, int index) { throw new Error("Not implemented"); }
|
public Point indexToLocation(JList list, int index) { return new Point(0, convertRowToY(index)); }
| 10,314
|
public int locationToIndex(JList list, Point location) { throw new Error("Not implemented"); }
|
public int locationToIndex(JList list, Point location) { return convertYToRow(location.y); }
| 10,316
|
public static ActivationSystem getSystem() throws ActivationException { if (system == null) return DefaultActivationSystem.singleton; else return system; }
|
public static ActivationSystem getSystem() throws ActivationException { if (system == null) return DefaultActivationSystem.get(); else return system; }
| 10,317
|
public ActivationException(String s) { this(s, null); }
|
public ActivationException() { this(s, null); }
| 10,318
|
public ActivationException(String s) { this(s, null); }
|
public ActivationException(String s) { this(null, null); }
| 10,319
|
public ActivationGroupDesc(String className, String location, MarshalledObject data, Properties overrides, ActivationGroupDesc.CommandEnvironment cmd) { throw new Error("Not implemented");}
|
public ActivationGroupDesc(Properties overrides, ActivationGroupDesc.CommandEnvironment cmd) { throw new Error("Not implemented");}
| 10,320
|
boolean remove(Object o);
|
E remove(int index);
| 10,321
|
public int compareTo (BigDecimal val) { if (scale == val.scale) return intVal.compareTo (val.intVal); BigInteger thisParts[] = intVal.divideAndRemainder (BigInteger.valueOf (10).pow (scale)); BigInteger valParts[] = val.intVal.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale)); int compare; if ((compare = thisParts[0].compareTo (valParts[0])) != 0) return compare; // quotients are the same, so compare remainders // remove trailing zeros if (thisParts[1].equals (BigInteger.valueOf (0)) == false) while (thisParts[1].mod (BigInteger.valueOf (10)).equals (BigInteger.valueOf (0))) thisParts[1] = thisParts[1].divide (BigInteger.valueOf (10)); // again... if (valParts[1].equals(BigInteger.valueOf (0)) == false) while (valParts[1].mod (BigInteger.valueOf (10)).equals (BigInteger.valueOf (0))) valParts[1] = valParts[1].divide (BigInteger.valueOf (10)); // and compare them return thisParts[1].compareTo (valParts[1]); }
|
public int compareTo (BigDecimal val) { if (scale == val.scale) return intVal.compareTo (val.intVal); BigInteger thisParts[] = intVal.divideAndRemainder (BigInteger.valueOf (10).pow (scale)); BigInteger valParts[] = val.intVal.divideAndRemainder (BigInteger.valueOf (10).pow (val.scale)); int compare; if ((compare = thisParts[0].compareTo (valParts[0])) != 0) return compare; // quotients are the same, so compare remainders // remove trailing zeros if (thisParts[1].equals (BigInteger.valueOf (0)) == false) while (thisParts[1].mod (BigInteger.valueOf (10)).equals (BigInteger.valueOf (0))) thisParts[1] = thisParts[1].divide (BigInteger.valueOf (10)); // again... if (valParts[1].equals(BigInteger.valueOf (0)) == false) while (valParts[1].mod (BigInteger.valueOf (10)).equals (BigInteger.valueOf (0))) valParts[1] = valParts[1].divide (BigInteger.valueOf (10)); // and compare them return thisParts[1].compareTo (valParts[1]); }
| 10,322
|
public BigInteger abs() { return abs(this); }
|
private static BigInteger abs(BigInteger x) { return abs(this); }
| 10,323
|
public BigInteger abs() { return abs(this); }
|
public BigInteger abs() { return x.isNegative() ? neg(x) : x; }
| 10,324
|
public BigInteger negate() { return neg(this); }
|
private static boolean negate(int[] dest, int[] src, int len) { return neg(this); }
| 10,325
|
public BigInteger negate() { return neg(this); }
|
public BigInteger negate() { long carry = 1; boolean negative = src[len-1] < 0; for (int i = 0; i < len; i++) { carry += ((long) (~src[i]) & 0xffffffffL); dest[i] = (int) carry; carry >>= 32; } return (negative && dest[len-1] < 0); }
| 10,326
|
public final Class getCategory() { return PrinterName.class; }
|
public Class getCategory() { return PrinterName.class; }
| 10,327
|
public final String getName() { return "printer-name"; }
|
public String getName() { return "printer-name"; }
| 10,328
|
public int hashCode() { return value.hashCode() + locale.hashCode(); }
|
public int hashCode() { return value.hashCode() ^ locale.hashCode(); }
| 10,329
|
protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent ev, Shape shape) { Rectangle b = shape.getBounds(); if (ec != null) preferenceChanged(this, true, true); }
|
protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent ev, Shape shape) { Rectangle b = shape.getBounds(); if (ec != null) preferenceChanged(this, true, true); }
| 10,330
|
public static String getClientHost() throws ServerNotActiveException { throw new Error("Not implemented");}
|
public static String getClientHost() throws ServerNotActiveException { Thread currThread = Thread.currentThread(); if (currThread instanceof RMIIncomingThread) { RMIIncomingThread incomingThread = (RMIIncomingThread) currThread; return incomingThread.getClientHost(); } else { throw new ServerNotActiveException( "Unknown client host - current thread not instance of 'RMIIncomingThread'"); }}
| 10,332
|
public ServerNotActiveException(String s) { super(s); }
|
public ServerNotActiveException() { super(s); }
| 10,333
|
public ServerNotActiveException(String s) { super(s); }
|
public ServerNotActiveException(String s) { }
| 10,334
|
protected void frameInit() { super.setLayout(new BorderLayout(1, 1)); enableEvents(AWTEvent.WINDOW_EVENT_MASK); getRootPane(); // will do set/create // Setup the defaultLookAndFeelDecoration if requested. if (isDefaultLookAndFeelDecorated() && UIManager.getLookAndFeel().getSupportsWindowDecorations()) { setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.FRAME); } // We're now done the init stage. setRootPaneCheckingEnabled(true); }
|
protected void frameInit() { super.setLayout(new BorderLayout()); setBackground(UIManager.getDefaults().getColor("control")); enableEvents(AWTEvent.WINDOW_EVENT_MASK); getRootPane(); // will do set/create // Setup the defaultLookAndFeelDecoration if requested. if (isDefaultLookAndFeelDecorated() && UIManager.getLookAndFeel().getSupportsWindowDecorations()) { setUndecorated(true); getRootPane().setWindowDecorationStyle(JRootPane.FRAME); } // We're now done the init stage. setRootPaneCheckingEnabled(true); }
| 10,335
|
Frame(String title){ super(); this.title = title; // Top-level frames are initially invisible. visible = false; noteFrame(this);}
|
Frame(){ super(); this.title = title; // Top-level frames are initially invisible. visible = false; noteFrame(this);}
| 10,336
|
Frame(String title){ super(); this.title = title; // Top-level frames are initially invisible. visible = false; noteFrame(this);}
|
Frame(String title){ super(); this.title = title; // Top-level frames are initially invisible. visible = false; noteFrame(this);}
| 10,337
|
public abstract boolean addMember(Principal user);
|
boolean addMember(Principal user);
| 10,338
|
public abstract boolean isMember(Principal member);
|
boolean isMember(Principal member);
| 10,339
|
public abstract Enumeration members();
|
Enumeration members();
| 10,340
|
public abstract boolean removeMember(Principal user);
|
boolean removeMember(Principal user);
| 10,341
|
public int findColumn(String columnName) { // Variables int index; String name; int count; // Process Columns count = getColumnCount(); for (index = 0; index < count; index++) { name = getColumnName(index); if (columnName.equals(name) == true) { return index; } // if } // for // Unable to Locate return -1; } // findColumn()
|
public int findColumn (String columnName) { int count = getColumnCount(); for (int index = 0; index < count; index++) { String name = getColumnName (index); if (name.equals (columnName)) return index; } // Variables int index; String name; int count; // Process Columns count = getColumnCount(); for (index = 0; index < count; index++) { name = getColumnName(index); if (columnName.equals(name) == true) { return index; } // if } // for // Unable to Locate return -1; } // findColumn()
| 10,342
|
public int findColumn(String columnName) { // Variables int index; String name; int count; // Process Columns count = getColumnCount(); for (index = 0; index < count; index++) { name = getColumnName(index); if (columnName.equals(name) == true) { return index; } // if } // for // Unable to Locate return -1; } // findColumn()
|
public int findColumn(String columnName) { // Variables int index; String name; int count; // Process Columns count = getColumnCount(); for (index = 0; index < count; index++) { name = getColumnName(index); if (columnName.equals(name) == true) { return index; } // if } // for // Unable to Locate return -1; } // findColumn()
| 10,343
|
public void fireTableChanged(TableModelEvent event) { // Variables Object[] list; int index; TableModelListener listener; // Get Listener List list = listenerList.getListenerList(); for (index = 0; index < list.length; index += 2) { // Get Listener listener = (TableModelListener) list[index + 1]; // Notify Listener listener.tableChanged(event); } // for: index } // fireTableChanged()
|
public void fireTableChanged(TableModelEvent event) { // Variables Object[] list; int index; TableModelListener listener; // Get Listener List list = listenerList.getListenerList(); for (index = 0; index < list.length; index += 2) { // Get Listener listener = (TableModelListener) list[index + 1]; // Notify Listener listener.tableChanged(event); } // for: index } // fireTableChanged()
| 10,344
|
public void fireTableChanged(TableModelEvent event) { // Variables Object[] list; int index; TableModelListener listener; // Get Listener List list = listenerList.getListenerList(); for (index = 0; index < list.length; index += 2) { // Get Listener listener = (TableModelListener) list[index + 1]; // Notify Listener listener.tableChanged(event); } // for: index } // fireTableChanged()
|
public void fireTableChanged(TableModelEvent event) { // Variables Object[] list; int index; TableModelListener listener; // Get Listener List list = listenerList.getListenerList(); for (index = 0; index < list.length; index += 2) { // Get Listener listener = (TableModelListener) list[index + 1]; // Notify Listener listener.tableChanged(event); } // for: index } // fireTableChanged()
| 10,345
|
public String getColumnName(int columnIndex) { // Variables int index; int left; int base; int multiplier; StringBuffer buffer; boolean foundFirst; // Ok, this is not the best solution in the world // and it does produce wrong answers starting 1378 // but it's a start. I sure hope there is a more // simple algorithm. I started with a base 10 to // base 26 converter and later found that there // were so many are exceptions that it has morphed // into a pile of goop. // NOTE2: I have a working algorithm which is much // much simplier and works for all values...I'll // be adding it soon... // Process Exponent levels buffer = new StringBuffer(); left = columnIndex; foundFirst = false; for (index = 6; index >= 0; index--) { base = (int) (Math.pow(26, index)); if (index > 1) { base = base + (int) (Math.pow(26, index - 1)); } if (base <= left) { multiplier = left / base; if (foundFirst == false && index > 0) { buffer.append((char) (multiplier + 64)); } else { buffer.append((char) (multiplier + 65)); } left = left - (base * multiplier); foundFirst = true; } else if (foundFirst == true || index == 0) { buffer.append('A'); } } // for // Return Column Name return buffer.toString(); } // getColumnName()
|
public String getColumnName (int columnIndex) { int index = columnIndex + 1; StringBuffer buffer = new StringBuffer(); // Variables int index; int left; int base; int multiplier; StringBuffer buffer; boolean foundFirst; // Ok, this is not the best solution in the world // and it does produce wrong answers starting 1378 // but it's a start. I sure hope there is a more // simple algorithm. I started with a base 10 to // base 26 converter and later found that there // were so many are exceptions that it has morphed // into a pile of goop. // NOTE2: I have a working algorithm which is much // much simplier and works for all values...I'll // be adding it soon... // Process Exponent levels buffer = new StringBuffer(); left = columnIndex; foundFirst = false; for (index = 6; index >= 0; index--) { base = (int) (Math.pow(26, index)); if (index > 1) { base = base + (int) (Math.pow(26, index - 1)); } if (base <= left) { multiplier = left / base; if (foundFirst == false && index > 0) { buffer.append((char) (multiplier + 64)); } else { buffer.append((char) (multiplier + 65)); } left = left - (base * multiplier); foundFirst = true; } else if (foundFirst == true || index == 0) { buffer.append('A'); } } // for // Return Column Name return buffer.toString(); } // getColumnName()
| 10,346
|
public String getColumnName(int columnIndex) { // Variables int index; int left; int base; int multiplier; StringBuffer buffer; boolean foundFirst; // Ok, this is not the best solution in the world // and it does produce wrong answers starting 1378 // but it's a start. I sure hope there is a more // simple algorithm. I started with a base 10 to // base 26 converter and later found that there // were so many are exceptions that it has morphed // into a pile of goop. // NOTE2: I have a working algorithm which is much // much simplier and works for all values...I'll // be adding it soon... // Process Exponent levels buffer = new StringBuffer(); left = columnIndex; foundFirst = false; for (index = 6; index >= 0; index--) { base = (int) (Math.pow(26, index)); if (index > 1) { base = base + (int) (Math.pow(26, index - 1)); } if (base <= left) { multiplier = left / base; if (foundFirst == false && index > 0) { buffer.append((char) (multiplier + 64)); } else { buffer.append((char) (multiplier + 65)); } left = left - (base * multiplier); foundFirst = true; } else if (foundFirst == true || index == 0) { buffer.append('A'); } } // for // Return Column Name return buffer.toString(); } // getColumnName()
|
public String getColumnName(int columnIndex) { // Variables int index; int left; int base; int multiplier; StringBuffer buffer; boolean foundFirst; // Ok, this is not the best solution in the world // and it does produce wrong answers starting 1378 // but it's a start. I sure hope there is a more // simple algorithm. I started with a base 10 to // base 26 converter and later found that there // were so many are exceptions that it has morphed // into a pile of goop. // NOTE2: I have a working algorithm which is much // much simplier and works for all values...I'll // be adding it soon... // Process Exponent levels buffer = new StringBuffer(); left = columnIndex; foundFirst = false; for (index = 6; index >= 0; index--) { base = (int) (Math.pow(26, index)); if (index > 1) { base = base + (int) (Math.pow(26, index - 1)); } if (base <= left) { multiplier = left / base; if (foundFirst == false && index > 0) { buffer.append((char) (multiplier + 64)); } else { buffer.append((char) (multiplier + 65)); } left = left - (base * multiplier); foundFirst = true; } else if (foundFirst == true || index == 0) { buffer.append('A'); } } // for // Return Column Name return buffer.toString(); } // getColumnName()
| 10,347
|
createURLStreamHandler(String protocol);
|
URLStreamHandler createURLStreamHandler(String protocol);
| 10,350
|
private AccessibleJTableHeaderCell(JTableHeader h, Component comp, int r, int c) { }
|
private AccessibleJTableHeaderCell(JTableHeader h, Component comp, int r, int c) { header = h; columnIndex = c; }
| 10,351
|
public AccessibleContext getAccessibleContext() { // TODO Auto-generated method stub return null; }
|
public AccessibleContext getAccessibleContext() { // TODO Auto-generated method stub return this; }
| 10,352
|
public Accessible getAccessibleAt(int r, int c) { return getAccessibleChild(r * getAccessibleColumnCount() + c); }
|
public Accessible getAccessibleAt(int r, int c) { TableCellRenderer cellRenderer = getCellRenderer(r, c); Component renderer = cellRenderer.getTableCellRendererComponent( JTable.this, getValueAt(r, c), isCellSelected(r, c), false, r, c); if (renderer instanceof Accessible) return (Accessible) renderer; return null; }
| 10,354
|
public static Border createLineBorder( Color color, int thickness) { /* Creates a line border withe the specified color and width. The width applies to all 4 sides of the border. To specify widths individually for the top, bottom, left, and right, use createMatteBorder(int,int,int,int,Color). Parameters: color - a Color to use for the linethickness - an int specifying the width in pixelsReturns: the Border object createRaisedBevelBorder */ return null; }
|
public static Border createLineBorder( Color color, int thickness) { /* Creates a line border withe the specified color and width. The width applies to all 4 sides of the border. To specify widths individually for the top, bottom, left, and right, use createMatteBorder(int,int,int,int,Color). Parameters: color - a Color to use for the linethickness - an int specifying the width in pixelsReturns: the Border object createRaisedBevelBorder */ return null; }
| 10,355
|
public void setBorderPainted(boolean b) { if (b != paint_border) { paint_border = b; revalidate(); repaint(); } }
|
public void setBorderPainted(boolean b) { if (b != paint_border) { paint_border = b; revalidate(); repaint(); } }
| 10,356
|
public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data) { int size = w*h; int outOffset = 0; int[] pixel = null; if (iArray == null) iArray = new int[w*h*numBands]; for (int yy=y; yy<(y+h); yy++) { for (int xx=x; xx<(x+w); xx++) { getPixel(xx, yy, pixel, data); System.arraycopy(pixel, 0, iArray, outOffset, numBands); outOffset += numBands; } } return iArray; }
|
public int[] getPixels(int x, int y, int w, int h, int[] iArray, DataBuffer data) { int size = w*h; int outOffset = 0; int[] pixel = null; if (iArray == null) iArray = new int[w*h*numBands]; for (int yy=y; yy<(y+h); yy++) { for (int xx=x; xx<(x+w); xx++) { pixel = getPixel(xx, yy, pixel, data); System.arraycopy(pixel, 0, iArray, outOffset, numBands); outOffset += numBands; } } return iArray; }
| 10,357
|
public int getColumnCount() { return (columnIdentifiers == null ? 0 : columnIdentifiers.size()); }
|
public int getColumnCount() { return (columnIdentifiers == null ? 0 : columnIdentifiers.size()); }
| 10,358
|
public void setColumnIdentifiers(Vector columnIdentifiers) { this.columnIdentifiers = columnIdentifiers; setColumnCount((columnIdentifiers == null ? 0 : columnIdentifiers.size())); }
|
public void setColumnIdentifiers(Vector columnIdentifiers) { this.columnIdentifiers = columnIdentifiers; setColumnCount(columnIdentifiers == null ? 0 : columnIdentifiers.size()); }
| 10,360
|
public void setRowCount(int rowCount) { int existingRowCount = dataVector.size(); if (rowCount < existingRowCount) { dataVector.setSize(rowCount); fireTableRowsDeleted(rowCount,existingRowCount-1); } else { int rowsToAdd = rowCount - existingRowCount; for (int i = 0; i < rowsToAdd; i++) { Vector tmp = new Vector(); tmp.setSize(columnIdentifiers.size()); dataVector.add(tmp); } fireTableRowsInserted(existingRowCount,rowCount-1); } }
|
public void setRowCount(int rowCount) { int existingRowCount = dataVector.size(); if (rowCount < existingRowCount) { dataVector.setSize(rowCount); fireTableRowsDeleted(rowCount,existingRowCount-1); } else { int rowsToAdd = rowCount - existingRowCount; for (int i = 0; i < rowsToAdd; i++) { Vector tmp = new Vector(); tmp.setSize(columnIdentifiers.size()); dataVector.add(tmp); } fireTableRowsInserted(existingRowCount,rowCount-1); } }
| 10,361
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.