当前位置: 首页>>代码示例>>Java>>正文


Java BadLocationException.initCause方法代码示例

本文整理汇总了Java中javax.swing.text.BadLocationException.initCause方法的典型用法代码示例。如果您正苦于以下问题:Java BadLocationException.initCause方法的具体用法?Java BadLocationException.initCause怎么用?Java BadLocationException.initCause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.BadLocationException的用法示例。


在下文中一共展示了BadLocationException.initCause方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isRowEmpty

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public static boolean isRowEmpty(CharSequence text, int offset) throws BadLocationException {
    try {
        if (offset < text.length()) {
            char c = text.charAt(offset);
            if (!(c == '\n' || (c == '\r' && (offset == text.length()-1 || text.charAt(offset+1) == '\n')))) {
                return false;
            }
        }

        if (!(offset == 0 || text.charAt(offset-1) == '\n')) {
            // There's previous stuff on this line
            return false;
        }

        return true;
    } catch (Exception ex) {
        BadLocationException ble = new BadLocationException(offset + " out of " + text.length(), offset);
        ble.initCause(ex);
        throw ble;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:GsfUtilities.java

示例2: getRowStart

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public static int getRowStart(CharSequence text, int offset) throws BadLocationException {
    try {
        // Search backwards
        for (int i = offset-1; i >= 0; i--) {
            char c = text.charAt(i);
            if (c == '\n') {
                return i+1;
            }
        }

        return 0;
    } catch (Exception ex) {
        BadLocationException ble = new BadLocationException(offset + " out of " + text.length(), offset);
        ble.initCause(ex);
        throw ble;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GsfUtilities.java

示例3: getRowEnd

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
public static int getRowEnd(CharSequence text, int offset) throws BadLocationException {
    try {
        // Search backwards
        for (int i = offset; i < text.length(); i++) {
            char c = text.charAt(i);
            if (c == '\n') {
                return i;
            }
        }

        return text.length();
    } catch (Exception ex) {
        BadLocationException ble = new BadLocationException(offset + " out of " + text.length(), offset);
        ble.initCause(ex);
        throw ble;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GsfUtilities.java

示例4: getText

import javax.swing.text.BadLocationException; //导入方法依赖的package包/类
/**
 * Get a portion of text of the given document as char sequence.
 * <br>
 *
 * @param doc document for which the charsequence is being obtained.
 * @param offset starting offset of the charsequence to obtain.
 * @param length length of the charsequence to obtain. It must be <code>&gt;= 0</code>
 *   and <code>&lt;doc.getLength() + 1</code>.
 * @return non-null character sequence.
 * @exception BadLocationException some portion of the given range
 *   was not a valid part of the document. The location in the exception
 *   is the first bad position encountered.
 *  <br>
 *  The returned character sequence should only be accessed under
 *  document's readlock (or writelock).
 */
public static CharSequence getText(Document doc, int offset, int length) throws BadLocationException {
    CharSequence text = getText(doc);
    try {
        return text.subSequence(offset, offset + length);
    } catch (IndexOutOfBoundsException e) {
        int badOffset = offset;
        if (offset >= 0 && offset + length > text.length()) {
            badOffset = length;
        }
        BadLocationException ble = new BadLocationException(e.getMessage(), badOffset);
        ble.initCause(e);
        throw ble;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:DocumentUtilities.java


注:本文中的javax.swing.text.BadLocationException.initCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。