{"id":18026470,"url":"https://github.com/timoschwarzer/ex04","last_synced_at":"2025-04-04T19:47:14.107Z","repository":{"id":90393909,"uuid":"193571235","full_name":"timoschwarzer/ex04","owner":"timoschwarzer","description":"homework","archived":false,"fork":false,"pushed_at":"2019-06-24T20:07:37.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-10T04:41:25.592Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timoschwarzer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-24T20:02:23.000Z","updated_at":"2020-06-03T19:41:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"a2a7d86c-b348-4bd7-83a7-2689ea3ecc66","html_url":"https://github.com/timoschwarzer/ex04","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fex04","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fex04/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fex04/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoschwarzer%2Fex04/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timoschwarzer","download_url":"https://codeload.github.com/timoschwarzer/ex04/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247240168,"owners_count":20906778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T08:06:54.451Z","updated_at":"2025-04-04T19:47:14.087Z","avatar_url":"https://github.com/timoschwarzer.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ex04\nhomework\n\n\npublic class Paragraph {\n\n    String text;\n\n    static int counter = 0;\n    int id;\n\n    Paragraph(String text){\n      this.id = counter;\n      this.text = text;\n      counter++;\n    }\n\n\n}\n\n\n    public void getTask() {\n\n\n        Request task;\n        final ConcurrentLinkedQueue\u003cRequest\u003e lock = request;\n\n        synchronized (lock) {\n            if (lock.isEmpty()) {\n                System.out.println(this.getName() + \" had no work\");\n                return;\n            }\n\n            task = lock.poll();\n\n        }\n        switch (task.getReqType()) {\n\n\n            case APPEND_PAR:\n                print(task);\n                doc.appendParagraph(task.getText());\n                break;\n            case APPEND_TEXT:\n                print(task);\n                doc.appendText(task.getText(), task.getParagraphID());\n                break;\n\n            case REPLACE:\n                print(task);\n                doc.replaceText(task.getText(), task.getParagraphID());\n                break;\n\n            case DELETE:\n                print(task);\n                doc.deleteParagraph(task.getParagraphID());\n                break;\n\n            case GET_TEXT:\n                print(task);\n                doc.getText();\n                break;\n\n            case MERGE:\n                print(task);\n                doc.mergeParagraphs(task.getParagraphID());\n                break;\n\n            case INSERT_AFTER:\n                print(task);\n                doc.insertAfterParagraph(task.getText(), task.getParagraphID());\n                break;\n\n            default:\n                System.out.println(this.getName() + \" shouldn't be here!\");\n                break;\n        }\n\n    }\n\n    private void print(Request task){\n        System.out.println(this.getName() + \" executed task: \" + task.getReqType().toString());\n\n    }\n    \n    public void run() {\n\n        while(true) {\n            getTask();\n            try {\n                Thread.sleep(100);\n            } catch (InterruptedException e) {\n            }\n\n            if (request.isEmpty()) {\n                break;\n            }\n        }\n\n    }\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoschwarzer%2Fex04","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoschwarzer%2Fex04","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoschwarzer%2Fex04/lists"}