@Test public void testAllBytesDisplayable() throws UnsupportedEncodingException { String[] strings = new String[4]; strings[0] = "4465722041756674726167207775726465206572666f6c67726569636820616267657363686c6f7373656e2e2045732074726174656e206a65646f63682064696520666f6c67656e64656e20426564696e67756e67656e206175663a0a0a31204461746569656e2077757264656e20fc626572737072756e67656e2e0a"; strings[1] = "5352562d45584330312c205352562d45584330322d4261636b7570202d204d6f2d446f2c2046722c206d746c2e2d4232442d4d6f6e7461672d446f6e6e657273746167202d2d204465722041756674726167207363686c7567206d697420666f6c67656e64656d204665686c6572206665686c3a20446572204d656469656e736572766572206b6f6e6e7465206b65696e652056657262696e64756e67207a756d2072656d6f74656e20436f6d7075746572206865727374656c6c656e2e204175662064656d2072656d6f74656e20436f6d7075746572206ce4756674206df6676c69636865727765697365206e69636874204261636b75702045786563200d0a52656d6f7465204167656e7420666f722057696e646f77732f4c696e75782e205374656c6c656e20536965207369636865722c206461737320646965206b6f7272656b74652056657273696f6e20766f6e2052656d6f7465204167656e74206175662064656d205a69656c636f6d707574657220696e7374616c6c696572742069737420756e64206175"; strings[2] = "56697275732f4d616c776172653a2054524f4a5f47452e443843463531313520436f6d70757465723a205352562d4653303220446f6de46e653a2054636c73675c2044617465693a20443a5c36352d6f323031302d70726f66696c655c73616e6472612e7265696e68617264745c55504d5f50726f66696c655c417070446174615c526f616d696e675c4d6963726f736f66745c75706361706933322e65786520446174756d2f5568727a6569743a2032302e30352e323031342030383a30313a33322045726765626e69733a20476573e4756265727420"; strings[3] = "56697275732f4d616c776172653a2045696361725f746573745f66696c6520436f6d70757465723a2049542d30303220446f6de46e653a2050632d6974206f686e65206669726577616c6c5c2044617465693a20473a5c6569636172202d204b6f7069655c6569636172202d204b6f7069652e746172202865696361722e636f6d2920446174756d2f5568727a6569743a2030312e31312e323031332031313a34383a34382045726765626e69733a2045732077757264652065696e20566972757320656e746465636b742e2053e4756265726e206e69636874206df6676c6963682e202851756172616e74e46e652920"; for (String string : strings) { System.out.println(new String(hexStringToBytes(string), "UTF-8")); System.out.println(new String(hexStringToBytes(string), "ISO-8859-1")); } for (String string : strings) { System.out.println(new String(hexStringToBytes(string))); assertTrue(new String(hexStringToBytes(string), "ISO-8859-1"), AbstractSnmpValue.allBytesDisplayable(hexStringToBytes(string))); } }
public static boolean allBytesDisplayable(final byte[] bytes) { if (allBytesUTF_8(bytes)) { return true; } else if (allBytesISO_8859_1(bytes)) { return true; } else { return false; } }
AbstractSnmpValue implements SnmpValue { public static boolean allBytesDisplayable(final byte[] bytes) { if (allBytesUTF_8(bytes)) { return true; } else if (allBytesISO_8859_1(bytes)) { return true; } else { return false; } } }
AbstractSnmpValue implements SnmpValue { public static boolean allBytesDisplayable(final byte[] bytes) { if (allBytesUTF_8(bytes)) { return true; } else if (allBytesISO_8859_1(bytes)) { return true; } else { return false; } }  }
AbstractSnmpValue implements SnmpValue { public static boolean allBytesDisplayable(final byte[] bytes) { if (allBytesUTF_8(bytes)) { return true; } else if (allBytesISO_8859_1(bytes)) { return true; } else { return false; } }  static boolean allBytesDisplayable(final byte[] bytes); static boolean allBytesUTF_8(final byte[] bytes); static boolean allBytesISO_8859_1(byte[] bytes); }
AbstractSnmpValue implements SnmpValue { public static boolean allBytesDisplayable(final byte[] bytes) { if (allBytesUTF_8(bytes)) { return true; } else if (allBytesISO_8859_1(bytes)) { return true; } else { return false; } }  static boolean allBytesDisplayable(final byte[] bytes); static boolean allBytesUTF_8(final byte[] bytes); static boolean allBytesISO_8859_1(byte[] bytes);  }