@Override public Element generateXMLElement(String name) { Element node = new Element(name); for (int i = 0; i < sequencesize; i++) { Element recordsnode = new Element("cardFaultRecords"); node.addContent(recordsnode); Iterator<CardFaultRecord> it = cardFaultRecords.get(i).iterator(); while (it.hasNext()) { CardFaultRecord cfr = (CardFaultRecord) it.next(); recordsnode.addContent(cfr.generateXMLElement("cardFaultRecord")); } } return node; }
/** * Constructor for a CardFaultData object * * @param value byte array of a CardFaultData structure whose data is used when the CardFaultData * object is created. */ public CardFaultData(byte[] value, short noOfFaultsPerType) { debugLogger = new DebugLogger(); debugLogger.println( DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] no of faults per type: " + noOfFaultsPerType); int noOfValidFaultRecords = 0; // loops are beautiful. cantaloop... funky, funky... for (int j = 0; j < sequencesize; j++) { // max. NoOfFaultsPerType = 24 cardFaultRecords.add(new Vector<CardFaultRecord>(24)); debugLogger.println( DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] ------------------------------------------------------------"); switch (j) { case 0: debugLogger.println( DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] recording eq. faults:"); break; case 1: debugLogger.println(DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] card faults:"); break; default: break; } for (int i = (noOfFaultsPerType * CardFaultRecord.size * j); i < (noOfFaultsPerType * CardFaultRecord.size * (j + 1)); i += CardFaultRecord.size) { byte[] record = arrayCopy(value, i, CardFaultRecord.size); CardFaultRecord cfr = new CardFaultRecord(record); // only add entries with non-default values, i.e. skip empty entries if (cfr.getFaultBeginTime().getTimeReal() != 0) { switch (j) { case 0: debugLogger.printf( DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] event fault type: 0x%02x, %s\n", cfr.getFaultType().getEventFaultType(), cfr.getFaultType().toString()); break; case 1: debugLogger.printf( DebugLogger.DEBUG_LOGLEVEL_INFO_EXTENDED, " [INFO_EXT] event fault type: 0x%02x, %s\n", cfr.getFaultType().getEventFaultType(), cfr.getFaultType().toString()); break; default: break; } cardFaultRecords.get(j).add(cfr); noOfValidFaultRecords += 1; } } } size = noOfValidFaultRecords * CardFaultRecord.size; }