javax.swing.text.BadLocationException.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(140)

本文整理了Java中javax.swing.text.BadLocationException.<init>()方法的一些代码示例,展示了BadLocationException.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BadLocationException.<init>()方法的具体详情如下:
包路径:javax.swing.text.BadLocationException
类名称:BadLocationException
方法名:<init>

BadLocationException.<init>介绍

暂无

代码示例

代码示例来源:origin: groovy/groovy-core

public MultiLineRun(int start, int end, int delimeterSize) throws BadLocationException {
  if (start > end) {
    String msg = "Start offset is after end: ";
    throw new BadLocationException(msg, start);
  }
  if (delimeterSize < 1) {
    String msg = "Delimiters be at least size 1: " + 
           delimeterSize;
    throw new IllegalArgumentException(msg);
  }
  this.start = styledDocument.createPosition(start);
  this.end = styledDocument.createPosition(end);
  this.delimeterSize = delimeterSize;
}

代码示例来源:origin: skylot/jadx

private int getOffsetY(int rowStartOffset, FontMetrics fontMetrics) throws BadLocationException {
  Rectangle r = codeArea.modelToView(rowStartOffset);
  if (r == null) {
    throw new BadLocationException("Can't get Y offset", rowStartOffset);

代码示例来源:origin: geotools/geotools

/**
   * Check the proposed text and, if it is valid, parse it as an integer value.
   *
   * @param proposedText the proposed text value
   * @param offset position in the document
   * @return the parsed integer value
   * @throws BadLocationException if the string did not represent a value integer
   */
  public int checkInput(String proposedText, int offset) throws BadLocationException {
    int newValue = 0;

    if (proposedText != null && proposedText.length() > 0) {
      try {
        newValue = Integer.parseInt(proposedText);
      } catch (NumberFormatException ex) {
        throw new BadLocationException(proposedText, offset);
      }
    }

    return newValue;
  }
}

代码示例来源:origin: ron190/jsql-injection

/**
 * Get index of line for current offset (generally cursor position).
 * @param offset Position on the line
 * @return Index of the line
 * @throws BadLocationException
 */
public int getLineOfOffset(int offset) throws BadLocationException {
  String errorMsg = "Can't translate offset to line";
  Document doc = this.getDocument();
  if (offset < 0) {
    throw new BadLocationException(errorMsg, -1);
  } else if (offset > doc.getLength()) {
    throw new BadLocationException(errorMsg, doc.getLength() + 1);
  } else {
    Element map = doc.getDefaultRootElement();
    return map.getElementIndex(offset);
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

Element line = getLineElem(doc, offs);
if (line == null) {
  throw new BadLocationException("No word at " + offs, offs);

代码示例来源:origin: ron190/jsql-injection

/**
 * Get position of the beginning of the line.
 * @param line Index of the line
 * @return Offset of line
 * @throws BadLocationException
 */
public int getLineStartOffset(int line) throws BadLocationException {
  Element map = this.getDocument().getDefaultRootElement();
  if (line < 0) {
    throw new BadLocationException("Negative line", -1);
  } else if (line >= map.getElementCount()) {
    throw new BadLocationException("No such line", this.getDocument().getLength() + 1);
  } else {
    Element lineElem = map.getElement(line);
    return lineElem.getStartOffset();
  }
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

public char charAt(int offset) throws BadLocationException {
  if (offset<0 || offset>=length()) {
    throw new BadLocationException("Invalid offset", offset);
  }
  int g0 = getGapStart();
  char[] array = (char[]) getArray();
  if (offset<g0) { // below gap
    return array[offset];
  }
  return array[getGapEnd() + offset - g0]; // above gap
}

代码示例来源:origin: bobbylight/RSyntaxTextArea

throw new BadLocationException("Offset " + offs + " not in " +
  "required range of 0-" + textArea.getDocument().getLength(),
  offs);

代码示例来源:origin: bobbylight/RSyntaxTextArea

throw new BadLocationException("Invalid document position", p0);
throw new BadLocationException("Invalid document position", p1);

代码示例来源:origin: bobbylight/RSyntaxTextArea

throw new BadLocationException("Position not represented by view", pos);

代码示例来源:origin: bobbylight/RSyntaxTextArea

throw new BadLocationException(null, pos);

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

private void checkOffsetNonNegative(int offset) throws BadLocationException {
  if (offset < 0) {
    throw new BadLocationException("Invalid offset=" + offset // NOI18N
      + " < 0; docLen=" + docLen(), offset); // NOI18N
  }
}

代码示例来源:origin: io.github.dheid/wings

@Override
public void insert(int offset, String string) throws BadLocationException {
  if (string == null || string.length() == 0) {
    return;
  }
  try {
    buffer.insert(offset, string);
    fireInsertUpdate(offset, string.length());
  } catch (IndexOutOfBoundsException e) {
    throw new BadLocationException(e.getMessage(), offset);
  }
}

代码示例来源:origin: org.armedbear.lisp/abcl

@Override
public void remove(int offs, int len) throws BadLocationException {
 synchronized(reader) {
  int bufferStart = getLength() - inputBuffer.length();
  if(offs < bufferStart) {
   throw new BadLocationException("Can only remove after " + bufferStart, offs);
  }
  super.remove(offs, len);
  inputBuffer.delete(offs - bufferStart, offs - bufferStart + len);
 }
}

代码示例来源:origin: io.github.dheid/wings

@Override
public void remove(int offset, int length) throws BadLocationException {
  if (length == 0) {
    return;
  }
  try {
    buffer.delete(offset, offset + length);
    fireRemoveUpdate(offset, length);
  } catch (IndexOutOfBoundsException e) {
    throw new BadLocationException(e.getMessage(), offset);
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

private void checkOffsetInDoc(int offset) throws BadLocationException {
  checkOffsetNonNegative(offset);
  if (offset > docLen()) {
    throw new BadLocationException("Invalid offset=" + offset // NOI18N
      + " > docLen=" + docLen(), offset); // NOI18N
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

private void checkOffsetInContent(int offset) throws BadLocationException {
  checkOffsetNonNegative(offset);
  if (offset > length()) {
    throw new BadLocationException("Invalid offset=" + offset // NOI18N
      + " > (docLen+1)=" + docLen(), offset); // NOI18N
  }
}

代码示例来源:origin: protegeproject/protege

public void insertChars(int position, final char cbuf[], final int off, final int len) throws BadLocationException {
    if (position > length() || position < 0) {
      throw new BadLocationException("Invalid insert", length());
    }
    if (off == 0) {
      replace(position, 0, cbuf, len);
    } else {
      char tmp[] = new char[len];
      System.arraycopy(cbuf, off, tmp, 0, len);
      replace(position, 0, tmp, len);
    }
  }
}

代码示例来源:origin: com.fifesoft/rsyntaxtextarea

public char charAt(int offset) throws BadLocationException {
  if (offset<0 || offset>=length()) {
    throw new BadLocationException("Invalid offset", offset);
  }
  int g0 = getGapStart();
  char[] array = (char[]) getArray();
  if (offset<g0) { // below gap
    return array[offset];
  }
  return array[getGapEnd() + offset - g0]; // above gap
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-editor-document

private void checkBoundsInContent(int offset, int length) throws BadLocationException {
  checkOffsetNonNegative(offset);
  checkLengthNonNegative(length);
if (offset + length > length()) {
  throw new BadLocationException("Invalid (offset=" + offset + " + length=" + length + // NOI18N
        ")=" + (offset+length) + " > (docLen+1)=" + length(), offset + length); // NOI18N
}
}

相关文章