Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 // This software is released into the Public Domain.  See copying.txt for details.
 package org.openstreetmap.osmosis.replication.common;
 
Formats replication sequence numbers into file names.
Creates a new instance.

Parameters:
minimumLength The minimum length file sequence string to generate. For example, setting a length of 2 will generate sequence numbers from "00" to "99".
groupingLength The number of characters to write before separating with a '/' character. Used for creating sequence numbers to be written to files in a nested directory structure.
	public ReplicationSequenceFormatter(int minimumLengthint groupingLength) {
		DecimalFormatSymbols formatSymbols;
		StringBuilder formatString;
		formatSymbols = new DecimalFormatSymbols(.);
		formatSymbols.setGroupingSeparator('/');
		formatString = new StringBuilder();
		for (int i = 0; i < minimumLength || i <= groupingLengthi++) {
			if (i > 0 && groupingLength > 0 && i % groupingLength == 0) {
				formatString.append(',');
			}
			if (i < minimumLength) {
				formatString.append('0');
else {
				formatString.append('#');
			}
		}
		formatString.reverse();
		this. = new DecimalFormat(formatString.toString(), formatSymbols);
	}


Formats the sequence number into a file name. Any sub-directories required will be automatically created.

Parameters:
sequenceNumber The sequence number.
fileNameSuffix The suffix to append to the end of the file name.
Returns:
The formatted file name.
	public String getFormattedName(long sequenceNumberString fileNameSuffix) {
		String fileName;
		fileName = .format(sequenceNumber) + fileNameSuffix;
		return fileName;
	}
New to GrepCode? Check out our FAQ X