my class has a method as follow :
private volatile String currentSeqSecondBucket = "";
private volatile int currentUriSeq = 0;
public String calculateRepositoryURI(Date now, String userSpecifiedFolder)
{
String folder = userSpecifiedFolder;
if (StringUtils.isBlank(folder))
folder = RSIConstant.CONTENT_ROOT_FOLDER;
StringBuilder buf = new StringBuilder(folder);
if (!folder.endsWith("/"))
buf.append("/");
String nowStr = YYYYMMDDHHMMSS_FORMAT.format(now);
buf.append(String.valueOf((int)(Math.random() * 1000)));
buf.append("/");
buf.append(nowStr);
buf.append("_");
synchronized (this)// here the this means my class
{
if (currentSeqSecondBucket.equals(nowStr))
{
currentUriSeq++;
}
else
{
currentUriSeq = 1;
currentSeqSecondBucket = nowStr;
}
buf.append(String.valueOf(currentUriSeq));
}
buf.append(".xml");
return buf.toString();
}
Will this code return a unique string for every call?