/**
   * constructs region Node
   *
   * @param regionName
   * @param regionInfo RegionInfo
   * @param pregion Protocol region
   */
  public void constructRegion(RegionInfo regionInfo, Object pregion) throws CollabException {
    String regionName = regionInfo.getID();
    String mode = regionInfo.getMode();
    int beginOffset = 0;
    int endOffset = 0;
    StyledDocument fileDocument = getDocument();

    if (mode.equals(RegionInfo.LINE_RANGE)) {
      javax.swing.text.Element beginElement =
          fileDocument.getDefaultRootElement().getElement(regionInfo.getbegin());
      beginOffset = beginElement.getStartOffset();

      javax.swing.text.Element endElement =
          fileDocument.getDefaultRootElement().getElement(regionInfo.getend());
      endOffset = endElement.getEndOffset();
    } else {
      beginOffset = regionInfo.getbegin();
      endOffset = regionInfo.getend();
      int endCorrection = regionInfo.getCorrection();
      endOffset += endCorrection;
      if (endOffset < 0) endOffset = 0;
    }

    if (pregion instanceof JavaRegion) {
      JavaRegion javaRegion = (JavaRegion) pregion;
      int length = endOffset - beginOffset;
      javaRegion.setRegionName(regionName);
      javaRegion.setBeginOffset(new java.math.BigInteger(String.valueOf(beginOffset)));
      javaRegion.setLength(new java.math.BigInteger(String.valueOf(length)));
    } else {
      super.constructRegion(regionInfo, pregion);
    }
  }