Java 8 Range - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Range class.

This code example shows how to use the following methods:compareBoundaryPoints, getEndContainer, getEndOffset, getStartContainer, getStartOffset
    return FILTER_ACCEPT;
  } 
 
  private boolean inside(Node n) {
    Range   r     = ((DocumentRange) document).createRange();
    boolean start = (n == range.getStartContainer());
    boolean end   = (n == range.getEndContainer());
 
    if (start || end)
      r.selectNodeContents(n);
    else 
      r.selectNode(n);
 
    if (start)
      r.setStart(n, range.getStartOffset());
 
    if (end)
      r.setEnd(n, range.getEndOffset());
 
    //compare start of other to start of this 

6
CodeRank
This code example shows how to use the following methods:setEnd, setStart
        Range r = docRange.createRange();
        // some xml parsers don't allow end<start in the same text node. So, 
        // handle dot<mark here 
 
        if (this.markInfo.range.compareBoundaryPoints(Range.START_TO_START, this.dotInfo.range) <= 0) {
            r.setStart(this.markInfo.range.getStartContainer(), this.markInfo.range
                    .getStartOffset());
            r.setEnd(this.dotInfo.range.getStartContainer(), this.dotInfo.range.getStartOffset());
        } else { 
            r.setStart(this.dotInfo.range.getStartContainer(), this.dotInfo.range.getStartOffset());
            r.setEnd(this.markInfo.range.getStartContainer(), this.markInfo.range.getStartOffset());
        } 
        return r;
    } 
 
    protected void adjustVisibility(Rectangle nloc) {
        if (panel == null) {
            return; 
        } 
        if (SwingUtilities.isEventDispatchThread()) {
5
CodeRank
This code example shows how to use the following methods:cloneRange, setStart
   * @return the newly created object. 
   */ 
  public SelectionRange cloneRange() { 
    SelectionRange dup = new SelectionRange();
    dup.userDataList.addAll(userDataList);
    dup.range = range.cloneRange();
 
    return dup;
  } 
 
  /** 
   * Returns the list of user data items 
   * 
   * @return the list (not a copy, so modifiable) 
   */ 
  public List getUserDataList() {
    return userDataList;
  } 
 
  /** 

4
CodeRank
This code example shows how to use the following methods:compareBoundaryPoints
    // Now modify the document 
    for (int i = length - 1; i >= 0; i--) {
      for (int j = ranges[i].length() - 1; j >= 0; j--) {
        Range   range = ranges[i].get(j).toRange();
        Element rNode =
          range.getStartContainer().getOwnerDocument().createElementNS(nsUri, elemQName);
        rNode.setAttributeNS(nsUri, idAttrQName, "" + (i + 1));
        if ((j == 0) && (firstId != null)) {
          rNode.setAttributeNS(nsUri, firstId, "true");
        } 
        range.surroundContents(rNode);
      } 
    } 
  } 
 
  private void insertAtOrAfter(int i, SelectionRange newSelectionRange) {
    int            length = selectionRanges.size();
 
    SelectionRange selectionRange = null;
 
4
CodeRank
See Code Examples for Java 8 Range Methods: