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


Java VTDGen.clear方法代码示例

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


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

示例1: openSubFiles

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
private void openSubFiles(IProgressMonitor monitor) throws Exception {
	if (subFiles == null || subFiles.size() == 0) {
		throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
	}
	if (monitor == null) {
		monitor = new NullProgressMonitor();
	}
	monitor.beginTask("", subFiles.size());
	VTDGen vg = new VTDGen();
	for (String file : subFiles) {
		if (monitor.isCanceled()) {
			throw new OperationCanceledException();
		}
		File f = new File(file);
		if (!f.exists() || f.isDirectory()) {
			throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
		}
		parseFile(vg, f, new SubProgressMonitor(monitor, 1));
		VTDUtils vu = new VTDUtils(vg.getNav());
		vus.put(file, vu);
		tuTotalNumber += countFileTuNumber(vu);
		vg.clear();
	}
	monitor.done();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:26,代码来源:TmxLargeFileContainer.java

示例2: validateTmxAndParseHeader

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * Validate TMX Format,and pilot to Body XMLElement
 * @param vg
 * @throws TmxReadException
 *             ;
 */
private void validateTmxAndParseHeader(VTDGen vg) throws TmxReadException {
	VTDNav vn = vg.getNav();
	AutoPilot ap = new AutoPilot(vn);
	String rootPath = "/tmx";
	vu = new VTDUtils();
	try {
		vu.bind(vn);
		ap.selectXPath(rootPath);
		if (ap.evalXPath() == -1) {
			throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError"));
		}
		ap.resetXPath();
		ap.selectXPath("/tmx/header");
		if (ap.evalXPath() == -1) {
			throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError"));
		}
		int id = vu.getVTDNav().getAttrVal("srclang");
		if (id == -1) {
			throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError"));
		}
		header.setSrclang(vu.getVTDNav().toString(id).trim());

		if (vu.pilot("/tmx/body") == -1) {
			throw new TmxReadException(Messages.getString("document.TmxReader.validateTmxFileError"));
		}
		// compute total tu number
		this.totalTu = vu.getChildElementsCount();
	} catch (VTDException e) {
		logger.error("", e);
		throw new TmxReadException(Messages.getString("document.TmxReader.parseTmxFileError") + e.getMessage());
	} finally {
		vg.clear();
	}
}
 
开发者ID:heartsome,项目名称:translationstudio8,代码行数:41,代码来源:TmxReader.java

示例3: parseFileWithVTD

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
/**
 * Parse current TMX file with VTD
 * @return <code>VTDUtils<code>
 * @throws Exception
 *             A set of VTD parse exception;
 */
public void parseFileWithVTD() throws Exception {
	File f = new File(this.filePath);
	if (!f.exists() || f.isDirectory()) {
		throw new FileNotFoundException(Messages.getString("tmxdata.TmxFileContainer.parseTmxFileNotFound"));
	}
	VTDGen vg = parseFile(f);
	vu = new VTDUtils(vg.getNav());
	loadTmxHeader(vu);
	getTUIndexCache(true);
	vg.clear();
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:18,代码来源:TmxFileContainer.java

示例4: run

import com.ximpleware.VTDGen; //导入方法依赖的package包/类
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
	File2TmxConvertBean convertBean = getConvertBean();
	try {
		checkConvertBean(convertBean);
		if (convertBean.newTmxFilePath != null) {
			final File fileTemp = new File(convertBean.newTmxFilePath);
			final boolean[] r = new boolean[1];
			if (fileTemp.exists()) {
				Display.getDefault().syncExec(new Runnable() {
					@Override
					public void run() {
						r[0] = OpenMessageUtils.openConfirmMessage(MessageFormat.format(
								Messages.getString("dialog.TmxConvert2FileDialog.overwriteFile"),
								fileTemp.getName()));
					}
				});
				if (!r[0]) {
					return;
				}
			}
		}
		// TODO Auto-generated method stub
		AbstractFile2Tmx file2TmxConverter = ConverterFactory.getFile2TmxConverter(convertBean.sourceFilePath);
		monitor.beginTask("", 100);
		monitor.setTaskName(Messages.getString("dialog.Convert2TmxDialog.convert.task.msg1"));
		SubProgressMonitor clearUnableCharSub = new SubProgressMonitor(monitor, 10);
		SubProgressMonitor sub = new SubProgressMonitor(monitor, 90);

		if (null != convertBean.appendExistTmxFilePath) {
			clearUnableCharSub.beginTask("", 100);
			clearUnableCharSub.worked(40);
			VTDGen newVg = TmxUtil.clearUnableParseChars(convertBean.appendExistTmxFilePath);
			clearUnableCharSub.done();
			if (null == newVg) {
				clearUnableCharSub.done();
				throw new Exception(
						Messages.getString("dialog.Convert2TmxDialog.converter.common.appendtmx.wrongTmx"));
			}
			newVg.clear();
		} else {
			sub = new SubProgressMonitor(monitor, 100);
		}
		file2TmxConverter.doCovnerter(convertBean, sub);
	} catch (Exception e) {
		LOGGER.error("convert error", e);
		if (convertBean.newTmxFilePath != null) {
			File file = new File(convertBean.newTmxFilePath);
			file.delete();
		}
		throw new InterruptedException(MessageFormat.format(
				Messages.getString("dialog.Convert2TmxDialog.convert.task.error"), e.getMessage()));
	} finally {
		monitor.done();
	}
}
 
开发者ID:heartsome,项目名称:tmxeditor8,代码行数:57,代码来源:Convert2TmxDialog.java


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