Skip to content

Commit

Permalink
Add facility to get ordered TLV list that preserves the input order
Browse files Browse the repository at this point in the history
  • Loading branch information
vishnupillai committed May 26, 2014
1 parent af9c36a commit 15a2dc6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jpos/src/main/java/org/jpos/tlv/TagSequence.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public interface TagSequence<T> extends TagValue<T> {

Map<String, List<TagValue<T>>> getAll();

List<TagValue<T>> getOrderedList();

void writeTo(ISOMsg isoMsg) throws ISOException;

void readFrom(ISOMsg isoMsg) throws ISOException;
Expand Down
7 changes: 7 additions & 0 deletions jpos/src/main/java/org/jpos/tlv/TagSequenceBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public abstract class TagSequenceBase implements TagSequence {

private final String tag;
private final TreeMap<String, List<TagValue>> tagMap = new TreeMap();
private final LinkedList<TagValue> orderedList = new LinkedList();

public TagSequenceBase() {
this.tag = "Root";
Expand Down Expand Up @@ -65,6 +66,12 @@ public synchronized void add(TagValue tagValue) {
tagMap.put(tag, values);
}
values.add(tagValue);
orderedList.add(tagValue);
}

@Override
public List<TagValue> getOrderedList() {
return orderedList;
}

@Override
Expand Down

0 comments on commit 15a2dc6

Please sign in to comment.