{"action":"created","comment":{"url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/comments/23999195","id":23999195,"diff_hunk":"@@ -0,0 +1,113 @@\n+package ru.fizteh.fivt.students.AndrewTimokhin.FileMap.DataBase;\n+\n+import java.io.DataOutputStream;\n+import java.io.File;\n+import java.io.FileOutputStream;\n+import java.io.IOException;\n+import java.util.Set;\n+import static java.lang.Math.abs;\n+import java.nio.file.Path;\n+import java.nio.file.Paths;\n+import java.util.ArrayList;\n+\n+/**\n+ * Класс @class Writer отвечает за физическую запись информации с на жесткий\n+ * диск или другой носитель информации. Логика работы устойчива к новым папкам и\n+ * т.д.\n+ *\n+ * @author Timokhin Andrew\n+ */\n+public class Writer {\n+\n+    final int totalSubDir = 16;\n+    final String dirct = \".dir\";\n+\n+    boolean checkDir(String name) {\n+        File tmpFile = new File(name);\n+        return tmpFile.exists();\n+\n+    }\n+\n+    void createDir(String path) {\n+        File tmpDir = new File(path);\n+        tmpDir.mkdir();\n+        return;\n+    }\n+\n+    void createFile(String path) throws IOException {\n+\n+        File tmpFile = new File(path);\n+        File prepareToMakeDir = new File(tmpFile.getParent().toString());\n+        prepareToMakeDir.mkdirs();\n+        tmpFile.createNewFile();\n+        return;\n+    }\n+\n+    public void deleteDirectory(File dir) {\n+        if (dir.isDirectory()) {\n+            String[] children = dir.list();\n+            for (int i = 0; i < children.length; i++) {\n+                File tmpFile = new File(dir, children[i]);\n+                deleteDirectory(tmpFile);\n+            }\n+            dir.delete();\n+        } else {\n+            dir.delete();\n+        }\n+    }\n+\n+    public void write(TableProviderImplements tp) throws IOException, KeyNullAndNotFound {\n+        this.deleteDirectory(new File(tp.getDir()));\n+        File baseDir = new File(tp.getDir());\n+        baseDir.mkdir();\n+        if (tp.getAvailableTables() != null) {\n+            Set<String> dataBase = tp.getAvailableTables();\n+            for (String name : dataBase) {\n+                TableImplement ti = (TableImplement) tp.getTable(name);\n+                Path pathToDb = Paths.get(tp.getDir(), ti.getName());\n+                File dataBaseDir = new File(pathToDb.toString());\n+                dataBaseDir.mkdir();\n+                {\n+                    ArrayList<String> keyList;\n+                    keyList = (ArrayList<String>) ti.list();\n+                    for (String keyFind : keyList) {\n+                        Integer dirToWrite = new Integer(abs(keyFind.hashCode()\n+                                % totalSubDir));\n+                        Path localPath = Paths.get(tp.getDir(), ti.getName(),\n+                                dirToWrite.toString() + dirct);\n+                        if (!this.checkDir(localPath.toString())) {\n+                            this.createDir(localPath.toString());\n+                        }\n+                        dirToWrite = new Integer((ti.get(keyFind)\n+                                .hashCode()\n+                                % totalSubDir % totalSubDir));\n+                        Path localFile = Paths.get(localPath.toString(),\n+                                dirToWrite.toString());\n+                        File checkIfExist = new File(localFile.toString());\n+                        if (!this.checkDir(localFile.toString())\n+                                && !checkIfExist.exists()) {\n+\n+                            this.createFile(localFile.toString());\n+                        }\n+                        DataOutputStream outStream = new DataOutputStream(\n+                                new FileOutputStream(localFile.toString(), true));\n+                        outStream.writeInt(keyFind.length());\n+                        outStream.writeChars(keyFind);\n+                        try {\n+                            outStream.writeInt(ti.get(keyFind).toString()\n+                                    .length());\n+                            outStream.writeChars(ti.get(keyFind)","path":"src/ru/fizteh/fivt/students/AndrewTimokhin/FileMap/DataBase/Writer.java","position":99,"original_position":99,"commit_id":"44da6c6251b5aea6f398d1e122a28d7d606bb29d","original_commit_id":"44da6c6251b5aea6f398d1e122a28d7d606bb29d","user":{"login":"AndrewTimokhin","id":8937830,"avatar_url":"https://avatars.githubusercontent.com/u/8937830?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewTimokhin","html_url":"https://github.com/AndrewTimokhin","followers_url":"https://api.github.com/users/AndrewTimokhin/followers","following_url":"https://api.github.com/users/AndrewTimokhin/following{/other_user}","gists_url":"https://api.github.com/users/AndrewTimokhin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewTimokhin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewTimokhin/subscriptions","organizations_url":"https://api.github.com/users/AndrewTimokhin/orgs","repos_url":"https://api.github.com/users/AndrewTimokhin/repos","events_url":"https://api.github.com/users/AndrewTimokhin/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewTimokhin/received_events","type":"User","site_admin":false},"body":"нет не повтор. тут логика, без которой перестает работать","created_at":"2015-02-03T12:06:43Z","updated_at":"2015-02-03T12:06:43Z","html_url":"https://github.com/dkomanov/fizteh-java-2014/pull/598#discussion_r23999195","pull_request_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598","_links":{"self":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/comments/23999195"},"html":{"href":"https://github.com/dkomanov/fizteh-java-2014/pull/598#discussion_r23999195"},"pull_request":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598"}}},"pull_request":{"url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598","id":27636787,"html_url":"https://github.com/dkomanov/fizteh-java-2014/pull/598","diff_url":"https://github.com/dkomanov/fizteh-java-2014/pull/598.diff","patch_url":"https://github.com/dkomanov/fizteh-java-2014/pull/598.patch","issue_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/598","number":598,"state":"open","locked":false,"title":"FileMap with JUnit (#Задание4)","user":{"login":"AndrewTimokhin","id":8937830,"avatar_url":"https://avatars.githubusercontent.com/u/8937830?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewTimokhin","html_url":"https://github.com/AndrewTimokhin","followers_url":"https://api.github.com/users/AndrewTimokhin/followers","following_url":"https://api.github.com/users/AndrewTimokhin/following{/other_user}","gists_url":"https://api.github.com/users/AndrewTimokhin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewTimokhin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewTimokhin/subscriptions","organizations_url":"https://api.github.com/users/AndrewTimokhin/orgs","repos_url":"https://api.github.com/users/AndrewTimokhin/repos","events_url":"https://api.github.com/users/AndrewTimokhin/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewTimokhin/received_events","type":"User","site_admin":false},"body":"В данном задании имплементированы те интерфейсы, которые запрашивались ранее. Т.е. это второй пункт решения этого задания (второй отослан ранее). Помимо методов, которые перечислены ранее, добавлен метод чтения данных с жесткого диска и также записи на жесткий диск. Тесты были написаны в среде разработки NetBeans 8.0.1. И успешно прошли. Класс JUnit служит для проверки логики работы с фабрикой, то что она производит и т.д. и т.п.  Можно скомпилировать исходные файлы в jar, тем самым собрав библиотеку и успешно ею пользоваться. Все замечания будут учтены!","created_at":"2015-01-19T21:25:18Z","updated_at":"2015-02-03T12:06:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d391674dfaa77bcdb764175d18ec6eee346bfb25","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598/commits","review_comments_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598/comments","review_comment_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/comments/{number}","comments_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/598/comments","statuses_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/statuses/44da6c6251b5aea6f398d1e122a28d7d606bb29d","head":{"label":"AndrewTimokhin:master","ref":"master","sha":"44da6c6251b5aea6f398d1e122a28d7d606bb29d","user":{"login":"AndrewTimokhin","id":8937830,"avatar_url":"https://avatars.githubusercontent.com/u/8937830?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewTimokhin","html_url":"https://github.com/AndrewTimokhin","followers_url":"https://api.github.com/users/AndrewTimokhin/followers","following_url":"https://api.github.com/users/AndrewTimokhin/following{/other_user}","gists_url":"https://api.github.com/users/AndrewTimokhin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewTimokhin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewTimokhin/subscriptions","organizations_url":"https://api.github.com/users/AndrewTimokhin/orgs","repos_url":"https://api.github.com/users/AndrewTimokhin/repos","events_url":"https://api.github.com/users/AndrewTimokhin/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewTimokhin/received_events","type":"User","site_admin":false},"repo":{"id":26065231,"name":"fizteh-java-2014","full_name":"AndrewTimokhin/fizteh-java-2014","owner":{"login":"AndrewTimokhin","id":8937830,"avatar_url":"https://avatars.githubusercontent.com/u/8937830?v=3","gravatar_id":"","url":"https://api.github.com/users/AndrewTimokhin","html_url":"https://github.com/AndrewTimokhin","followers_url":"https://api.github.com/users/AndrewTimokhin/followers","following_url":"https://api.github.com/users/AndrewTimokhin/following{/other_user}","gists_url":"https://api.github.com/users/AndrewTimokhin/gists{/gist_id}","starred_url":"https://api.github.com/users/AndrewTimokhin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AndrewTimokhin/subscriptions","organizations_url":"https://api.github.com/users/AndrewTimokhin/orgs","repos_url":"https://api.github.com/users/AndrewTimokhin/repos","events_url":"https://api.github.com/users/AndrewTimokhin/events{/privacy}","received_events_url":"https://api.github.com/users/AndrewTimokhin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AndrewTimokhin/fizteh-java-2014","description":"","fork":true,"url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014","forks_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/forks","keys_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/teams","hooks_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/hooks","issue_events_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/issues/events{/number}","events_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/events","assignees_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/assignees{/user}","branches_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/branches{/branch}","tags_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/tags","blobs_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/git/refs{/sha}","trees_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/statuses/{sha}","languages_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/languages","stargazers_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/stargazers","contributors_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/contributors","subscribers_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/subscribers","subscription_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/subscription","commits_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/commits{/sha}","git_commits_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/git/commits{/sha}","comments_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/comments{/number}","issue_comment_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/issues/comments/{number}","contents_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/contents/{+path}","compare_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/merges","archive_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/downloads","issues_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/issues{/number}","pulls_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/pulls{/number}","milestones_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/milestones{/number}","notifications_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/labels{/name}","releases_url":"https://api.github.com/repos/AndrewTimokhin/fizteh-java-2014/releases{/id}","created_at":"2014-11-01T22:35:15Z","updated_at":"2015-02-03T02:11:17Z","pushed_at":"2015-02-03T02:11:17Z","git_url":"git://github.com/AndrewTimokhin/fizteh-java-2014.git","ssh_url":"git@github.com:AndrewTimokhin/fizteh-java-2014.git","clone_url":"https://github.com/AndrewTimokhin/fizteh-java-2014.git","svn_url":"https://github.com/AndrewTimokhin/fizteh-java-2014","homepage":null,"size":8209,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dkomanov:master","ref":"master","sha":"da301fdee510377d59ec86f8cf5dcc9960ba3156","user":{"login":"dkomanov","id":1158662,"avatar_url":"https://avatars.githubusercontent.com/u/1158662?v=3","gravatar_id":"","url":"https://api.github.com/users/dkomanov","html_url":"https://github.com/dkomanov","followers_url":"https://api.github.com/users/dkomanov/followers","following_url":"https://api.github.com/users/dkomanov/following{/other_user}","gists_url":"https://api.github.com/users/dkomanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkomanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkomanov/subscriptions","organizations_url":"https://api.github.com/users/dkomanov/orgs","repos_url":"https://api.github.com/users/dkomanov/repos","events_url":"https://api.github.com/users/dkomanov/events{/privacy}","received_events_url":"https://api.github.com/users/dkomanov/received_events","type":"User","site_admin":false},"repo":{"id":23866876,"name":"fizteh-java-2014","full_name":"dkomanov/fizteh-java-2014","owner":{"login":"dkomanov","id":1158662,"avatar_url":"https://avatars.githubusercontent.com/u/1158662?v=3","gravatar_id":"","url":"https://api.github.com/users/dkomanov","html_url":"https://github.com/dkomanov","followers_url":"https://api.github.com/users/dkomanov/followers","following_url":"https://api.github.com/users/dkomanov/following{/other_user}","gists_url":"https://api.github.com/users/dkomanov/gists{/gist_id}","starred_url":"https://api.github.com/users/dkomanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dkomanov/subscriptions","organizations_url":"https://api.github.com/users/dkomanov/orgs","repos_url":"https://api.github.com/users/dkomanov/repos","events_url":"https://api.github.com/users/dkomanov/events{/privacy}","received_events_url":"https://api.github.com/users/dkomanov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dkomanov/fizteh-java-2014","description":"","fork":false,"url":"https://api.github.com/repos/dkomanov/fizteh-java-2014","forks_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/forks","keys_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/teams","hooks_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/hooks","issue_events_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/events{/number}","events_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/events","assignees_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/assignees{/user}","branches_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/branches{/branch}","tags_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/tags","blobs_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/git/refs{/sha}","trees_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/statuses/{sha}","languages_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/languages","stargazers_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/stargazers","contributors_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/contributors","subscribers_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/subscribers","subscription_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/subscription","commits_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/commits{/sha}","git_commits_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/git/commits{/sha}","comments_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/comments{/number}","issue_comment_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/comments/{number}","contents_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/contents/{+path}","compare_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/merges","archive_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/downloads","issues_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues{/number}","pulls_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls{/number}","milestones_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/milestones{/number}","notifications_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/labels{/name}","releases_url":"https://api.github.com/repos/dkomanov/fizteh-java-2014/releases{/id}","created_at":"2014-09-10T08:32:49Z","updated_at":"2014-12-27T19:21:06Z","pushed_at":"2014-12-27T15:00:31Z","git_url":"git://github.com/dkomanov/fizteh-java-2014.git","ssh_url":"git@github.com:dkomanov/fizteh-java-2014.git","clone_url":"https://github.com/dkomanov/fizteh-java-2014.git","svn_url":"https://github.com/dkomanov/fizteh-java-2014","homepage":null,"size":35831,"stargazers_count":8,"watchers_count":8,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":84,"mirror_url":null,"open_issues_count":52,"forks":84,"open_issues":52,"watchers":8,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598"},"html":{"href":"https://github.com/dkomanov/fizteh-java-2014/pull/598"},"issue":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/598"},"comments":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/issues/598/comments"},"review_comments":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598/comments"},"review_comment":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/pulls/598/commits"},"statuses":{"href":"https://api.github.com/repos/dkomanov/fizteh-java-2014/statuses/44da6c6251b5aea6f398d1e122a28d7d606bb29d"}}}}