Class IdMultiPartHashGenerator

  extended by com.atlassian.confluence.pages.persistence.dao.filesystem.IdMultiPartHashGenerator

public class IdMultiPartHashGenerator
extends Object

A class that will take a long Confluence Id and converted it to a multi-part hash with a particular number of parts.

The split point of the Id is specified by the number of digits in each split.
e.g. 565321 with a split size of 3 will split to 565 and 321.

The actual value for each part will be the modulo of the part with the specified module value. So in the above example if a modulo of 250 is given then the split parts returned would be 65 and 71 and you know you will have a maximum of 250 possible distinct values for each part.

The number of parts property specifies exactly how many parts will be returned on each split. An Id which doesn't have enough parts will have zero value returned for any missing parts.
e.g. with a modulo=250, split=3 and parts=4 applied to the Id 436854 the returned parts will be 0, 0, 186, 104.

Instances of this class are thread safe.

Constructor Summary
IdMultiPartHashGenerator(int split, int modulo, int parts)
Method Summary
 List<Integer> generate(long value)
          Create the multipart hash for the supplied value.
 int getSplit()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public IdMultiPartHashGenerator(int split,
                                int modulo,
                                int parts)
split - the number of digits in each part. Must be between 1 and 9.
modulo - the value to be used in the modulo calculation. Must be greater than 0.
parts - the number of parts to be created. Must be greater than 0.
IllegalArgumentException - if any of the parameters are out of range.
Method Detail


public List<Integer> generate(long value)
Create the multipart hash for the supplied value.

value - the value to be split
the number of individual parts to split into.
IllegalArgumentException - if the supplied value is less than 0


public int getSplit()

Copyright © 2003–2015 Atlassian. All rights reserved.