/** * Returns whether an offset is contained by any position in this * model. * * @param offset the offset to check * @return <code>true</code> if <code>offset</code> is included by any * position (see {@link LinkedPosition#includes(int)}) in this * model, <code>false</code> otherwise */ public boolean anyPositionContains(int offset) { for (LinkedPositionGroup group : fGroups) { if (group.contains(offset)) // take the first hit - exclusion is guaranteed by enforcing // disjointness when adding positions return true; } return false; }
/** * Returns the linked position group that contains <code>position</code>, * or <code>null</code> if <code>position</code> is not contained in any * group within this model. Group containment is tested by calling * <code>group.contains(position)</code> for every <code>group</code> in * this model. * * <p> * This method part of the private protocol between * <code>LinkedModeUI</code> and <code>LinkedModeModel</code>. * </p> * * @param position the position the group of which is requested * @return the first group in this model for which * <code>group.contains(position)</code> returns <code>true</code>, * or <code>null</code> if no group contains <code>position</code> */ public LinkedPositionGroup getGroupForPosition(Position position) { for (LinkedPositionGroup group : fGroups) { if (group.contains(position)) return group; } return null; } }
/** * Returns whether an offset is contained by any position in this * model. * * @param offset the offset to check * @return <code>true</code> if <code>offset</code> is included by any * position (see {@link LinkedPosition#includes(int)}) in this * model, <code>false</code> otherwise */ public boolean anyPositionContains(int offset) { for (Iterator<LinkedPositionGroup> it= fGroups.iterator(); it.hasNext(); ) { LinkedPositionGroup group= it.next(); if (group.contains(offset)) // take the first hit - exclusion is guaranteed by enforcing // disjointness when adding positions return true; } return false; }
/** * Returns the linked position group that contains <code>position</code>, * or <code>null</code> if <code>position</code> is not contained in any * group within this model. Group containment is tested by calling * <code>group.contains(position)</code> for every <code>group</code> in * this model. * * <p> * This method part of the private protocol between * <code>LinkedModeUI</code> and <code>LinkedModeModel</code>. * </p> * * @param position the position the group of which is requested * @return the first group in this model for which * <code>group.contains(position)</code> returns <code>true</code>, * or <code>null</code> if no group contains <code>position</code> */ public LinkedPositionGroup getGroupForPosition(Position position) { for (Iterator<LinkedPositionGroup> it= fGroups.iterator(); it.hasNext(); ) { LinkedPositionGroup group= it.next(); if (group.contains(position)) return group; } return null; } }