@Test public void test() { StringBuilder input = new StringBuilder(); for (int i = 0; i < 350; i++) { input.append("a"); } String resultStr = SolarisUtil.limitString(input); AssertJUnit.assertTrue(resultStr.contains("\\")); String[] strs = resultStr.split("\n"); for (String string : strs) { final int limit = SolarisUtil.DEFAULT_LIMIT + 1; final int trimmedStringLength = string.trim().length(); String msg = String.format("String exceeds the maximal limit '%s', as it is: '%s'", limit, trimmedStringLength); AssertJUnit.assertTrue(msg, trimmedStringLength <= limit); } }
private static StringBuilder limitString(StringBuilder data, int limit) { StringBuilder result = null; if (data.length() > limit) { result = new StringBuilder(limit); result.append(data.substring(0, limit)); result.append("\\\n"); final String remainder = data.substring(limit, data.length()); if (remainder.length() > limit) { StringBuilder sbtmp = new StringBuilder(); sbtmp.append(remainder); result.append(limitString(sbtmp, limit)); } else { result.append(remainder); } } else { return data; } return result; }
SolarisUtil { private static StringBuilder limitString(StringBuilder data, int limit) { StringBuilder result = null; if (data.length() > limit) { result = new StringBuilder(limit); result.append(data.substring(0, limit)); result.append("\\\n"); final String remainder = data.substring(limit, data.length()); if (remainder.length() > limit) { StringBuilder sbtmp = new StringBuilder(); sbtmp.append(remainder); result.append(limitString(sbtmp, limit)); } else { result.append(remainder); } } else { return data; } return result; } }
SolarisUtil { private static StringBuilder limitString(StringBuilder data, int limit) { StringBuilder result = null; if (data.length() > limit) { result = new StringBuilder(limit); result.append(data.substring(0, limit)); result.append("\\\n"); final String remainder = data.substring(limit, data.length()); if (remainder.length() > limit) { StringBuilder sbtmp = new StringBuilder(); sbtmp.append(remainder); result.append(limitString(sbtmp, limit)); } else { result.append(remainder); } } else { return data; } return result; } private  SolarisUtil(); }
SolarisUtil { private static StringBuilder limitString(StringBuilder data, int limit) { StringBuilder result = null; if (data.length() > limit) { result = new StringBuilder(limit); result.append(data.substring(0, limit)); result.append("\\\n"); final String remainder = data.substring(limit, data.length()); if (remainder.length() > limit) { StringBuilder sbtmp = new StringBuilder(); sbtmp.append(remainder); result.append(limitString(sbtmp, limit)); } else { result.append(remainder); } } else { return data; } return result; } private  SolarisUtil(); static String limitString(StringBuilder data); static void controlObjectClassValidity(ObjectClass oclass,
            ObjectClass[] acceptedObjectClasses, Class<? extends AbstractOp> operation,
            final SolarisConfiguration configuration); static SolarisEntry convertIcfAttributesToSolarisEntry(String entryName, ObjectClass objectClass,
            Set<Attribute> attributes, SolarisConfiguration config); static ConnectorObject convertToConnectorObject(SolarisEntry entry, String[] attrsToGet, 
    		ObjectClass oclass, SolarisConfiguration config); static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn); }
SolarisUtil { private static StringBuilder limitString(StringBuilder data, int limit) { StringBuilder result = null; if (data.length() > limit) { result = new StringBuilder(limit); result.append(data.substring(0, limit)); result.append("\\\n"); final String remainder = data.substring(limit, data.length()); if (remainder.length() > limit) { StringBuilder sbtmp = new StringBuilder(); sbtmp.append(remainder); result.append(limitString(sbtmp, limit)); } else { result.append(remainder); } } else { return data; } return result; } private  SolarisUtil(); static String limitString(StringBuilder data); static void controlObjectClassValidity(ObjectClass oclass,
            ObjectClass[] acceptedObjectClasses, Class<? extends AbstractOp> operation,
            final SolarisConfiguration configuration); static SolarisEntry convertIcfAttributesToSolarisEntry(String entryName, ObjectClass objectClass,
            Set<Attribute> attributes, SolarisConfiguration config); static ConnectorObject convertToConnectorObject(SolarisEntry entry, String[] attrsToGet, 
    		ObjectClass oclass, SolarisConfiguration config); static boolean exists(ObjectClass entryType, SolarisEntry entry, SolarisConnection conn); static final int DEFAULT_LIMIT; }