use of iso.std.iso_iec._24727.tech.schema.IFDStatusType in project open-ecard by ecsec.
the class IFDStatusDiff method merge.
private List<IFDStatusType> merge(List<IFDStatusType> deleted) {
ArrayList<IFDStatusType> states = new ArrayList<IFDStatusType>(result.size() + deleted.size());
states.addAll(result);
// transform all deleted terminals so it is clear they disappeared
for (IFDStatusType next : deleted) {
IFDStatusType s = new IFDStatusType();
s.setIFDName(next.getIFDName());
s.setConnected(Boolean.FALSE);
// slots must be present too
for (SlotStatusType nextST : next.getSlotStatus()) {
SlotStatusType st = new SlotStatusType();
st.setIndex(nextST.getIndex());
st.setCardAvailable(Boolean.FALSE);
s.getSlotStatus().add(st);
}
// add new deleted terminal type to states list
states.add(s);
}
this.result = states;
return states;
}
use of iso.std.iso_iec._24727.tech.schema.IFDStatusType in project open-ecard by ecsec.
the class IFDStatusDiff method diff.
public void diff(List<IFDStatusType> others, boolean withNew) {
result = new LinkedList<IFDStatusType>();
deleted = new LinkedList<IFDStatusType>(expected);
for (IFDStatusType next : others) {
String nextName = next.getIFDName();
if (expectedContains(nextName)) {
// check for terminal connection
IFDStatusType other = expectedGet(nextName);
Boolean otherCard = other.isConnected();
boolean otherCardB = (otherCard == null) ? false : otherCard.booleanValue();
Boolean thisCard = next.isConnected();
boolean thisCardB = (thisCard == null) ? false : thisCard.booleanValue();
if (thisCardB != otherCardB) {
result.add(next);
} else {
// check for card insertions or removals
if (other.getSlotStatus().size() == next.getSlotStatus().size()) {
for (SlotStatusType nextSlot : next.getSlotStatus()) {
BigInteger thisSlotIdx = nextSlot.getIndex();
SlotStatusType otherSlot = null;
for (SlotStatusType nextOtherSlot : other.getSlotStatus()) {
if (thisSlotIdx.equals(nextOtherSlot.getIndex())) {
otherSlot = nextOtherSlot;
break;
}
}
// no equivalent slot, only occurs on evolving terminals ;-)
if (otherSlot == null) {
result.add(next);
break;
}
// compare card status of slot
if (nextSlot.isCardAvailable() != otherSlot.isCardAvailable()) {
result.add(next);
break;
}
// compare if there are different cards in slot
byte[] nextATR = nextSlot.getATRorATS();
byte[] otherATR = otherSlot.getATRorATS();
if (!(nextATR == null && otherATR == null) && !(IFDStatusDiff.arrayEquals(nextATR, otherATR))) {
result.add(next);
break;
}
}
}
}
// delete card from deleted list
deleted.remove(expectedGet(nextName));
} else if (withNew) {
result.add(next);
}
}
merge(deleted);
}
Aggregations