python-awips/dynamicserialize/adapters/EnumSetAdapter.py

41 lines
901 B
Python
Raw Normal View History

2015-06-18 10:25:33 -06:00
##
##
#
# Adapter for java.util.EnumSet
2016-03-16 16:32:17 -05:00
#
#
2015-06-18 10:25:33 -06:00
# SOFTWARE HISTORY
2016-03-16 16:32:17 -05:00
#
2015-06-18 10:25:33 -06:00
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/28/11 dgilling Initial Creation.
# 12/02/13 2537 bsteffen Serialize empty enum sets.
2016-03-16 16:32:17 -05:00
#
#
2015-06-18 10:25:33 -06:00
#
from dynamicserialize.dstypes.java.util import EnumSet
2016-03-16 16:32:17 -05:00
ClassAdapter = ['java.util.EnumSet', 'java.util.RegularEnumSet']
2015-06-18 10:25:33 -06:00
2015-06-18 10:25:33 -06:00
def serialize(context, set):
setSize = len(set)
context.writeI32(setSize)
context.writeString(set.getEnumClass())
for val in set:
context.writeString(val)
2015-06-18 10:25:33 -06:00
def deserialize(context):
setSize = context.readI32()
enumClassName = context.readString()
valList = []
2016-04-16 17:00:50 -06:00
for i in range(setSize):
2015-06-18 10:25:33 -06:00
valList.append(context.readString())
2016-03-16 16:32:17 -05:00
return EnumSet(enumClassName, valList)