{"id":13743846,"url":"https://github.com/kokorin/AStream","last_synced_at":"2025-05-09T02:31:35.184Z","repository":{"id":16724446,"uuid":"19481505","full_name":"kokorin/AStream","owner":"kokorin","description":"XML to Object (and vice versa) mapping library written in AS3. Compatible with XStream.","archived":true,"fork":false,"pushed_at":"2015-05-16T10:08:55.000Z","size":630,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-15T15:40:53.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"ActionScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kokorin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-06T04:53:53.000Z","updated_at":"2024-07-10T09:45:38.000Z","dependencies_parsed_at":"2022-07-13T13:51:13.499Z","dependency_job_id":null,"html_url":"https://github.com/kokorin/AStream","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokorin%2FAStream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokorin%2FAStream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokorin%2FAStream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kokorin%2FAStream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kokorin","download_url":"https://codeload.github.com/kokorin/AStream/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253177722,"owners_count":21866388,"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-08-03T05:00:58.287Z","updated_at":"2025-05-09T02:31:34.880Z","avatar_url":"https://github.com/kokorin.png","language":"ActionScript","funding_links":[],"categories":["File Formats"],"sub_categories":["XML"],"readme":"AStream\n=======\n\nAStream can handle enums. Enum's name passed to super() is used to represent enum's value in XML.\n```as3\npackage com.example.domain {\nimport as3.lang.Enum;\n\npublic class UserRole extends Enum {\n    public static const ADMINISTRATOR:UserRole = new UserRole(\"ROLE_ADMINISTRATOR\");\n    public static const OPERATOR:UserRole = new UserRole(\"ROLE_OPERATOR\");\n\n    public function UserRole(name:String) {\n        super(name);\n    }\n}\n}\n```\n\n**There is no guarantee in flash that you will get class' properies in order they were declared!**\n\nYou can add AStreamOrder metadata to enforce tag order in xml.\n```as3\npackage com.example.domain {\n[AStreamAlias(\"User\")]\npublic class User {\n    private var _name:String;\n\n    [AStreamOrder(10)]\n    public var id:Number;\n    [AStreamOrder(30)]\n    public var role:UserRole;\n    [AStreamOrder(40)]\n    [AStreamConverter(\"ru.kokorin.astream.converter.DateConverter\", params=\"yyyy-MM-dd\")]\n    public var birth:Date;\n\n    public function User() {\n    }\n\n    [AStreamOrder(20)]\n    public function get name():String {\n        return _name;\n    }\n\n    public function set name(value:String):void {\n        _name = value;\n    }\n\n    public function toString():String {\n        return \"User{name=\" + String(name) + \",id=\" + String(id) + \",role=\" + String(role) + \",birth=\" + String(birth) + \"}\";\n    }\n}\n}\n```\n\n**Use AStream's metadata autodetection with caution!**\n\nIf metadata autodetection is on, every time AStream converts an object it will  first process the object's type and all the types related. Therefore it is no problem to serialize an object graph into XML, since AStream will know of all types in advance.\n\nThis is no longer true at deserialization time. AStream has to know the alias to turn it into the proper type, but it can find the annotation for the alias only if it has processed the type in advance. Therefore deserialization will fail if the type has not already been processed either by having called AStream's processMetadata method or by already having serialized this type. However, AStreamAlias is the only metadata that may fail in this case.\n```as3\nconst aStream:AStream = new AStream();\naStream.processMetadata(User);\n//or aStream.autodetectMetadata(true);\n\nconst user:User = new User();\nuser.id = 1;\nuser.name = \"Ivanov Ivan\";\nuser.role = UserRole.ADMINISTRATOR;\nuser.birth = new Date(1960, 4, 19, 0, 0, 0, 0);\n\nconst xml:XML = aStream.toXML(user);\n/* xml.toXMLString()\n \u003cUser\u003e\n    \u003cid\u003e1\u003c/id\u003e\n    \u003cname\u003eIvanov Ivan\u003c/name\u003e\n    \u003crole\u003eROLE_ADMINISTRATOR\u003c/role\u003e\n    \u003cbirth\u003e1960-05-19\u003c/birth\u003e\n \u003c/User\u003e */\n\nconst restoredUser:User = aStream.fromXML(xml) as User;\n/* restoredUser.toString()\nUser{name=Ivanov Ivan,id=1,role=ROLE_ADMINISTRATOR,birth=Thu May 19 00:00:00 GMT+0300 1960} */\n```        \n\n**Сorresponding types (by default)**\n\n         Java        |         XML         |                AS3       \n---------------------|---------------------|------------------------------------\n       byte[]        |      byte-array     |              ByteArray\n       Type[]        |      Type-array     |         Vector.\u0026lt;Type\u0026gt;\n java.util.ArrayList |        list         | org.spicefactory.lib.collection.List\n  java.util.HashMap  |         map         | org.spicefactory.lib.collection.Map\n    Float, float     |        float        |               Number                  \n    Integer, int     |         int         |                int                  \n   java.util.Date    |         date        |                Date\n  java.lang.String   |        string       |               String                 \n      \n      \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkokorin%2FAStream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkokorin%2FAStream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkokorin%2FAStream/lists"}