| | |
| | | import de.uhilger.mediaz.App; |
| | | import de.uhilger.mediaz.Server; |
| | | import de.uhilger.mediaz.entity.Ablageort; |
| | | import de.uhilger.mediaz.entity.Abspieler; |
| | | import de.uhilger.mediaz.entity.Einstellung; |
| | | import java.io.BufferedReader; |
| | | import java.io.File; |
| | |
| | | /** StorageType Ablageort */ |
| | | public static final String ST_ABLAGEORT = "Ablageort"; |
| | | public static final String ST_EINSTELLUNG = "Einstellung"; |
| | | public static final String ST_ABSPIELER = "Abspieler"; |
| | | |
| | | private final String fileBase; |
| | | |
| | |
| | | // Beispiel: TypeToken<List<String>> list = new TypeToken<List<String>>() {}; |
| | | TypeToken<Ablageort> ttAblageort = new TypeToken<Ablageort>() {}; |
| | | TypeToken<Einstellung> ttEinstellung = new TypeToken<Einstellung>() {}; |
| | | TypeToken<Abspieler> ttAbspieler = new TypeToken<Abspieler>() {}; |
| | | types = new HashMap(); |
| | | types.put(Ablageort.class.getSimpleName(), ttAblageort); |
| | | types.put(Einstellung.class.getSimpleName(), ttEinstellung); |
| | | types.put(Abspieler.class.getSimpleName(), ttAbspieler); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public TypeToken typeFromName(String name) { |
| | | return types.get(name); |
| | |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public List<Entity> listObjects(String typ) { |
| | | File base = new File(fileBase); |
| | | File dir = new File(base, typ); |
| | | List<Entity> list = new ArrayList(); |
| | | File[] files = dir.listFiles(); |
| | | if(files != null) { |
| | | for(File file : files) { |
| | | try { |
| | | list.add(entityFromFile(file)); |
| | | } catch (ClassNotFoundException | IOException ex) { |
| | | logger.log(Level.SEVERE, null, ex); |
| | | } |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |