"notes" : 579,
"albumType" : "Not-Implemented"
}, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "DEBUT",
- "level" : 8,
- "notes" : 126,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "REGULAR",
- "level" : 12,
- "notes" : 178,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "PRO",
- "level" : 17,
- "notes" : 344,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "MASTER",
- "level" : 25,
- "notes" : 605,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "DEBUT",
- "level" : 8,
- "notes" : 126,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "REGULAR",
- "level" : 12,
- "notes" : 178,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "PRO",
- "level" : 17,
- "notes" : 344,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "cherry*merry*cherry",
- "difficulty" : "MASTER",
- "level" : 25,
- "notes" : 605,
- "albumType" : "Not-Implemented"
- }, {
"attribute" : "パッション",
- "name" : "スパイスパラダイス",
- "difficulty" : "WITCH",
- "level" : 27,
- "notes" : 566,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "パッション",
- "name" : "トロピカルガール",
+ "name" : "Demolish",
"difficulty" : "DEBUT",
"level" : 8,
- "notes" : 104,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "パッション",
- "name" : "トロピカルガール",
- "difficulty" : "REGULAR",
- "level" : 14,
- "notes" : 203,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "パッション",
- "name" : "トロピカルガール",
- "difficulty" : "PRO",
- "level" : 18,
- "notes" : 408,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "パッション",
- "name" : "トロピカルガール",
- "difficulty" : "MASTER",
- "level" : 26,
- "notes" : 694,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "パッション",
- "name" : "トロピカルガール",
- "difficulty" : "MASTER+",
- "level" : 29,
- "notes" : 988,
- "albumType" : "Not-implemented"
- }, {
- "attribute" : "クール",
- "name" : "あこがれステッチ",
- "difficulty" : "LIGHT",
- "level" : 6,
- "notes" : 133,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "クール",
- "name" : "あこがれステッチ",
- "difficulty" : "TRICK",
- "level" : 15,
- "notes" : 319,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "クール",
- "name" : "双翼の独奏歌",
- "difficulty" : "LIGHT",
- "level" : 8,
- "notes" : 172,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "クール",
- "name" : "双翼の独奏歌",
- "difficulty" : "TRICK",
- "level" : 17,
- "notes" : 372,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "かぼちゃ姫",
- "difficulty" : "MASTER+",
- "level" : 29,
- "notes" : 963,
- "albumType" : "ALBUM A"
- }, {
- "attribute" : "全タイプ",
- "name" : "つぼみ",
- "difficulty" : "MASTER+",
- "level" : 28,
- "notes" : 688,
- "albumType" : "ALBUM A"
- }, {
- "attribute" : "パッション",
- "name" : "CoCo夏夏夏 Holiday",
- "difficulty" : "DEBUT",
- "level" : 8,
- "notes" : 127,
+ "notes" : 116,
"albumType" : "Not-Implemented"
}, {
"attribute" : "パッション",
- "name" : "CoCo夏夏夏 Holiday",
+ "name" : "Demolish",
"difficulty" : "REGULAR",
- "level" : 14,
- "notes" : 250,
+ "level" : 13,
+ "notes" : 198,
"albumType" : "Not-Implemented"
}, {
"attribute" : "パッション",
- "name" : "CoCo夏夏夏 Holiday",
+ "name" : "Demolish",
"difficulty" : "PRO",
"level" : 19,
- "notes" : 468,
+ "notes" : 499,
"albumType" : "Not-Implemented"
}, {
"attribute" : "パッション",
- "name" : "CoCo夏夏夏 Holiday",
+ "name" : "Demolish",
"difficulty" : "MASTER",
- "level" : 27,
- "notes" : 819,
+ "level" : 26,
+ "notes" : 727,
"albumType" : "Not-Implemented"
}, {
"attribute" : "パッション",
- "name" : "CoCo夏夏夏 Holiday",
+ "name" : "Demolish",
"difficulty" : "MASTER+",
"level" : 30,
- "notes" : 999,
+ "notes" : 997,
"albumType" : "Not-implemented"
- }, {
- "attribute" : "クール",
- "name" : "堕ちる果実",
- "difficulty" : "MASTER+",
- "level" : 31,
- "notes" : 734,
- "albumType" : "ALBUM B"
- }, {
- "attribute" : "全タイプ",
- "name" : "心もよう",
- "difficulty" : "MASTER+",
- "level" : 26,
- "notes" : 500,
- "albumType" : "ALBUM B"
- }, {
- "attribute" : "キュート",
- "name" : "スローライフ・ファンタジー",
- "difficulty" : "DEBUT",
- "level" : 6,
- "notes" : 80,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "スローライフ・ファンタジー",
- "difficulty" : "REGULAR",
- "level" : 12,
- "notes" : 152,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "スローライフ・ファンタジー",
- "difficulty" : "PRO",
- "level" : 17,
- "notes" : 304,
- "albumType" : "Not-Implemented"
- }, {
- "attribute" : "キュート",
- "name" : "スローライフ・ファンタジー",
- "difficulty" : "MASTER",
- "level" : 25,
- "notes" : 579,
- "albumType" : "Not-Implemented"
} ]
}
\ No newline at end of file
package com.ranfa.lib.io;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
public class FileIO {
+ private static Logger logger = LoggerFactory.getLogger(FileIO.class);
+
// constants
private static final String FILE_NAME_PATTERN = "YYYY-MM-dd-HH-mm-ss";
private static final String FILE_EXTENSION = ".drs";
// fields
- private String songName;
+ /**
+ * songname
+ * level
+ * difficulty
+ * attribute
+ * score
+ */
+ List<Map<String, String>> songList;
+
+
+ public FileIO(List<Map<String, String>> songList) {
+ this.songList = songList;
+ }
public FileIO() {
-
+ this.songList = null;
+ }
+
+ public boolean write() {
+ StringBuilder builder = new StringBuilder(new SimpleDateFormat(FILE_NAME_PATTERN).format(new Date()));
+ builder.append(FILE_EXTENSION);
+ try {
+ ObjectOutputStream outStream = new ObjectOutputStream(new FileOutputStream(builder.toString()));
+ OutputDataStructure structure = new OutputDataStructure(songList);
+ outStream.writeObject(structure);
+ outStream.flush();
+ outStream.close();
+ return true;
+ } catch (IOException e) {
+ logger.error("Exception while output objects", e);
+ return false;
+ }
+ }
+
+ public static OutputDataStructure read(String fileName) {
+ FileInputStream fileInputStream;
+ try {
+ fileInputStream = new FileInputStream(fileName);
+ ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
+ OutputDataStructure structure = (OutputDataStructure) objectInputStream.readObject();
+ objectInputStream.close();
+ return structure;
+ } catch (IOException | ClassNotFoundException e) {
+ logger.error("Exception while reading objects", e);
+ return null;
+ }
}
}
package com.ranfa.lib.io;
import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
public class OutputDataStructure implements Serializable {
private static final long serialVersionUID = 1L;
- private String songName;
- private int level;
- private String difficulty;
+ // fields
+ List<Map<String, String>> songList;
+
+ public OutputDataStructure(List<Map<String, String>> songList) {
+ this.songList = songList;
+ }
+
+ public static long getSerialversionuid() {
+ return serialVersionUID;
+ }
+
+ public List<Map<String, String>> getSongList() {
+ return songList;
+ }
+
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(songList);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof OutputDataStructure)) {
+ return false;
+ }
+ OutputDataStructure other = (OutputDataStructure) obj;
+ return Objects.equals(songList, other.songList);
+ }
+
}
--- /dev/null
+package test;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import com.ranfa.lib.io.FileIO;
+import com.ranfa.lib.io.OutputDataStructure;
+
+import test.mock.ObjectWriteMock;
+
+/**
+ * songname
+ * level
+ * difficulty
+ * attribute
+ * score
+ */
+public class ObjectIOTest {
+
+ private static final String filename = "test.drs";
+ private static Map<String, String> testMap;
+ private static List<Map<String, String>> testList;
+
+ @BeforeClass
+ public static void init() {
+ testMap = new LinkedHashMap<>();
+ testMap.put("songname", "testname001");
+ testMap.put("level", "28");
+ testMap.put("difficulty", "MASTER");
+ testMap.put("attribute", "キュート");
+ testMap.put("score", "1200000");
+ testList = new ArrayList<>();
+ testList.add(testMap);
+ }
+
+
+ @Test
+ public void writeTest() {
+ assertTrue(ObjectWriteMock.write(testList, filename));
+ }
+
+ @Test
+ public void readNonNullTest() {
+ OutputDataStructure structure = FileIO.read(filename);
+ assertNotNull(structure);
+ }
+
+ @Test
+ public void readEqualsTest() {
+ OutputDataStructure structure = FileIO.read(filename);
+ if(structure != null) {
+ assertEquals(new OutputDataStructure(testList), structure);
+ }
+ }
+
+ @AfterClass
+ public static void del() {
+ try {
+ Files.deleteIfExists(Paths.get(filename));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+}
--- /dev/null
+package test.mock;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.util.List;
+import java.util.Map;
+
+import com.ranfa.lib.io.OutputDataStructure;
+
+public class ObjectWriteMock {
+
+ public static boolean write(List<Map<String, String>> songList, String filename) {
+ try {
+ ObjectOutputStream outStream = new ObjectOutputStream(new FileOutputStream(filename));
+ OutputDataStructure structure = new OutputDataStructure(songList);
+ outStream.writeObject(structure);
+ outStream.flush();
+ outStream.close();
+ return true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+}