Created
January 6, 2010 12:07
-
-
Save rmetzler/270235 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static <T> List<T> unmarshalList(IUnmarshaller<T> unmarshaller, DataInputStream in) | |
throws UnmarshalException { | |
try { | |
BufferedInputStream buff = new BufferedInputStream(in); | |
in = new DataInputStream(buff); | |
byte tag = in.readByte(); | |
if (TagTable.NO_VALUE == tag) { | |
return null; | |
} | |
if (TagTable.SEQ == tag) { | |
ArrayList<T> list = new ArrayList<T>(); | |
byte b; | |
in.mark(2); | |
while ( TagTable.EOC != (b = in.readByte()) ) { | |
in.reset(); | |
T o = unmarshaller.unmarshal(in); | |
list.add(o); | |
in.mark(2); | |
} | |
return list; | |
} | |
// else if (TagTable.REG_EXT == tag) { | |
// | |
// //Registered Extension | |
// //TODO implement | |
// int extId = in.readInt(); | |
// System.out.println("Registered Extension:" + extId); | |
// IProtocolElement unmarshalled = ExtensionRegistry.getInstance().getForId(extId).unmarshal(in); | |
// System.out.println(unmarshalled); | |
// | |
// return null; | |
// } | |
throw new UnmarshalException("Sequence expected, Tag was " + Byte.toString(tag)); | |
} catch (IOException e) { | |
throw new UnmarshalException("Fehler beim unmarshalling der Liste", e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment