67 lines
2.1 KiB
Java
Raw Normal View History

package ProjectElectricLocomotive;
2023-12-05 00:57:00 +04:00
import javax.xml.crypto.dsig.keyinfo.KeyValue;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.List;
public class LocomotivesGenericStorage {
2023-12-05 00:57:00 +04:00
public final char _separatorForKeyValue = '|';
public final char _separatorRecords = ';';
public final char _separatorForObject = ':';
final HashMap<String, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> _locomotiveStorage;
2023-12-05 00:57:00 +04:00
public List<String> Keys() {
return _locomotiveStorage.keySet().stream().toList();
}
2023-12-05 00:57:00 +04:00
private final int _pictureWidth;
private final int _pictureHeight;
2023-12-05 00:57:00 +04:00
public LocomotivesGenericStorage(int pictureWidth, int pictureHeight) {
_locomotiveStorage = new HashMap<>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
2023-12-05 00:57:00 +04:00
public void AddSet(String name) {
if (!(_locomotiveStorage.containsKey(name))) {
_locomotiveStorage.put(name, new LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>(_pictureWidth, _pictureHeight));
}
}
2023-12-05 00:57:00 +04:00
public void DelSet(String name) {
if (_locomotiveStorage.keySet().contains(name)) {
_locomotiveStorage.remove(name);
}
}
2023-12-05 00:57:00 +04:00
public LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive> get(String ind) {
if (_locomotiveStorage.keySet().contains(ind)) {
return _locomotiveStorage.get(ind);
}
return null;
}
2023-12-05 00:57:00 +04:00
public DrawingObjectLocomotive get(String name, int ind) {
if (_locomotiveStorage.keySet().contains(ind)) {
return _locomotiveStorage.get(name).GetU(ind);
}
return null;
}
2023-12-05 00:57:00 +04:00
public boolean SaveData(String filename) {
if (new File(filename).exists()) {
new File(filename).delete();
}
StringBuilder data = new StringBuilder();
// for(KeyValue<String, LocomotiveGenericCollection<DrawingLocomotive, DrawingObjectLocomotive>> record : _locomotiveStorage)
return true;
}
}