Skip to content

Commit

Permalink
implement Loggeable
Browse files Browse the repository at this point in the history
  • Loading branch information
ar committed Dec 5, 2014
1 parent 171e7c0 commit f25c784
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion jpos/src/main/java/org/jpos/iso/PosDataCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

package org.jpos.iso;

import java.io.PrintStream;
import org.jpos.util.Loggeable;

@SuppressWarnings("unused")
public class PosDataCode {
public class PosDataCode implements Loggeable {

public enum ReadingMethod {
UNKNOWN (1, "Unknown"),
Expand Down Expand Up @@ -211,4 +214,45 @@ public String toString() {
public static PosDataCode valueOf (byte[] b) {
return new PosDataCode(b); // we create new objects for now, but may return cached instances in the future
}
public void dump(PrintStream p, String indent) {
String inner = indent + " ";
StringBuilder sb = new StringBuilder();
p.printf("%s<pdc value='%s'>%s%n", indent, ISOUtil.hexString(getBytes()), sb.toString());
for (ReadingMethod m : ReadingMethod.values()) {
if (hasReadingMethod(m)) {
if (sb.length() > 0)
sb.append(',');
sb.append(m.name());
}
}
p.printf ("%srm: %s%n", inner, sb.toString());
sb = new StringBuilder();
for (VerificationMethod m : VerificationMethod.values()) {
if (hasVerificationMethod(m)) {
if (sb.length() > 0)
sb.append(',');
sb.append(m.name());
}
}
p.printf ("%svm: %s%n", inner, sb.toString());
sb = new StringBuilder();
for (POSEnvironment m : POSEnvironment.values()) {
if (hasPosEnvironment(m)) {
if (sb.length() > 0)
sb.append(',');
sb.append(m.name());
}
}
p.printf ("%spe: %s%n", inner, sb.toString());
sb = new StringBuilder();
for (SecurityCharacteristic m : SecurityCharacteristic.values()) {
if (hasSecurityCharacteristic(m)) {
if (sb.length() > 0)
sb.append(',');
sb.append(m.name());
}
}
p.printf ("%ssc: %s%n", inner, sb.toString());
p.println("</pdc>");
}
}

0 comments on commit f25c784

Please sign in to comment.