/** * Clones this property. * @return a new property object that is a copy of this one. */ public Property clone () { Property prop = new Property(name, value, isReadOnly); //TODO: copy annotations?? prop.annotations = annotations.clone(); return prop; }
protected void writeAllPropertiesAsAttibutes (XMLWriter writer, Set<String> names, TextContainer item) { // Write any TUV-level properties as attributes (but only standard attributes) for ( String name : names ) { if (ATTR_NAMES.contains(";"+name+";") && !name.equals("tuid")) { writer.writeAttributeString(name, item.getProperty(name).getValue()); } } }
/** * Add tu-level property. If property (name) already exists the new property value is appended to the existing one. * @param prop Property to add. */ void addProp(Property prop){ Property existingProp = getProp(prop.getName()); if(existingProp!=null){ existingProp.setValue(existingProp.getValue() + sep + prop.getValue()); }else{ propsBefore.add(prop); } }
/** * toString() for debugging purposes * @return Combined string */ public String toString(){ StringBuilder sb = new StringBuilder(); sb.append("-----TmxTu-----\n"); sb.append("Skeleton Before: "+skelBefore+"\n"); for (Property p : propsBefore) sb.append("Property Name: "+p.getName()+" Property Value: "+p.getValue()+"\n"); for (TmxTuv tuv : tuvs){ sb.append(tuv.toString()); } sb.append("Skeleton After: "+skelAfter+"\n"); return sb.toString(); } }
|| oneIsNulll(p1.getName(),p2.getName(),"compareProperty","Property Name") || oneIsNulll(p1.getValue(),p2.getValue(),"compareProperty","Property Value")){ return false; if( !bothAreNull(p1.getName(),p2.getName()) ){ if (!p1.getName().equals(p2.getName())) { LOGGER.warn("compareProperty warning: Property name difference."); return false; if( !bothAreNull(p1.getValue(),p2.getValue()) ){ if (!p1.getValue().equals(p2.getValue())) { LOGGER.warn("compareProperty warning: Property value difference. [prop name:{}\tval p1:{}\tval p2:{}]", p1.getName(), p1.getValue(), p2.getValue()); return false; if (p1.isReadOnly() != p2.isReadOnly()) { LOGGER.warn("compareProperty warning: isReadOnly difference."); return false;
@Override public Property createTargetProperty (LocaleId locId, String name, boolean overwriteExisting, int creationOptions) { // Get the target or create an isEmpty one TextContainer tc = createTarget(locId, false, CREATE_EMPTY); // Get the property if it exists Property prop = tc.getProperty(name); // If it does not exists or if we overwrite: create a new one if (( prop == null ) || overwriteExisting ) { // Get the source property prop = getSource().getProperty(name); if ( prop == null ) { // If there is no source, create an isEmpty property return tc.setProperty(new Property(name, "", false)); } else { // If there is a source property // Create a copy, isEmpty or not depending on the options if ( creationOptions == CREATE_EMPTY ) { return tc.setProperty(new Property(name, "", prop.isReadOnly())); } else { return tc.setProperty(prop.clone()); } } } return prop; }
mid = data.indexOf('='); Property prop = new Property(data.substring(0, mid), data.substring(mid+1), false); dp.setProperty(prop); skel.addValuePlaceholder(dp, prop.getName(), LocaleId.EMPTY); start = n2+1; tu.setProperty(new Property(Property.NOTE, locNote)); tu.setProperty(new Property(Property.TRANSNOTE, transNote)); tu.setProperty(new Property(PROPERTY_REFERENCES, references)); tu.setProperty(new Property(PROPERTY_CONTEXT, msgContext)); tc.setContent(toAbstract(new TextFragment(tmp.toString()))); if ( !hasFuzzyFlag ) { tu.setTargetProperty(trgLang, new Property(Property.APPROVED, "yes", true));
scalarFlow = resource.getProperty(YamlFilter.YAML_SCALAR_FLOW_PROPERTY_NAME); scalarParentIndent = resource.getProperty(YamlFilter.YAML_PARENT_INDENT_PROPERTY_NAME); flow = scalarFlow.getBoolean(); fullIndent = Integer.parseInt(scalarParentIndent.getValue()); if (flow) { flowStyle = FlowStyle.FLOW; encoder.setScalarType(YamlScalarTypes.valueOf(scalarType.getValue()));
/** * Get tu-level property with specified name. * @param name Name of property to retrieve. Null if it can't be found. */ Property getProp(String name){ for (Property p : propsBefore) if(p.getName().equals(name)){ return p; } return null; }
@Override public TextPart clone() { TextPart tp = new TextPart(text.clone()); // Clone the properties if ( this.properties != null ) { tp.properties = new LinkedHashMap<String, Property>(); for ( Property prop : this.properties.values() ) { tp.properties.put(prop.getName(), prop.clone()); } } // clone annotations if (annotations != null) { tp.annotations = annotations.clone(); } return tp; }
deScore1to2Prop.setValue(String.format("%03d", edScore1to2)); fmScore1to2Prop.setValue(String.format("%03d", fmScore1to2)); tmxTu.setTargetProperty(targetLocale2Extra, deScore1to2Prop); tmxTu.setTargetProperty(targetLocale2Extra, fmScore1to2Prop); if ( filter3 != null ) { tmxTu.setTargetContent(targetLocale3Extra, trgFrag3); deScore1to3Prop.setValue(String.format("%03d", edScore1to3)); fmScore1to3Prop.setValue(String.format("%03d", fmScore1to3)); tmxTu.setTargetProperty(targetLocale3Extra, deScore1to3Prop); tmxTu.setTargetProperty(targetLocale3Extra, fmScore1to3Prop);
tu.setProperty(prop.clone());
@Override public String processTextUnit(ITextUnit tu) { if (tu.hasProperty(CommaSeparatedValuesFilter.PROP_QUALIFIED) && "yes".equals(tu.getProperty(CommaSeparatedValuesFilter.PROP_QUALIFIED).getValue())) { return super.processTextUnit(tu); tc.setContent(tf); tu.setProperty(new Property(CommaSeparatedValuesFilter.PROP_QUALIFIED, "yes"));
/** * Synchronize the value of the tool property on the StartSubDocument * event with the XML representation of this annotation. * @param startSubDoc the {@link StartSubDocument} event */ public void updateToolProperty(StartSubDocument startSubDoc) { Property toolPlaceholder = (startSubDoc.getProperty(Property.XLIFF_TOOL) == null) ? new Property(Property.XLIFF_TOOL, "") : startSubDoc.getProperty(Property.XLIFF_TOOL); toolPlaceholder.setValue(toXML()); }
for (String n : props) { Property p = startDocument.getProperty(n); if ("note".equalsIgnoreCase(p.getName())) { writer.writeStartElement("note"); writer.writeString(p.getValue()); writer.writeEndElement(); } else { writer.writeStartElement("prop"); writer.writeAttributeString("type", p.getName()); writer.writeString(p.getValue()); writer.writeEndElement();