本文整理汇总了Java中com.ximpleware.VTDNav.getTokenType方法的典型用法代码示例。如果您正苦于以下问题:Java VTDNav.getTokenType方法的具体用法?Java VTDNav.getTokenType怎么用?Java VTDNav.getTokenType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ximpleware.VTDNav
的用法示例。
在下文中一共展示了VTDNav.getTokenType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initTmxVersion
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
private void initTmxVersion(VTDNav vn) throws NavException {
vn.toElement(VTDNav.ROOT);
int rootIdx = vn.getCurrentIndex();
if (vn.toString(rootIdx).equalsIgnoreCase("tmx")) {
int t = vn.getAttrVal("version");
if (t != -1) {
tmxVersion = vn.toString(t);
}
}
for (int i = 0; i < rootIdx; i++) {
int ty = vn.getTokenType(i);
if (ty == VTDNav.TOKEN_DTD_VAL) {
doctypeContent = vn.toString(i);
}
}
}
示例2: ananysisSubTag
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 处理 sub 标记
* @param vn
* @param textMap
*/
private void ananysisSubTag(VTDNav vn, Map<Integer, String> textMap, Map<Integer, SectionSegBean> targetMap) throws Exception{
vn.push();
String style = "";
int attrIdx = -1;
if ((attrIdx = vn.getAttrVal("rPr")) != -1) {
style = vn.toString(attrIdx);
}
String extendNodes = "";
if ((attrIdx = vn.getAttrVal("extendNodes")) != -1) {
extendNodes = vn.toString(attrIdx);
}
AutoPilot curAP = new AutoPilot(vn);
curAP.selectXPath("./node()|text()");
while(curAP.evalXPath() != -1){
int index = vn.getCurrentIndex();
int tokenType = vn.getTokenType(index);
if (tokenType == 0) { //节点子节点
String nodeName = vn.toString(index);
if ("ph".equals(nodeName)) {
textMap.put(index, resetCleanStr(vu.getElementContent()));
}else if ("g".equals(nodeName)) {
ananysisTag(vn, targetMap);
}else if ("sub".equals(nodeName)) {
ananysisSubTag(vn, textMap, targetMap);
}
}else if (tokenType == 5) { //文本子节点
StringBuffer textSB = new StringBuffer();
textSB.append("<w:r>" + style + extendNodes);
textSB.append("<w:t xml:space=\"preserve\">" + resetCleanStr(vn.toRawString(index)) + "</w:t></w:r>");
textMap.put(index, textSB.toString());
}
}
vn.pop();
}
示例3: ananysisTag
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
private void ananysisTag(Map<Integer, String[]> targetMap) throws VTDException {
VTDNav vn = vu.getVTDNav();
vn.push();
int idex = vn.getCurrentIndex();
String tagName = vn.toString(idex);
if ("g".equals(tagName)) {
String ctype = vu.getCurrentElementAttribut("ctype", null);
String rpr = vu.getCurrentElementAttribut("rPr", "");
AutoPilot ap = new AutoPilot(vn);
ap.selectXPath("./node() | text()");
while (ap.evalXPath() != -1) {
idex = vn.getCurrentIndex();
int tokenType = vn.getTokenType(idex);
if (tokenType == 0) {
String name = vu.getCurrentElementName();
if ("ph".equals(name)) {
targetMap.put(idex, new String[] { vu.getElementContent(), rpr, ctype });
} else if ("g".equals(name)) {
ananysisTag(targetMap);
}
} else if (tokenType == 5) {
targetMap.put(idex, new String[] { vn.toRawString(idex), rpr, ctype });
}
}
} else if ("ph".equals(tagName)) {
targetMap.put(idex, new String[] { vu.getElementContent(), null, null });
} else { // 其他节点,一律当做字符串处理
targetMap.put(idex, new String[] { vu.getElementFragment(), null, null });
}
vn.pop();
}
示例4: initSpreadAllStory
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 加载 designmap.xml 文件,初始化 lstSpread 和 lstAllStory
* @throws XPathParseException
* @throws XPathEvalException
* @throws NavException
* ;
*/
private void initSpreadAllStory(IProgressMonitor monitor) throws XPathParseException, XPathEvalException,
NavException {
monitor.beginTask("", 1);
monitor.subTask(MessageFormat.format(Messages.getString("idml.IDML2XLIFF.task5"), "designmap.xml"));
VTDGen vg = new VTDGen();
if (vg.parseZIPFile(strSrcPath, "designmap.xml", true)) {
VTDNav vn = vg.getNav();
AutoPilot ap = new AutoPilot(vn);
ap.declareXPathNameSpace(IDML_PREFIX, IDML_NAMESPACE);
ap.selectXPath("/Document/node()");
while (ap.evalXPath() != -1) {
int curIndex = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIndex);
String name = vn.toString(curIndex);
// 节点
if (tokenType == 0) {
if (name.equals("idPkg:Spread")) {
String strSpread = vn.toString(vn.getAttrVal("src"));
lstSpread.add(strSpread);
} else if (name.equals("idPkg:Story")) {
String strStory = vn.toString(vn.getAttrVal("src"));
lstAllStory.add(strStory);
} else if (name.equals("idPkg:MasterSpread")) {
String strMasterSpread = vn.toString(vn.getAttrVal("src"));
lstMasterSpread.add(strMasterSpread);
}
}
}
}
monitor.worked(1);
monitor.done();
}
示例5: anaysisTgtOrSrcNode
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 分析 source 或 target 节点,获取其内容
* @throws Exception
*/
private void anaysisTgtOrSrcNode(StringBuffer textSB, VTDNav vn, boolean isText) throws Exception {
vn.push();
AutoPilot otherAP = new AutoPilot(vn);
String childXpath = "./text()|node()";
otherAP.selectXPath(childXpath);
int tokenId = -1;
int index = -1;
Map<Integer, SectionSegBean> targetMap = new TreeMap<Integer, SectionSegBean>();
while (otherAP.evalXPath() != -1) {
index = vn.getCurrentIndex();
tokenId = vn.getTokenType(index);
if (tokenId == 0) { //节点子节点
ananysisTag(vn, targetMap);
}else if (tokenId == 5) { // 文本子节点
// if ("+1 845-536-1416".equals(vn.toString(index))) {
// System.out.println("问题开始了。。。。");
// }
targetMap.put(index, new SectionSegBean(null, vn.toRawString(index), null, null, null));
}
}
vn.pop();
SectionSegBean bean;
for (Entry<Integer, SectionSegBean> entry : targetMap.entrySet()) {
bean = entry.getValue();
if (isText) {
if (bean.getText() != null) {
textSB.append(bean.getText());
}
}else {
// 这个要组装 w:r 等节点
String ctype = bean.getCtype() == null ? "" : bean.getCtype();
String style = bean.getStyle() == null ? "" : bean.getStyle();
String extendNodes = bean.getExtendNodesStr() == null ? "" : bean.getExtendNodesStr();
if (bean.getPhTagStr() != null) {
textSB.append(bean.getPhTagStr());
}else {
if ("".equals(ctype)) {
textSB.append("<w:r>" + style + extendNodes);
textSB.append("<w:t xml:space=\"preserve\">" + bean.getText() + "</w:t></w:r>");
}else {
// <w:hyperlink r:id="rId8" w:history="1">
int endIdx = ctype.indexOf(" ") == -1 ? ctype.indexOf(">") : ctype.indexOf(" ");
String nodeName = ctype.substring(ctype.indexOf("<") + 1, endIdx);
textSB.append(ctype);
textSB.append("<w:r>" + style + extendNodes);
textSB.append("<w:t xml:space=\"preserve\">" + bean.getText() + "</w:t></w:r>");
textSB.append("</" + nodeName + ">");
}
}
}
}
}
示例6: analysisChildOfSrcTuv
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 分析tuv节点下面的所有节点,获取出要翻译的文本段
*/
private void analysisChildOfSrcTuv(Map<Integer, TextBean> textMap, VTDNav vn, VTDUtils vu) throws Exception {
vn.push();
AutoPilot ap = new AutoPilot(vn);
String xpath = "./node()|text()";
ap.selectXPath(xpath);
int index = -1;
while (ap.evalXPath() != -1) {
int curIdx = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIdx);
// 等于0表示为节点
if (tokenType == 0) {
// 如果这个节点还有子节点。那么遍历其子节点
if (vu.getChildElementsCount() > 0) {
analysisChildOfSrcTuv(textMap, vn, vu);
} else {
String nodeName = vu.getCurrentElementName();
if ("df".equals(nodeName)) {
// df节点下的数据,直接加载。
if ((index = vn.getText()) != -1) {
sklXM.updateToken(index, "%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toRawString(index), true));
tagId++;
}
} else if ("ut".equals(nodeName)) {
// ut节点下保存的是cf标记信息,要将它进行转义
if ((index = vn.getText()) != -1) {
// 这种情况,为cf标记
if (vn.getAttrVal("DisplayText") != -1
&& "cf".equals(sklVN.toString(vn.getAttrVal("DisplayText")))) {
textMap.put(index, new TextBean(-1, vn.toString(index), false));
} else {
// 处理除cf之外的其他标记,如symbol,这时一般当文本处理
sklXM.remove();
sklXM.insertBeforeElement("%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toString(index), false));
tagId++;
}
}
}
}
} else if (tokenType == 5) { // 等于5表示为文本子节点
index = vn.getCurrentIndex();
sklXM.updateToken(index, "%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toRawString(index), true));
tagId++;
}
}
vn.pop();
}
示例7: analysisChildOfTgtTuv
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 分析译文tuv节点下面的所有节点,获取出要翻译的文本段,但不占位,只获取文本
*/
private void analysisChildOfTgtTuv(Map<Integer, TextBean> tgtTextMap, VTDNav vn, VTDUtils vu) throws Exception {
vn.push();
AutoPilot ap = new AutoPilot(vn);
String xpath = "./*|text()";
ap.selectXPath(xpath);
int index = -1;
while (ap.evalXPath() != -1) {
int curIdx = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIdx);
// 等于0表示为节点
if (tokenType == 0) {
// 如果这个节点还有子节点。那么遍历其子节点
if (vu.getChildElementsCount() > 0) {
analysisChildOfTgtTuv(tgtTextMap, vn, vu);
} else {
String nodeName = vu.getCurrentElementName();
if ("df".equals(nodeName)) {
// df节点下的数据,直接加载。
if ((index = vn.getText()) != -1) {
tgtTextMap.put(index, new TextBean(-1, vn.toRawString(index), true));
}
} else if ("ut".equals(nodeName)) {
// ut节点下保存的是cf标记信息,要将它进行转义
if ((index = vn.getText()) != -1) {
if (vn.getAttrVal("Type") != -1) {
tgtTextMap.put(index, new TextBean(-1, vn.toString(index), false));
} else {
// 若 ut 节点没有 Type 属性,一般为除cf之外的其他标记,如symbol,这时一般当文本处理
tgtTextMap.put(index, new TextBean(-1, vn.toString(index), false));
}
}
}
}
} else if (tokenType == 5) { // 等于5表示为文本子节点
index = vn.getCurrentIndex();
tgtTextMap.put(index, new TextBean(-1, vn.toRawString(index), true));
}
}
vn.pop();
}
示例8: analysisDF
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 处理一个单元格区间的每一个节点,
* @return true:调用此方法的程序继续执行, false:调用此方法的程序终止执行或跳出当前循环
*/
private void analysisDF(VTDNav vn, SegmentBean segBean) throws Exception{
vn.push();
AutoPilot ap = new AutoPilot(vn);
String xpath = "./node()|text()";
ap.selectXPath(xpath);
int index = -1;
while(ap.evalXPath() != -1){
int tokenType = vn.getTokenType(vn.getCurrentIndex());
if (tokenType == 0) { //等于0表示为节点
String nodeName = vu.getCurrentElementName();
if ("ut".equals(nodeName)) {
String typeAtt = "";
if ((index = vn.getAttrVal("Type")) != -1) {
typeAtt = vn.toRawString(index);
}
String displayTextAtt = "";
if ((index = vn.getAttrVal("DisplayText")) != -1) {
displayTextAtt = vn.toRawString(index);
}
//判断开始与结束点
if ("start".equals(typeAtt) && !"cf".equals(displayTextAtt)) {
start = true; //一个单元的开始
end = false;
}else if ("end".equals(typeAtt) && !"cf".equals(displayTextAtt)) {
start = false;
end = true; // 一个单元的结束
}
segBean.setTagStr(vu.getElementFragment());
needAdd = true;
}else if ("Tu".equals(nodeName)) { //遇到 Tu 节点,单元结束,end = true,但是 start仍保持之前状态
needAdd = false;
end = true;
}
segBean.setHasTag(true); //有标记存在
}else if (tokenType == 5) { //等于5表示为文本子节点
segBean.setSegment(vn.toRawString(vn.getCurrentIndex()));
System.out.println(vn.toRawString(vn.getCurrentIndex()));
needAdd = true;
}
}
vn.pop();
}
示例9: analysisChildOfSrcTuv
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 分析tuv节点下面的所有节点,获取出要翻译的文本段
*/
private void analysisChildOfSrcTuv(Map<Integer, TextBean> textMap, VTDNav vn, VTDUtils vu) throws Exception{
vn.push();
AutoPilot ap = new AutoPilot(vn);
String xpath = "./node()|text()";
ap.selectXPath(xpath);
int index = -1;
while (ap.evalXPath() != -1) {
int curIdx = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIdx);
//等于0表示为节点
if (tokenType == 0) {
//如果这个节点还有子节点。那么遍历其子节点
if (vu.getChildElementsCount() > 0) {
analysisChildOfSrcTuv(textMap, vn, vu);
}else {
String nodeName = vu.getCurrentElementName();
if ("df".equals(nodeName)) {
//df节点下的数据,直接加载。
if ((index = vn.getText()) != -1) {
sklXM.updateToken(index, "%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toRawString(index), true));
tagId++;
}
}else if ("ut".equals(nodeName)) {
//ut节点下保存的是cf标记信息,要将它进行转义
if ((index = vn.getText()) != -1) {
//这种情况,为cf标记
if (vn.getAttrVal("DisplayText") != -1 && "cf".equals(sklVN.toString(vn.getAttrVal("DisplayText")))) {
textMap.put(index, new TextBean(-1, vn.toString(index), false));
}else {
// 处理除cf之外的其他标记,如symbol,这时一般当文本处理
sklXM.remove();
sklXM.insertBeforeElement("%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toString(index), false));
tagId ++;
}
}
}
}
}else if (tokenType == 5) { //等于5表示为文本子节点
index = vn.getCurrentIndex();
sklXM.updateToken(index, "%%%" + tagId + "%%%");
textMap.put(index, new TextBean(tagId, vn.toRawString(index), true));
tagId++;
}
}
vn.pop();
}
示例10: analysisChildOfTgtTuv
import com.ximpleware.VTDNav; //导入方法依赖的package包/类
/**
* 分析译文tuv节点下面的所有节点,获取出要翻译的文本段,但不占位,只获取文本
*/
private void analysisChildOfTgtTuv(Map<Integer, TextBean> tgtTextMap, VTDNav vn, VTDUtils vu) throws Exception{
vn.push();
AutoPilot ap = new AutoPilot(vn);
String xpath = "./*|text()";
ap.selectXPath(xpath);
int index = -1;
while (ap.evalXPath() != -1) {
int curIdx = vn.getCurrentIndex();
int tokenType = vn.getTokenType(curIdx);
//等于0表示为节点
if (tokenType == 0) {
//如果这个节点还有子节点。那么遍历其子节点
if (vu.getChildElementsCount() > 0) {
analysisChildOfTgtTuv(tgtTextMap, vn, vu);
}else {
String nodeName = vu.getCurrentElementName();
if ("df".equals(nodeName)) {
//df节点下的数据,直接加载。
if ((index = vn.getText()) != -1) {
tgtTextMap.put(index, new TextBean(-1, vn.toRawString(index), true));
}
}else if ("ut".equals(nodeName)) {
//ut节点下保存的是cf标记信息,要将它进行转义
if ((index = vn.getText()) != -1) {
if (vn.getAttrVal("Type") != -1) {
tgtTextMap.put(index, new TextBean(-1, vn.toString(index), false));
}else {
// 若 ut 节点没有 Type 属性,一般为除cf之外的其他标记,如symbol,这时一般当文本处理
tgtTextMap.put(index, new TextBean(-1, vn.toString(index), false));
}
}
}
}
}else if (tokenType == 5) { //等于5表示为文本子节点
index = vn.getCurrentIndex();
tgtTextMap.put(index, new TextBean(-1, vn.toRawString(index), true));
}
}
vn.pop();
}