net.sf.nakeduml.metamodel.mapping.internal.WorkspaceMappingInfoImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of metamodel Show documentation
Show all versions of metamodel Show documentation
A uml code generator and execution engine
The newest version!
package net.sf.nakeduml.metamodel.mapping.internal;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
import net.sf.nakeduml.metamodel.mapping.IMappingInfo;
import net.sf.nakeduml.metamodel.mapping.IWorkspaceMappingInfo;
public class WorkspaceMappingInfoImpl implements IWorkspaceMappingInfo {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#0.000000");
private Properties properties;
private Map mappingInfoMap = new HashMap();
private File file;
private int currentRevision;
private float currentVersion;
private int nakedUmlIdMaxValue;
public WorkspaceMappingInfoImpl() {
this.properties = new Properties();
}
public WorkspaceMappingInfoImpl(File file) {
this();
this.file = file;
if (file.exists()) {
try {
load(new FileReader(file));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
}
}
}
public WorkspaceMappingInfoImpl(Reader reader) {
this();
if (reader!=null) {
load(reader);
}
}
private void load(Reader reader) {
try {
if (reader != null) {
final String CURRENT_VERSION = getClass().getName() + ".currentVersion";
final String CURRENT_REVISION = getClass().getName() + ".currentRevision";
final String NAKED_UML_MAX_VALUE = getClass().getName() + ".nakedUmlIdMaxValue";
Set knownProperties = new HashSet();
knownProperties.add(CURRENT_VERSION);
knownProperties.add(CURRENT_REVISION);
knownProperties.add(NAKED_UML_MAX_VALUE);
properties.load(reader);
currentVersion = DECIMAL_FORMAT.parse(properties.getProperty(CURRENT_VERSION)).floatValue();
currentRevision = Integer.parseInt(properties.getProperty(CURRENT_REVISION));
nakedUmlIdMaxValue = Integer.parseInt(properties.getProperty(NAKED_UML_MAX_VALUE));
Set> entrySet = properties.entrySet();
for (Entry