/** * tuvToMonoLingualObject converts a given tuv element into a MoonLingualObject * * @param tuv the tuv Element * @return the MonoLingualObject for the given tuv */ public MonoLingualObject tuvToMonoLingualObject(Element tuv) { // get the attributes, props and notes LinguisticProperties linguisticProperties = createLinguisticProperties(tuv); LinguisticProperty tuProp = new LinguisticProperty("tuv", tuv); String segment = this.elementContentToString(this.getSeg(tuv)); String plainTextSegment = MonoLingualObject.simpleComputePlainText(segment); MonoLingualObject mono = new MonoLingualObject( linguisticProperties, LinguisticTypes.TMX, segment, plainTextSegment, this.getTuvLang(tuv)); String uniquidvalue = (String) linguisticProperties.search("unique-id"); if ((uniquidvalue != null) && !uniquidvalue.equals("")) { mono.setStUniqueID(uniquidvalue); } String stlastAccessTime = (String) linguisticProperties.search("lastAccessTime"); if ((stlastAccessTime != null) && !stlastAccessTime.equals("")) { try { long lastAccessTime = Long.parseLong(stlastAccessTime); mono.setLastAccessTime(lastAccessTime); } catch (NumberFormatException e) { } } mono.addLinguisticProperty(tuProp); return mono; }
/** * tuToMultiLingualObject converts a given tu element into a MultiLingualObject * * @param tu the tu Element * @return the MultiLingualObject for the given tu */ public MultiLingualObject tuToMultiLingualObject(Element tu) { LinguisticProperties linguisticProperties = createLinguisticProperties(tu); MultiLingualObject multi = new MultiLingualObject(linguisticProperties, LinguisticTypes.TMX); LinguisticProperty tuProp = new LinguisticProperty("tu", tu); multi.addLinguisticProperty(tuProp); String uniquidvalue = (String) linguisticProperties.search("unique-id"); if ((uniquidvalue != null) && !uniquidvalue.equals("")) { multi.setStUniqueID(uniquidvalue); } String stlastAccessTime = (String) linguisticProperties.search("lastAccessTime"); if ((stlastAccessTime != null) && !stlastAccessTime.equals("")) { try { long lastAccessTime = Long.parseLong(stlastAccessTime); multi.setLastAccessTime(lastAccessTime); } catch (NumberFormatException e) { } } List<Element> tuvs = this.getTuvList(tu); for (int i = 0; i < tuvs.size(); i++) { MonoLingualObject mono = tuvToMonoLingualObject(tuvs.get(i)); if (mono != null) multi.addMonoLingualObject(mono); } return multi; }