clearPositionReferences();
if (pos == null) { int mark = offset; if (mark >= gapStart) mark += (gapEnd - gapStart); pos = new GapContentPosition(mark); positions.put(pos, null); }
  public Position createPosition(final int offset) throws BadLocationException  {    if (offset < 0 || offset > length())      throw new BadLocationException("The offset was out of the bounds of this"          + " buffer", offset);    clearPositionReferences();    // We store the actual array index in the GapContentPosition. The real    // offset is then calculated in the GapContentPosition.    int mark = offset;    if (offset >= gapStart)      mark += gapEnd - gapStart;    GapContentPosition pos = new GapContentPosition(mark);    WeakReference r = new WeakReference(pos);    // Add this into our list in a sorted fashion.    int index = Collections.binarySearch(positions, r,                                         new WeakPositionComparator());    if (index < 0)      index = -(index + 1);    positions.add(index, r);    return pos;  }