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


Java EntityException类代码示例

本文整理汇总了Java中com.ximpleware.EntityException的典型用法代码示例。如果您正苦于以下问题:Java EntityException类的具体用法?Java EntityException怎么用?Java EntityException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: processExcelRequest

import com.ximpleware.EntityException; //导入依赖的package包/类
/**
 * Method used to process the whole request.
 * 
 * @param resID unique ID of resource
 * @param requestType designator of URI scheme
 * @param sheetName name of sheet
 * @param reference table, column, row or cell reference
 * @param xssfReader package reader of POI
 * @return list of values as {@code ValueExchangeExt}
 * @throws EncodingException
 * @throws EOFException
 * @throws EntityException
 * @throws InvalidFormatException not an OOXML file
 * @throws ParseException error during parsing
 * @throws IOException can't open file
 * @throws XPathParseException error during parsing
 * @throws XPathEvalException error during XPath evaluation
 * @throws NavException error during XML navigation
 */
private ValueExchangeExt processExcelRequest(String resID, String requestType,
        String sheetName, String reference, XSSFReader xssfReader) throws EncodingException,
        EOFException, EntityException, InvalidFormatException, ParseException, IOException,
        XPathParseException, XPathEvalException, NavException {
    ValueExchangeExt valList = new ValueExchangeExt();

    this.sstData = new SharedStringsData(xssfReader);
    StylesTable styles = xssfReader.getStylesTable();
    InputStream workBook = xssfReader.getWorkbookData();

    LinkedHashMap<String, InputStream> sheets = getSheets(workBook, xssfReader, sheetName);

    String xpathExp = buildXPathExp(reference);
    Boolean allSheets = sheetName.equals("*");

    if (allSheets) {
        valList.setBaseURI("/" + resID + "/" + requestType + "/");
    } else {
        valList.setBaseURI("/" + resID + "/" + requestType + "/"
                + URLEncoder.encode(sheetName, "US-ASCII") + "/");
    }

    // iterate sheets for evaluation
    for (String curSheetName : sheets.keySet()) {
        String pathPrefix = "";
        if (allSheets)
            pathPrefix = URLEncoder.encode(curSheetName, "US-ASCII");
        InputStream sheetIS = sheets.get(curSheetName);
        byte[] sheet = IOUtils.toByteArray(sheetIS);
        // evaluate XPath expression for current sheet
        valList.addValues(evalSheet(sheet, xpathExp, reference, styles, pathPrefix));
    }
    return valList;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:54,代码来源:DataExcelVtdResource.java

示例2: getSheets

import com.ximpleware.EntityException; //导入依赖的package包/类
/**
 * Method to get all sheets from which data was requested.
 * 
 * @param workBook excel document
 * @param xssfReader package reader of POI
 * @param sheetName name of excel sheet
 * @return list of sheets as {@code LinkedHashMap<String, InputStream>}
 * @throws IOException can't open file
 * @throws EncodingException
 * @throws EOFException
 * @throws EntityException
 * @throws ParseException
 * @throws XPathParseException
 * @throws XPathEvalException
 * @throws NavException
 * @throws InvalidFormatException not an OOXML file
 */
private LinkedHashMap<String, InputStream> getSheets(InputStream workBook,
        XSSFReader xssfReader, String sheetName) throws IOException, EncodingException,
        EOFException, EntityException, ParseException, XPathParseException, XPathEvalException,
        NavException, InvalidFormatException {

    LinkedHashMap<String, InputStream> sheets = new LinkedHashMap<String, InputStream>();
    String relationshipNS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships";
    VTDGen wbkVg = new VTDGen();
    byte[] wbByteArr = IOUtils.toByteArray(workBook);
    wbkVg.setDoc(wbByteArr);
    wbkVg.parse(true);
    VTDNav wbVn = wbkVg.getNav();
    AutoPilot wbAp = new AutoPilot(wbVn);

    wbAp.declareXPathNameSpace("r", relationshipNS);

    if (sheetName.equals("*")) {
        wbAp.selectXPath("/workbook/sheets/sheet");
    } else {
        wbAp.selectXPath("/workbook/sheets/sheet[@name=\"" + sheetName + "\"]");
    }

    while (wbAp.evalXPath() != -1) {

        String relId = wbVn.toRawString(wbVn.getAttrValNS(relationshipNS, "id"));
        String curSheetName = wbVn.toRawString(wbVn.getAttrVal("name"));
        sheets.put(curSheetName, xssfReader.getSheet(relId));
    }

    if (sheets.isEmpty()) {
        throw new WebApplicationException(404);
    }

    return sheets;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:53,代码来源:DataExcelVtdResource.java

示例3: SharedStringsData

import com.ximpleware.EntityException; //导入依赖的package包/类
public SharedStringsData(XSSFReader xssfReader) throws InvalidFormatException, IOException,
        EncodingException, EOFException, EntityException, ParseException {
    VTDGen sstVg = new VTDGen();
    byte[] sstData = IOUtils.toByteArray(xssfReader.getSharedStringsData());
    sstVg.setDoc(sstData);
    sstVg.parse(true);
    sstVn = sstVg.getNav();
    sstAp = new AutoPilot(sstVn);
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:10,代码来源:DataExcelVtdResource.java

示例4: processTextParagraphs

import com.ximpleware.EntityException; //导入依赖的package包/类
/**
 * Processing of requests to text paragraphs
 * 
 * @param document main XML document as byte array
 * @param resID resource ID to set BaseURI
 * @param paragraphRef position of requested paragraph (start at 0)
 * @return list of values as {@code ValueExchangeExt}
 * @throws EncodingException
 * @throws EOFException
 * @throws EntityException
 * @throws ParseException
 * @throws XPathParseException
 * @throws NavException
 * @throws XPathEvalException
 */
private ValueExchangeExt processTextParagraphs(byte[] document, String resID,
        String requestType, String paraRef) throws EncodingException, EOFException,
        EntityException, ParseException, XPathParseException, XPathEvalException, NavException {
    ValueExchangeExt valList = new ValueExchangeExt();
    valList.setBaseURI("/" + resID + "/" + requestType + "/");
    VTDGen vg = new VTDGen();
    vg.setDoc(document);
    vg.parse(true);
    VTDNav vn = vg.getNav();
    AutoPilot ap = new AutoPilot(vn);
    declareNameSpaces(ap);

    setStartEndParagraph(paraRef, "*");

    // element list for evaluation of subtree
    ArrayList<String> elements = new ArrayList<String>();
    elements.add("w:p");

    // list of according indexes of subtree elements, "*" if all elements
    ArrayList<EvalRange> elementIndex = new ArrayList<EvalRange>();
    elementIndex.add(new EvalRange(this.startPara, this.endPara));

    // XPath expression for evaluation
    String xpathExp = "/w:document/w:body";
    ap.selectXPath(xpathExp);
    // prefix to build subURI
    String pathPrefix = new String();
    while (ap.evalXPath() != -1) {
        // evaluate subtree of selected node
        valList.addValues(evalSubTree(ap, vn, elements, elementIndex, 0, pathPrefix));
    }

    return valList;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:50,代码来源:DataWordVtdResource.java

示例5: evalSheet

import com.ximpleware.EntityException; //导入依赖的package包/类
/**
 * Method that evaluates the XPath expression for a single worksheet.
 * 
 * @param sheetAp VTD auto pilot for XPath evaluation
 * @param sheetVn VTD navigator
 * @param sharedStrings - shared string table of excel document
 * @param styles styles table of excel document
 * @param pathPrefix prefix of subURI
 * @return list of sheet values as {@code LinkedList<Value>}
 * @throws EncodingException
 * @throws EOFException
 * @throws EntityException
 * @throws ParseException
 * @throws XPathEvalException
 * @throws NavException
 * @throws XPathParseException
 */
private LinkedList<Value> evalSheet(byte[] sheet, String xpathExp, String reference,
        StylesTable styles, String pathPrefix) throws EncodingException, EOFException,
        EntityException, ParseException, XPathEvalException, NavException, XPathParseException {

    LinkedList<Value> sheetValues = new LinkedList<Value>();

    // setup VTD
    VTDGen sheetVg = new VTDGen();
    sheetVg.setDoc(sheet);
    sheetVg.parse(true);
    VTDNav sheetVn = sheetVg.getNav();
    AutoPilot sheetAp = new AutoPilot(sheetVn);
    sheetAp.selectXPath(xpathExp);

    // evaluate XPath and select cells
    // a cell can hold information about location (reference), value, data
    // type, formatting, and formula
    while (sheetAp.evalXPath() != -1) {
        // move to first cell
        if (sheetVn.toElement(VTDNav.FIRST_CHILD)) {
            // iterate cells
            while (moveToSibling(sheetVn, "c")) {
                Value cellValue = null;
                String cellRef = "";
                if (sheetVn.hasAttr("r")) {
                    cellRef = sheetVn.toRawString(sheetVn.getAttrVal("r"));
                    if (this.tableArea.getColStart() == -1) {
                        cellValue = evalCell(sheetVn, styles, cellRef, pathPrefix);
                    } else {
                        // replaces empty character between letters and
                        // digits with ";" and split both parts
                        String[] cellRefTokens = cellRef.replaceAll("(?<=\\p{L})(?=\\d)", ";")
                                .split(";");
                        Integer colID = ResourceHelper.convertColRefToColNum(cellRefTokens[0]);
                        if (this.tableArea.getColStart() <= colID
                                && colID <= this.tableArea.getColEnd()) {
                            cellValue = evalCell(sheetVn, styles, cellRef, pathPrefix);
                        }
                    }
                }

                // add value to list
                if (cellValue != null)
                    sheetValues.add(cellValue);

                // stop if no other siblings
                if (!sheetVn.toElement(VTDNav.NEXT_SIBLING)) {
                    break;
                }
            }
            // move back to cell
            sheetVn.toElement(VTDNav.PARENT);
        }
    }

    return sheetValues;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:75,代码来源:DataExcelVtdResource.java

示例6: executeImport

import com.ximpleware.EntityException; //导入依赖的package包/类
/***
 * 将已解析XML文件导入到库中
 * @param srcLang
 *            TMX源语言
 * @param vtdUtils
 *            封装的VTD解析工具
 * @throws SQLException
 * @throws NavException
 * @throws XPathParseException
 * @throws XPathEvalException
 *             ;
 * @throws ParseException
 * @throws EntityException
 * @throws EOFException
 * @throws EncodingException
 * @throws IOException
 * @throws ModifyException
 * @throws TranscodeException
 */
protected abstract void executeImport(String srcLang) throws SQLException, NavException, XPathParseException,
		XPathEvalException, EncodingException, EOFException, EntityException, ParseException, TranscodeException,
		ModifyException, IOException, ImportException;
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:23,代码来源:ImportAbstract.java


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