{"id":45240635,"url":"https://github.com/jean-merelis/coffeepot-bean-wr","last_synced_at":"2026-02-20T21:15:03.130Z","repository":{"id":57720435,"uuid":"10601846","full_name":"jean-merelis/coffeepot-bean-wr","owner":"jean-merelis","description":null,"archived":false,"fork":false,"pushed_at":"2018-04-03T12:53:41.000Z","size":281,"stargazers_count":6,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-19T18:43:22.244Z","etag":null,"topics":["coffeepot-bean-wr","filewriter","java","java-bean","writer"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"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/jean-merelis.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}},"created_at":"2013-06-10T14:21:36.000Z","updated_at":"2020-03-26T22:54:56.000Z","dependencies_parsed_at":"2022-09-02T13:10:40.540Z","dependency_job_id":null,"html_url":"https://github.com/jean-merelis/coffeepot-bean-wr","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/jean-merelis/coffeepot-bean-wr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jean-merelis%2Fcoffeepot-bean-wr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jean-merelis%2Fcoffeepot-bean-wr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jean-merelis%2Fcoffeepot-bean-wr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jean-merelis%2Fcoffeepot-bean-wr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jean-merelis","download_url":"https://codeload.github.com/jean-merelis/coffeepot-bean-wr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jean-merelis%2Fcoffeepot-bean-wr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29664824,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-20T19:49:36.704Z","status":"ssl_error","status_checked_at":"2026-02-20T19:44:05.372Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["coffeepot-bean-wr","filewriter","java","java-bean","writer"],"created_at":"2026-02-20T21:15:02.662Z","updated_at":"2026-02-20T21:15:03.123Z","avatar_url":"https://github.com/jean-merelis.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"coffeepot-bean-wr (Writer and Reader)\n=====================================\n\nCoffeepot-bean-wr is a simple Java framework for marshalling Java beans to flat file and unmarshal flat file to Java Beans.\n\nFeatures:\n\n  - Support for delimited and fixed length formats.\n  - Uses Java annotations for mapping.\n  - Maps unannotated classes dynamically.\n  - Override annotations dynamically.\n  - Custom type handlers are supported.\n\nReal examples of use you will find them in [coffeepot-br-sped-fiscal](https://github.com/jean-merelis/coffeepot-br-sped-fiscal) and [coffeepot-br-sintegra](https://github.com/jean-merelis/coffeepot-br-sintegra) projects. The coffeepot-br-sped-fiscal project uses delimited format, and the sintegra project uses FixedLength format.\n\n\n## Version 2.0.0\n\nIn version 2, the type handlers are enhanced with the command feature.\n\nExample:\n\n```java\n\t// DefaultStringHandler has the built-in replace command\n\t@Field(name=\"descr\", commands={@Cmd(name=DefaultStringHandler.CMD_REPLACE, args={\"foo\", \"bar\"} )})\n```\n\nDownload from Maven central\n\n```xml\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.jean-merelis\u003c/groupId\u003e\n            \u003cartifactId\u003ecoffeepot-bean-wr\u003c/artifactId\u003e\n            \u003cversion\u003e2.0.0-rc.1\u003c/version\u003e            \n        \u003c/dependency\u003e \n```\n\n\n## Version 1.3.0\n\nDownload from Maven central\n\n```xml\n        \u003cdependency\u003e\n            \u003cgroupId\u003ecom.github.jean-merelis\u003c/groupId\u003e\n            \u003cartifactId\u003ecoffeepot-bean-wr\u003c/artifactId\u003e\n            \u003cversion\u003e1.3.0\u003c/version\u003e            \n        \u003c/dependency\u003e \n```\n\nExamples\n--------\n\nMapping\n-------\n\n```java\n\t\t@Record(fields = {\n\t\t\t\t@Field(name = \"\", id = true, constantValue = \"ORDER\"),\n\t\t\t\t@Field(name = \"id\"),\n\t\t\t\t@Field(name = \"date\"),\n\t\t\t\t@Field(name = \"customer\", params = {DefaultStringHandler.CMD_REPLACE, \"Sr.\", \"\", \"CharCase.UPPER\"}),\n\t\t\t\t@Field(name = \"items\")\n\t\t\t})\n\t\tpublic class Order {\n\n\t\t\tprivate Integer id;\n\t\t\tprivate Date date;\n\t\t\tprivate String customer;\n\t\t\tprivate List\u003cItem\u003e items;\n\t\t\n\t\t\t// getters and setters...\n\t\t}\n\n\t\t@Record(fields = {\n\t\t\t\t@Field(name = \"\", id = true, constantValue = \"ITEM\"),\n\t\t\t\t@Field(name = \"number\"),\n\t\t\t\t@Field(name = \"product\"),\n\t\t\t\t@Field(name = \"quantity\")\n\t\t\t})\n\t\tpublic class Item {\n\n\t\t\tprivate int number;\n\t\t\tprivate String product;\n\t\t\tprivate double quantity;\n\t\t\n\t\t\t// getters ... setters...\n\t\t}\t\t\n```\n\nUsing...\n\n```java\n\n\tpublic void test() throws Exception{\n\t\tOrder order = new Order();\n\t\torder.setCustomer(\"Sr. John B.\");\n\t\t//add some data\n\n        File file = new File(\"ORDER.tmp\");\n        Writer w = new FileWriter(file);\n\n        DelimitedWriter instance = new DelimitedWriter(w);\n        instance.setDelimiter('|');\n        instance.setEscape('\\\\');\n        instance.setRecordTerminator(\"|\\r\\n\");\n        \n        instance.write(order);\n\n        w.flush();\n        w.close();\n\n```\n\nOutput: \n\n\t\tORDER|123|2015-03-10T00:04:15|JOHN B.|\n\t\tITEM|1|product 1|10|\n\t\tITEM|2|product 2|5|\n\t\tITEM|3|product 3|2|\n\n    \nReading\n--------------\n\nFor simple file structure, i.e. where the file has only one type of record, simply map the fields of the class that represents this record and perform the reading. \n\nIf file contains a list of these records you can read with the parseAsListOf.\n\n```java\n\t//Example for a file with a list of the records.\n\n    public void read(){\n\t\tFile file = new File(\"file-with-a-list-of-records.txt\");\n\n\t\ttry (FileReader fr = new FileReader(file)) {\n\t\t\tFixedLengthReader reader = new FixedLengthReader(fr);\n\t\t\tList\u003cMyRecord\u003e records = reader.parseAsListOf(MyRecord.class);\n\t\t\tfor (MyRecord r: records){ \n\t\t\t  ...\n\t\t\t}\n\t\t}\n\n\t}\n```\n\nFor more complex structures that have various types of records, it is necessary that the records have an identifier field so it can be possible to instantiate the corresponding class of the record.\nThe identifier field must have the value that identifies the record in the constantValue property and the id property must be true.\n\n```java\n\n@Record(fields = {\n    @Field(name = \"\", constantValue = \"01\", id = true, length = 2), // identifier field\n    @Field(name = \"value\", length = 18)\n\t// ... more fields\n})\n\npublic class Rec01 {\n\n    private String value;\n\t\t\n\t// more fields getters and setters...\n\t...\n}\n\n\n@Record(fields = {\n    @Field(name = \"\", constantValue = \"AA\", id = true, length = 2), // identifier field\n    @Field(name = \"value\", length = 18)\n\t// ... more fields\n})\n\npublic class RecAA {\n\n    private String value;\n\t\t\n\t// more fields getters and setters...\n\t...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjean-merelis%2Fcoffeepot-bean-wr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjean-merelis%2Fcoffeepot-bean-wr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjean-merelis%2Fcoffeepot-bean-wr/lists"}