當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.getCharacterOffset方法代碼示例

本文整理匯總了Java中javax.xml.stream.Location.getCharacterOffset方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.getCharacterOffset方法的具體用法?Java Location.getCharacterOffset怎麽用?Java Location.getCharacterOffset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.xml.stream.Location的用法示例。


在下文中一共展示了Location.getCharacterOffset方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: LocationImpl

import javax.xml.stream.Location; //導入方法依賴的package包/類
LocationImpl(Location loc){
    systemId = loc.getSystemId();
    publicId = loc.getPublicId();
    lineNo = loc.getLineNumber();
    colNo = loc.getColumnNumber();
    charOffset = loc.getCharacterOffset();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:8,代碼來源:LocationImpl.java

示例2: addLocation

import javax.xml.stream.Location; //導入方法依賴的package包/類
static boolean addLocation(Document doc, Node node,
                           XMLStreamReader reader,
                           boolean recordLoc) {
    if (recordLoc) {
        Location loc = reader.getLocation();
        if (loc != null && (loc.getColumnNumber() != 0 || loc.getLineNumber() != 0)) {
            try {
                final int charOffset = loc.getCharacterOffset();
                final int colNum = loc.getColumnNumber();
                final int linNum = loc.getLineNumber();
                final String pubId = loc.getPublicId() == null ? doc.getDocumentURI() : loc.getPublicId();
                final String sysId = loc.getSystemId() == null ? doc.getDocumentURI() : loc.getSystemId();
                Location loc2 = new Location() {
                    @Override
                    public int getCharacterOffset() {
                        return charOffset;
                    }

                    @Override
                    public int getColumnNumber() {
                        return colNum;
                    }

                    @Override
                    public int getLineNumber() {
                        return linNum;
                    }

                    @Override
                    public String getPublicId() {
                        return pubId;
                    }

                    @Override
                    public String getSystemId() {
                        return sysId;
                    }
                };
                node.setUserData("location", loc2, new UserDataHandler() {
                    @Override
                    public void handle(short operation, String key, Object data, Node src, Node dst) {
                        if (operation == NODE_CLONED) {
                            dst.setUserData(key, data, this);
                        }
                    }
                });
            } catch (Exception ex) {
                //possibly not DOM level 3, won't be able to record this then
                return false;
            }
        }
    }
    return recordLoc;
}
 
開發者ID:Legostaev,項目名稱:xmlsec-gost,代碼行數:55,代碼來源:StAX2DOM.java


注:本文中的javax.xml.stream.Location.getCharacterOffset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。