public void setTranslated(String translated) { getOrCreateTranslation().setValue(translated); }
/** * Creates and returns a new {@link Property} based on key and value inputs.<br> */ private static Property newProperty(String key, String value) { Property property = PropertiesFactory.eINSTANCE.createProperty(); property.setKey(key); property.setValue(value); return property; }
if(matcher.matches()) property.setValue(matcher.group(1).replace("\\n", "\n")); return property;
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { boolean template = false; URL url = new URL("http://pootle.locamotion.org/export/terminology/de/essential.po"); InputStream openStream = url.openStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(openStream, "UTF-8")); Property property = null; POHelper helper = new POHelper(); PropertyFile file = PropertiesFactory.eINSTANCE.createPropertyFile(); while((property=helper.readProperty(reader))!=null) { if(template) property.setValue(property.getKey()); file.getProperties().add(property); } PropertiesResourceImpl resource = new PropertiesResourceImpl(org.eclipse.emf.common.util.URI.createFileURI("messages.properties")); resource.getContents().add(file); resource.save(new HashMap<Object, Object>()); }
private void createMessageFile(InputStream in, URI target, boolean isTemplate) throws IOException { BufferedReader reader = null; try { reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); Property property = null; POHelper helper = new POHelper(); PropertyFile file = PropertiesFactory.eINSTANCE.createPropertyFile(); while((property=helper.readProperty(reader))!=null) { if(isTemplate) { property.setValue(property.getKey()); //get rid of the german comment property.setComment(null); } file.getProperties().add(property); } PropertiesResourceImpl resource = new PropertiesResourceImpl(target); resource.getContents().add(file); resource.save(new HashMap<Object, Object>()); } catch (UnsupportedEncodingException e) { LOGGER.error(e.getMessage(),e); } finally { reader.close(); } }
property.setValue(parts[1]); checkedForHeader = true; return property;
Property property = PropertiesFactory.eINSTANCE.createProperty(); property.setKey(key); property.setValue(translationDoc.get(QueryService.FIELD_VALUE)); property.setComment(translationDoc.get(QueryService.FIELD_COMMENT)); PropertyFileDescriptor slave = queryService.getDescriptor(translationDoc);
current.setValue(currentValue.toString());
/** * If we make it here, we know that the {@link Property} exists in the master * {@link PropertyFileDescriptor}, but we don't know if a corresponding {@link Property} exists * for the existing {@link PropertyFile}. If it does not, we create a new {@link Property}.<br> * * Hence perform a quick check, and create a new {@link Property} which we add to this * {@link PropertyFileDescriptor} if it does not yet exist.<br> */ private static void updateExistingProperty(PropertyFile existingFile, Property existingProperty, Property newProperty) { if (existingProperty == null) { existingProperty = PropertiesFactory.eINSTANCE.createProperty(); existingProperty.setKey(newProperty.getKey()); existingFile.getProperties().add(existingProperty); } existingProperty.setValue(newProperty.getValue()); existingProperty.setComment(newProperty.getComment()); }
@Override protected void onSubmit() { super.onSubmit(); IModel<List<? extends PropertyPair>> model = getModel(); List<? extends PropertyPair> list = model.getObject(); PropertyFileDescriptor descriptor = PropertyEditorPanel.this.getModelObject(); PropertyFile file = descriptor.loadProperties(); Map<String, Property> map = file.asMap(); for (PropertyPair pair : list) { Property translation = pair.getTranslation(); if(translation==null) continue; if (map.containsKey(translation.getKey())) { Property property = map.get(translation.getKey()); property.setComment(translation.getComment()); property.setValue(translation.getValue()); } else file.getProperties().add(translation); } propertyPersistence.saveProperties(descriptor, file); getSession().info("Saved successfully"); try { //TODO: this is very unclean... // give it some time to store the values Thread.sleep(500); } catch (InterruptedException e) { logger.error("Interrupted while waiting for property persistence",e); } } };
Property property = map.get(translation.getKey()); property.setComment(translation.getComment()); property.setValue(translation.getValue()); } else if (!isEmpty(translation.getValue())) { file.getProperties().add(translation);
origProp.setValue(newProp.getValue()); origProp.setComment(newProp.getComment());