diff options
author | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
---|---|---|
committer | Ade Lee <alee@redhat.com> | 2011-12-08 21:15:59 -0500 |
commit | 171aaece4f23709d33d180cf36eb3af5e454b0c9 (patch) | |
tree | 1485f9f0a7bd10de4ff25030db575dbb8dafae74 /pki/base/util/src/netscape/security/util/PrettyPrintFormat.java | |
parent | adad2fcee8a29fdb82376fbce07dedb11fccc182 (diff) | |
download | pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.gz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.tar.xz pki-171aaece4f23709d33d180cf36eb3af5e454b0c9.zip |
Revert "Formatting"
This reverts commit 32150d3ee32f8ac27118af7c792794b538c78a2f.
Diffstat (limited to 'pki/base/util/src/netscape/security/util/PrettyPrintFormat.java')
-rw-r--r-- | pki/base/util/src/netscape/security/util/PrettyPrintFormat.java | 159 |
1 files changed, 83 insertions, 76 deletions
diff --git a/pki/base/util/src/netscape/security/util/PrettyPrintFormat.java b/pki/base/util/src/netscape/security/util/PrettyPrintFormat.java index d62c2d046..94a5d18c7 100644 --- a/pki/base/util/src/netscape/security/util/PrettyPrintFormat.java +++ b/pki/base/util/src/netscape/security/util/PrettyPrintFormat.java @@ -17,100 +17,106 @@ // --- END COPYRIGHT BLOCK --- package netscape.security.util; + /** - * This class will display the certificate content in predefined format. - * + * This class will display the certificate content in predefined + * format. + * * @author Andrew Wnuk * @version $Revision$, $Date$ */ public class PrettyPrintFormat { - /* - * ========================================================== variables - * ========================================================== - */ + /*========================================================== + * variables + *==========================================================*/ private String mSeparator = ""; - private int mIndentSize = 0; - private int mLineLen = 0; - - /* - * ========================================================== constants - * - * ========================================================== - */ - private final static String spaces = " " - + " " - + " " - + " " - + " "; - - /* - * ========================================================== constructors - * ========================================================== - */ - - public PrettyPrintFormat(String separator) { - mSeparator = separator; + private int mIndentSize = 0; + private int mLineLen = 0; + + /*========================================================== + * constants + * + *==========================================================*/ + private final static String spaces= + " "+ + " "+ + " "+ + " "+ + " "; + + /*========================================================== + * constructors + *==========================================================*/ + + public PrettyPrintFormat(String separator) + { + mSeparator = separator; } - public PrettyPrintFormat(String separator, int lineLen) { - mSeparator = separator; - mLineLen = lineLen; + public PrettyPrintFormat(String separator, int lineLen) + { + mSeparator = separator; + mLineLen = lineLen; } - public PrettyPrintFormat(String separator, int lineLen, int indentSize) { - mSeparator = separator; - mLineLen = lineLen; - mIndentSize = indentSize; + public PrettyPrintFormat(String separator, int lineLen, int indentSize) + { + mSeparator = separator; + mLineLen = lineLen; + mIndentSize = indentSize; } - /* - * ========================================================== Private - * methods========================================================== - */ - - /* - * ========================================================== public methods - * ========================================================== - */ + /*========================================================== + * Private methods + *==========================================================*/ + + + /*========================================================== + * public methods + *==========================================================*/ /** - * Provide white space indention stevep - speed improvements. Factor of 10 - * improvement - * + * Provide white space indention + * stevep - speed improvements. Factor of 10 improvement * @param numSpace number of white space to be returned * @return white spaces */ - public String indent(int size) { - return spaces.substring(0, size); - } + public String indent(int size) { + return spaces.substring(0,size); + } + + private static final char[] hexdigits = { + '0','1','2','3','4','5','6','7','8','9', + 'A','B','C','D','E','F' + }; - private static final char[] hexdigits = { '0', '1', '2', '3', '4', '5', - '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; /** - * Convert Byte Array to Hex String Format stevep - speedup by factor of 8 - * + * Convert Byte Array to Hex String Format + * stevep - speedup by factor of 8 * @param byte array of data to hexify - * @param indentSize number of spaces to prepend before each line - * @param lineLen number of bytes to output on each line (0 means: put - * everything on one line - * @param separator the first character of this string will be used as the - * separator between bytes. + * @param indentSize number of spaces to prepend before each line + * @param lineLen number of bytes to output on each line (0 + means: put everything on one line + * @param separator the first character of this string will be used as + the separator between bytes. * @return string representation */ - public String toHexString(byte[] in, int indentSize, int lineLen, - String separator) { + public String toHexString(byte[] in, int indentSize, + int lineLen, String separator) + { StringBuffer sb = new StringBuffer(); int hexCount = 0; char c[]; - int j = 0; + int j=0; - if (lineLen == 0) { - c = new char[in.length * 3 + 1]; - } else { - c = new char[lineLen * 3 + 1]; + if (lineLen ==0) { + c = new char[in.length*3+1]; + } + else { + c = new char[lineLen*3+1]; } char sep = separator.charAt(0); @@ -119,16 +125,16 @@ public class PrettyPrintFormat { for (int i = 0; i < in.length; i++) { if (lineLen > 0 && hexCount == lineLen) { c[j++] = '\n'; - sb.append(c, 0, j); + sb.append(c,0,j); sb.append(indent(indentSize)); - hexCount = 0; - j = 0; + hexCount =0; + j=0; } byte x = in[i]; // output hex digits to buffer c[j++] = hexdigits[(char) ((x >> 4) & 0xf)]; - c[j++] = hexdigits[(char) (x & 0xf)]; + c[j++] = hexdigits[(char) (x&0xf)]; // if not last char, output separator if (i != in.length - 1) { @@ -137,24 +143,25 @@ public class PrettyPrintFormat { hexCount++; } - if (j > 0) { + if (j>0) { c[j++] = '\n'; - sb.append(c, 0, j); + sb.append(c,0,j); } - // sb.append("\n"); +// sb.append("\n"); return sb.toString(); } + public String toHexString(byte[] in, int indentSize, int lineLen) { - return toHexString(in, indentSize, lineLen, mSeparator); + return toHexString(in,indentSize,lineLen,mSeparator); } public String toHexString(byte[] in, int indentSize) { - return toHexString(in, indentSize, mLineLen); + return toHexString(in,indentSize,mLineLen); } public String toHexString(byte[] in) { - return toHexString(in, mIndentSize); - } + return toHexString(in,mIndentSize); + } } |