protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), 4, ' '); } }
protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), 4, ' '); } }
protected String rowNumberStr() { return StringUtil.justifyRight("" + (++rowNumber), widthOfRowNumber, ' '); }
protected InputStream openNextFile() throws IOException { // Open the stream to the next file ... ++fileCount; String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0'); String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION + GZIP_EXTENSION; currentFile = new File(parentDirectory, filename); boolean compressed = true; if (!currentFile.exists()) { // Try the uncompressed form ... filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION; currentFile = new File(parentDirectory, filename); if (!currentFile.exists()) return null; compressed = false; } if (!currentFile.canRead() || !currentFile.isFile()) return null; InputStream fileStream = new FileInputStream(currentFile); if (compressed) fileStream = new GZIPInputStream(fileStream); return new BufferedInputStream(fileStream); }
protected InputStream openNextFile() throws IOException { // Open the stream to the next file ... ++fileCount; String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0'); String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION + GZIP_EXTENSION; currentFile = new File(parentDirectory, filename); boolean compressed = true; if (!currentFile.exists()) { // Try the uncompressed form ... filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION; currentFile = new File(parentDirectory, filename); if (!currentFile.exists()) return null; compressed = false; } if (!currentFile.canRead() || !currentFile.isFile()) return null; InputStream fileStream = new FileInputStream(currentFile); if (compressed) fileStream = new GZIPInputStream(fileStream); return new BufferedInputStream(fileStream); }
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0'); String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION; if (compress) filename = filename + GZIP_EXTENSION;
String suffix = StringUtil.justifyRight(Long.toString(fileCount), BackupService.NUM_CHARS_IN_FILENAME_SUFFIX, '0'); String filename = filenamePrefix + "_" + suffix + DOCUMENTS_EXTENSION; if (compress) filename = filename + GZIP_EXTENSION;
/** * Justify the contents of the string. * * @param justify the way in which the string is to be justified * @param str the string to be right justified; if null, an empty string is used * @param width the desired width of the string; must be positive * @param padWithChar the character to use for padding, if needed * @return the right justified string */ public static String justify( Justify justify, String str, final int width, char padWithChar ) { switch (justify) { case LEFT: return justifyLeft(str, width, padWithChar); case RIGHT: return justifyRight(str, width, padWithChar); case CENTER: return justifyCenter(str, width, padWithChar); } assert false; return null; }
/** * Justify the contents of the string. * * @param justify the way in which the string is to be justified * @param str the string to be right justified; if null, an empty string is used * @param width the desired width of the string; must be positive * @param padWithChar the character to use for padding, if needed * @return the right justified string */ public static String justify( Justify justify, String str, final int width, char padWithChar ) { switch (justify) { case LEFT: return justifyLeft(str, width, padWithChar); case RIGHT: return justifyRight(str, width, padWithChar); case CENTER: return justifyCenter(str, width, padWithChar); } assert false; return null; }
/** * Justify the contents of the string. * * @param justify the way in which the string is to be justified * @param str the string to be right justified; if null, an empty string is used * @param width the desired width of the string; must be positive * @param padWithChar the character to use for padding, if needed * @return the right justified string */ public static String justify( Justify justify, String str, final int width, char padWithChar ) { switch (justify) { case LEFT: return justifyLeft(str, width, padWithChar); case RIGHT: return justifyRight(str, width, padWithChar); case CENTER: return justifyCenter(str, width, padWithChar); } assert false; return null; }
@Test public void justifyRightShouldPrependCharacterForStringsThatAreTooShort() { assertEquals(" This", StringUtil.justifyRight("This", 10, ' ')); }
@Test public void justifyRightShouldPrependCharacterForEmptyStrings() { assertEquals(" ", StringUtil.justifyRight("", 10, ' ')); }
@Test public void justifyRightShouldPrependCharacterForNullStrings() { assertEquals(" ", StringUtil.justifyRight(null, 10, ' ')); }
@Test public void justifyRightShouldReturnStringsThatAreTheDesiredLength() { assertEquals("This is the string", StringUtil.justifyRight("This is the string", 18, ' ')); }
sb.append(StringUtil.justifyLeft(location.getPath().getString(registry), maxLength, ' ')); sb.append(StringUtil.justifyRight(snapshot.getId().toString(), 10, ' '));
@Test public void justifyRightShouldTruncateStringsThatAreTooLong() { assertEquals(" is the string", StringUtil.justifyRight("This is the string", 14, ' ')); }
final String threadName = StringUtil.justifyRight("" + (i + 1), 3, ' '); Runnable runner = new Runnable() { @Override
while (iter.hasNext()) { Node node = iter.nextNode(); if (print) System.out.println(" " + StringUtil.justifyRight(Integer.toString(++i), 4, ' ') + ". " + node.getPath()); if (predicate != null) assertThat(predicate.accept(node), is(true)); while (rows.hasNext()) { Row row = rows.nextRow(); if (print) System.out.print(" " + StringUtil.justifyRight(Integer.toString(++rowCount), 4, ' ') + ". "); for (int i = 0; i != selectorNames.length; ++i) { Node node = row.getNode(selectorNames[i]);