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


Java NavException类代码示例

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


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

示例1: VersionTransferWriter

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * Constructs a new instance of this class. During construction, the file
 * specified will be read and stored in a buffer.
 * 
 * @param file
 *            File to be read, must not be {@code null}
 * @throws IOException
 * @throws TranscodeException
 * @throws NavException
 * @throws ModifyException
 */
public VersionTransferWriter(final File pFile, final String pOwnVersionOrNull)
		throws IOException, ModifyException, NavException, TranscodeException {
	notNull(pFile, "File specified is null");
	file = pFile;
	insertVersionIntoOriginalIfNecessary(pOwnVersionOrNull);

	final char[] buffer = new char[1024];
	try (final Reader rd = new BufferedReader(new FileReader(file))) {
		int readChars = rd.read(buffer);
		while (readChars != -1) {
			original.append(buffer, 0, readChars);
			readChars = rd.read(buffer);
		}
	}

}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:28,代码来源:VersionTransferWriter.java

示例2: insertVersionIntoOriginalIfNecessary

import com.ximpleware.NavException; //导入依赖的package包/类
private void insertVersionIntoOriginalIfNecessary(final String pOwnVersionOrNull)
		throws ModifyException, NavException, UnsupportedEncodingException, IOException, TranscodeException {
	if (pOwnVersionOrNull != null) {
		final VTDGen gen = new VTDGen();
		gen.enableIgnoredWhiteSpace(true);
		final XMLModifier modifier = new XMLModifier();

		if (gen.parseFile(file.getAbsolutePath(), false)) {
			final VTDNav vn = gen.getNav();
			modifier.bind(vn);

			if (vn.toElement(FC, ARTIFACT_ID)) {
				final long l = vn.expandWhiteSpaces(vn.getElementFragment(), WS_LEADING);
				final ByteArrayOutputStream out = new ByteArrayOutputStream();
				vn.dumpFragment(l, out);
				final String version = new String(out.toByteArray()).replaceAll(ARTIFACT_ID_PATTERN,
						format(VERSION_FORMAT, pOwnVersionOrNull));
				modifier.insertAfterElement(version);
			}
		}

		try (final FileOutputStream out = new FileOutputStream(file)) {
			modifier.output(out);
		}
	}
}
 
开发者ID:SourcePond,项目名称:release-maven-plugin-parent,代码行数:27,代码来源:VersionTransferWriter.java

示例3: getTransUnitContext

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 通过rowId获取当前翻译单元的上下文
 * @param rowId 
 * @param num 上下文个数
 * @return ;
 */
