| | |
| | | package de.uhilger.mediaz.store; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import de.uhilger.mediaz.App; |
| | | import de.uhilger.mediaz.Server; |
| | | import de.uhilger.mediaz.entity.Ablageort; |
| | |
| | | import java.util.logging.Logger; |
| | | import de.uhilger.mediaz.entity.Entity; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.logging.Level; |
| | | |
| | | /** |
| | |
| | | |
| | | private String fileBase; |
| | | |
| | | private Map<String, TypeToken> types; |
| | | |
| | | public FileStorage(String base) { |
| | | this.fileBase = base; |
| | | |
| | | //TypeToken<List<String>> list = new TypeToken<List<String>>() {}; |
| | | TypeToken<Ablageort> ttAblageort = new TypeToken<Ablageort>() {}; |
| | | types = new HashMap(); |
| | | types.put(Ablageort.class.getSimpleName(), ttAblageort); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | public Entity readFromFile(File file) throws ClassNotFoundException, FileNotFoundException, IOException { |
| | | String type = typeFromName(file); |
| | | String type = typeNameFromPath(file); |
| | | StringBuilder sb = new StringBuilder(); |
| | | FileReader in = new FileReader(file); |
| | | BufferedReader r = new BufferedReader(in); |
| | |
| | | } |
| | | } |
| | | |
| | | private String typeFromName(File file) { |
| | | //String path = file.getPath(); |
| | | //logger.info(path); |
| | | private String typeNameFromPath(File file) { |
| | | String[] parts = file.getPath().split(App.getRs(Server.RB_SLASH)); |
| | | //for(String part : parts) { |
| | | //logger.info(part); |
| | | //} |
| | | //logger.info("" + parts.length); |
| | | logger.info(parts[parts.length-2]); |
| | | return parts[parts.length-2]; |
| | | } |
| | |
| | | return list; |
| | | } |
| | | |
| | | @Override |
| | | public TypeToken typeFromName(String name) { |
| | | return types.get(name); |
| | | } |
| | | |
| | | |
| | | |
| | | } |