/** * Returns a printable representation of this header. * * @param filter FormatProperties object for filtering this header. * @return Returns a string representation of this header. */ public String toString(FormatProperties filter) { // Check for Port filtering if (filter != null) { // If filter is enabled boolean print = false; String port = filter.getPort(); if (port == null) { print = true; // The filtering doesn't apply to this header } else if (port.equals(sourceport.toString()) || port.equals(destport.toString())) { print = true; } if (!print) { // Don't print the packet if (Trace.isTraceOn() && Trace.isTraceInformationOn()) { Trace.log(Trace.INFORMATION, CLASS + ".toString() " + "Not printing record"); } return ""; // Return empty record because it didn't pass the filter } } String portname = (String) Port.get(this.sourceport.toString()); String portname2 = (String) Port.get(this.destport.toString()); // Make sure we have enough data to parse a full header if (rawheader.getBitSize() < getHeaderLen()) { return (new Data(rawheader)).toString(); } if (portname == null) { portname = UNASSIGNED; } if (portname2 == null) { portname2 = UNASSIGNED; } String sourceport = this.sourceport.toString() + ", " + portname; String destport = this.destport.toString() + ", " + portname2; Object[] args = {sourceport, destport, length, checksum}; return Formatter.jsprintf( "\t " + UDPSTR + " . . . . : " + SRC + ": {0,18,L} " + DST + ": {1,18,L}\n" + "\t\t\t " + LEN + ": {2,5,L} " + CHKSUM + ": {3}\n", args) + printHexHeader() + printnext(filter) + (new Data(rawpayload)).toString(); }