我在arrayList中有以下数据。每一行都是arraylist 中的一个元素。
我如何获取/映射每个服务对应的描述 示例 1:{服务= 住院医院护理审查,描述= 当您的情况要求您成为住院患者时 描述= 如果不满足付款确定标准。如果我们通知您您不符合付款确定标准。}
示例 2:{服务= 门诊手术中心 (ASC),描述= 当您的病情要求您住院时 描述= 承保,包括手术室、手术用品。}
Service= Review of Inpatient Hospital Care
Description= When your condition requires you to be an inpatient
Description= If payment determination criteria are not met.
If we inform you that you do not meet payment determination criteria.
Service= Ambulatory Surgical Center (ASC)
Description= Covered, including operating rooms, surgical supplies.
Service= Hospital Ancillary Services
Description= Covered, including surgical supplies, hospital anesthesia services.
Service= Hospital Room and Board
Description= Covered, including:Semi-Private Rooms. If you are hospitalized at a participating facility.
Description= Private Rooms.At Participating Hospitals.
Description= At Nonparticipating Hospitals:
Description= Newborn nursery care. Covered for the baby's nursery care after birth.
Description= Please note: Services at nonparticipating and out-of-state post-acute.
Service= Intensive Care Unit/Coronary Care Unit.
Description= Covered.
Service= Intermediate Care Unit
Description= Covered.
Service= Isolation Care Unit
Description= Covered.
我假设您要创建包含遇到的每个服务的每个数据的新对象,包含两个属性:服务和描述。我对吗 ?
在这种情况下,您可以迭代所有元素,并且每次找到以“Service=”开头的行时,都将使用“Service=”之后的行内容实例化一个新对象。你可以用正则表达式来做到这一点。每个实例化的对象都应该放在另一个列表或映射中。
然后,不以 'Service=' 开头的下一行将连接在当前新对象的 'Description' 属性中。
在循环结束时,您将拥有一个新列表,其中包含填充了所有数据的对象。
编辑:我会创建一个具有两个属性的服务类:名称和描述,两者都是字符串。
然后,当您遍历原始数据列表时,每次获得“服务”行时,您都会创建一个具有名称的新服务,从当前行中提取。
下一行将添加到您的缓冲区(我建议在没有同步的单线程程序中使用 StringBuilder 类),作为描述值。
最后,当您找到一个新的 Service 行时,您首先将缓冲区刷新到前一个 Service 实例中,填充其描述属性。然后您可以通过创建一个新的 Service 实例并再次循环来开始新的迭代。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句