public Map<String, String> getTransUnitContext(String rowId, int num) {

	Map<String, String> result = new HashMap<String, String>();
	if (tuSizeMap == null || rowId == null) {
		return null;
	}

	VTDUtils vu = null;
	VTDNav vn = getVTDNavByRowId(rowId);
	try {
		vu = new VTDUtils(vn);
	} catch (NavException e1) {
		String errorMsg = Messages.getString("qa.QAXmlHandler.logger21");
		logger.error(errorMsg, e1);
		return null;
	}
	AutoPilot ap = new AutoPilot(vu.getVTDNav());
	result.put("x-preContext", getContext(vu, ap, num, true));
	result.put("x-nextContext", getContext(vu, ap, num, false));
	return result;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:28,代码来源:QAXmlHandler.java

示例4: parseCorefs

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * Assumes the position of vn is at a "DOC" tag
 */
private List<AgigaCoref> parseCorefs(VTDNav vn) throws PilotException, NavException {
    require (vn.matchElement(AgigaConstants.DOC));
    
    List<AgigaCoref> agigaCorefs = new ArrayList<AgigaCoref>();
    if (!vn.toElement(VTDNav.FIRST_CHILD, AgigaConstants.COREFERENCES)) {
        // If there is no coref annotation return the empty list
        log.finer("No corefs found");
        return agigaCorefs;
    }

    // Loop through each token
    AutoPilot corefAp = new AutoPilot(vn);
    corefAp.selectElement(AgigaConstants.COREFERENCE);
    while (corefAp.iterate()) {
        AgigaCoref coref = parseCoref(vn.cloneNav());
        agigaCorefs.add(coref);
    }
    return agigaCorefs;
}
 
开发者ID:mgormley,项目名称:agiga,代码行数:23,代码来源:AgigaDocumentReader.java

示例5: buildCharsets

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * Builds the charsets.
 * @throws SAXException
 *             the SAX exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 * @throws NavException
 */
private void buildCharsets() throws SAXException, IOException, NavException {
	SAXBuilder builder = new SAXBuilder();
	Document doc = builder.build(programFoler + "ini/rtf_encodings.xml"); //$NON-NLS-1$
	charsets = new Hashtable<String, String>();
	Element root = doc.getRootElement();
	List<Element> list = root.getChildren("encoding"); //$NON-NLS-1$
	Iterator<Element> it = list.iterator();
	while (it.hasNext()) {
		Element e = it.next();
		charsets.put(e.getAttributeValue("codePage"), getEncoding(e.getText().trim())); //$NON-NLS-1$
	}
	// VTDGen vg = new VTDGen();
	// vg.parseFile(programFoler + "ini/rtf_encodings.xml", false);
	// VTDNav vn = vg.getNav();
	// VTDUtils vu = new VTDUtils(vn);
	// AutoPilot ap = new AutoPilot(vn);
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:ImportRTFToXLIFF.java

示例6: moveToSibling

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * Moves the cursor to an element (sibling) with given name and position
 * (the nth element with he same name starting to count at 0)
 * 
 * @param vtdNav vtdXML navigator
 * @param elementName name of element
 * @param skipElements index of element starting with 0
 * @return true if element found
 * @throws NavException
 */
private boolean moveToSibling(VTDNav vtdNav, String elementName, Integer skipElements)
        throws NavException {
    boolean foundElement = false;
    // counter for elements with elementName
    Integer currentPosition = 0;
    // iterate siblings until element found or no other siblings
    do {
        // break if element with position found and return true
        if (vtdNav.matchTokenString(vtdNav.getCurrentIndex(), elementName)) {
            if (skipElements == currentPosition) {
                foundElement = true;
                break;
            }
            currentPosition++;
        }
    } while (vtdNav.toElement(VTDNav.NEXT_SIBLING));
    return foundElement;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:29,代码来源:DataWordVtdResource.java

示例7: approveTransUnits

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 批准或取消批准指定Id的翻译单元
 * @param rowIdList
 *            要修改的翻译单元Id的集合;
 * @param approve
 *            true:批准;false:取消批准;
 * @throws XliffException
 */
public List<String> approveTransUnits(List<String> rowIdList, final boolean approve, final boolean checkTargetWidth) {
	if (rowIdList == null || rowIdList.isEmpty()) {
		return Collections.<String> emptyList();
	}
	final ArrayList<String> list = new ArrayList<String>();
	handleSomeSegment(rowIdList, new PerSegmentHandler() {
		public void handle(String rowId, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws XPathParseException,
				XPathEvalException, NavException, ModifyException, UnsupportedEncodingException {
			String tuXPath = RowIdUtil.parseRowIdToXPath(rowId); // 根据RowId得到定位到该翻译单元的XPath
			if (vu.pilot(ap, tuXPath) != -1) {
				String approvedValue = approve ? "yes" : "no";
				changeApproveProp(vu.getVTDNav(), approvedValue, xm);
			}
		}
	});
	return list;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:XLFHandler.java

示例8: approveAllTransUnits

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 批准或取消批准所有的翻译单元
 * @param approve
 *            true:批准;false:取消批准;
 */
public List<String> approveAllTransUnits(final boolean approve, final boolean checkTargetWidth) {
	final ArrayList<String> list = new ArrayList<String>();
	handleAllSegment(new PerFileHandler() {
		public void handle(String fileName, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws ModifyException,
				XPathParseException, XPathEvalException, NavException, UnsupportedEncodingException {
			ap.selectXPath(XPATH_ALL_TU);
			while (ap.evalXPath() != -1) {
				String approvedValue = approve ? "yes" : "no";
				changeApproveProp(vu.getVTDNav(), approvedValue, xm);
			}
			saveAndReparse(xm, fileName); // 保存并更新VTDNav对象
		}
	});
	return list;
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:21,代码来源:XLFHandler.java

示例9: getNotes

import com.ximpleware.NavException; //导入依赖的package包/类
private Vector<NoteBean> getNotes(VTDUtils vu) throws XPathEvalException, NavException, XPathParseException {
	Vector<NoteBean> notes = new Vector<NoteBean>();
	VTDNav vn = vu.getVTDNav();
	AutoPilot ap = new AutoPilot(vn);
	ap.declareXPathNameSpace("xml", VTDUtils.XML_NAMESPACE_URL);
	ap.declareXPathNameSpace(hsNSPrefix, hsR7NSUrl);
	ap.selectXPath("./note");
	while (ap.evalXPath() != -1) {
		NoteBean note = new NoteBean(vu.getElementContent());
		note.setLang(vu.getCurrentElementAttribut("xml:lang", null));
		note.setFrom(vu.getCurrentElementAttribut("from", null));
		note.setPriority(vu.getCurrentElementAttribut("priority", null));
		note.setAnnotates(vu.getCurrentElementAttribut("annotates", null));
		note.setApplyCurrent(vu.getCurrentElementAttribut("hs:apply-current", "Yes"));

		notes.add(0, note);
	}

	if (notes.isEmpty()) {
		notes = null;
	}

	return notes;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:XLFHandler.java

示例10: changeTranslateProp

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 改变translate属性的值
 * @param translateValue
 *            可选值:“yes”、“no”
 * @param xm
 *            XMLModifier对象;
 * @throws NavException
 * @throws UnsupportedEncodingException
 * @throws ModifyException
 * @throws XPathParseException
 * @throws XPathEvalException
 */
private boolean changeTranslateProp(VTDNav vn, String translateValue, XMLModifier xm) throws NavException,
		ModifyException, UnsupportedEncodingException, XPathParseException, XPathEvalException {
	if (translateValue == null) {
		return false;
	}

	vn.push();
	boolean isChanged = false; // 当前的TransUnit的translate属性是否执行了修改
	int attrIdx = vn.getAttrVal("translate");
	if (attrIdx != -1) { // 存在translate属性
		String translate = vn.toString(attrIdx);
		if (!translate.equals(translateValue)) { // translate属性值不为指定的translateValue
			xm.updateToken(attrIdx, translateValue);
			isChanged = true;
		}
	} else {
		xm.insertAttribute(" translate=\"" + translateValue + "\" ");
		if (translateValue.equals("no")) { // 默认值为yes
			isChanged = true;
		}
	}
	vn.pop();
	return isChanged;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:37,代码来源:XLFHandler.java

示例11: deleteAltTrans

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 删除匹配
 * @param rowIds
 *            行的唯一标识集合;
 */
public void deleteAltTrans(List<String> rowIds) {
	handleSomeSegment(rowIds, new PerSegmentHandler() {
		public void handle(String rowId, VTDUtils vu, AutoPilot ap, XMLModifier xm) throws XPathParseException,
				XPathEvalException, NavException, ModifyException {
			String tuXPath = RowIdUtil.parseRowIdToXPath(rowId); // 根据RowId得到定位到该翻译单元的XPath
			// vu.delete(ap, xm, tuXPath + "/alt-trans", VTDUtils.PILOT_TO_END);
			if (vu.pilot(ap, tuXPath) == -1) {
				return;
			}
			ap.selectXPath("./alt-trans");
			while (ap.evalXPath() != -1) {
				xm.remove();
			}
		}
	});
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:22,代码来源:XLFHandler.java

示例12: getTransUnitContext

import com.ximpleware.NavException; //导入依赖的package包/类
/**
 * 通过rowId获取当前翻译单元的上下文
 * @param rowId
 * @param num
 *            上下文个数
 * @return ;
 */
public Map<String, String> getTransUnitContext(String rowId, int num) {

	Map<String, String> result = new HashMap<String, String>();
	if (tuSizeMap == null || rowId == null) {
		return null;
	}

	VTDUtils vu = null;
	VTDNav vn = getVTDNavByRowId(rowId);
	try {
		vu = new VTDUtils(vn);
		String tuXpath = RowIdUtil.parseRowIdToXPath(rowId);
		vu.pilot(tuXpath);
	} catch (NavException e1) {
		String errorMsg = Messages.getString("file.XLFHandler.logger4");
		LOGGER.error(errorMsg, e1);
		return null;
	}
	AutoPilot ap = new AutoPilot(vu.getVTDNav());
	result.put("x-preContext", getContext(vu, ap, num, true));
	result.put("x-nextContext", getContext(vu, ap, num, false));
	return result;
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:31,代码来源:XLFHandler.java

示例13: main

import com.ximpleware.NavException; //导入依赖的package包/类
public static void main(String[] args) throws XPathParseException, XPathEvalException, NavException {
		TSFileHandler ts = new TSFileHandler();
		VTDGen vg = new VTDGen();
		if (vg
				.parseFile(
						"/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf",
						true)) {
			ts.openFile("/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf");
			System.out.println(ts.getSourceLanguage(3));
			System.out.println(ts.getTargetLanguage(3));
//			System.out
//					.println(ts
//							.analysisTranslatorProgress(
//									vg.getNav(),
//									"/data/john/Workspaces/Other/net.heartsome.cat.ts.core/testSrc/net/heartsome/cat/ts/core/file/test/Test.txt.xlf",
//									0));
		}

	}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:20,代码来源:TSFileHandler.java

示例14: testGetCurrentElementAttributs1Param

import com.ximpleware.NavException; //导入依赖的package包/类
@Test
public void testGetCurrentElementAttributs1Param() throws XPathParseException, XPathEvalException, NavException{
	AutoPilot ap = new AutoPilot(vn);
	ap.selectXPath("//trans-unit[position()=2]");
	ap.evalXPath();
	
	Hashtable<String,String> eAtts = new Hashtable<String,String>();
	eAtts.put("approved","yes");
	eAtts.put("id","1");
	eAtts.put("merged-trans","yes");
	eAtts.put("reformat","yes");
	eAtts.put("size-unit","pixel");
	eAtts.put("translate","yes");
	eAtts.put("xml:space","preserve");
	eAtts.put("hs:ext","yes");
	eAtts.put("xsi:test", "test");
	
	Hashtable<String,String> aAtts = vu.getCurrentElementAttributs("es","http://www.heartsome.net.cn/2008/XLFExtension");
	assertEquals(eAtts,aAtts);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:21,代码来源:VTDUtilsTest.java

示例15: testGetCurrentElementAttributs2Params

import com.ximpleware.NavException; //导入依赖的package包/类
@Test
public void testGetCurrentElementAttributs2Params() throws XPathParseException, XPathEvalException, NavException{
	
	AutoPilot ap = new AutoPilot(vn);
	ap.selectXPath("//trans-unit[position()=2]");
	ap.evalXPath();
	
	Hashtable<String,String> eAtts = new Hashtable<String,String>();
	eAtts.put("approved","yes");
	eAtts.put("id","1");
	eAtts.put("merged-trans","yes");
	eAtts.put("reformat","yes");
	eAtts.put("size-unit","pixel");
	eAtts.put("translate","yes");
	eAtts.put("xml:space","preserve");
	eAtts.put("hs:ext","yes");
	eAtts.put("xsi:test", "test");
	
	Hashtable<String,String> ns = new Hashtable<String,String>();
	ns.put("http://www.heartsome.net.cn/2008/XLFExtension", "es");
	ns.put("http://www.w3.org/2001/XMLSchema-instance", "es");
	Hashtable<String,String> aAtts = vu.getCurrentElementAttributs(ns);
	assertEquals(eAtts,aAtts);
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:25,代码来源:VTDUtilsTest.java


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