python-awips/dynamicserialize/adapters/EnumSetAdapter.py

33 lines
912 B
Python
Raw Normal View History

2018-09-05 15:52:38 -06:00
#
# Adapter for java.util.EnumSet
#
#
# SOFTWARE HISTORY
#
# Date Ticket# Engineer Description
# ------------ ---------- ----------- --------------------------
# 07/28/11 dgilling Initial Creation.
# 12/02/13 2537 bsteffen Serialize empty enum sets.
#
from dynamicserialize.dstypes.java.util import EnumSet
ClassAdapter = ['java.util.EnumSet', 'java.util.RegularEnumSet']
def serialize(context, bufferset):
setSize = len(bufferset)
2018-09-05 15:52:38 -06:00
context.writeI32(setSize)
context.writeString(bufferset.getEnumClass())
for val in bufferset:
2018-09-05 15:52:38 -06:00
context.writeString(val)
def deserialize(context):
setSize = context.readI32()
enumClassName = context.readString()
valList = []
for __ in range(setSize):
2018-09-05 15:52:38 -06:00
valList.append(context.readString())
return EnumSet(enumClassName, valList)