Kevin Roast b726c4d6db Merged DEV/TEMPORARY to HEAD
17667: Branch for SpringSurf integration - from HEAD r17665
   17668: Fix to ensure included scripts files are not loaded from a cached classpath loader.
   17670: Part 1 of SpringSurf integration - changes relating to spring-surf-core-1.0.0.CI-SNAPSHOT.jar
   17674: Part 2 of SpringSurf integration - changes relating to spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@17788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2009-12-14 13:41:05 +00:00

72 lines
1.6 KiB
Java

/**
*
*/
package org.alfresco.repo.avm.util;
import org.alfresco.repo.avm.AVMNodeConverter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.springframework.extensions.surf.util.Pair;
/**
* A utility to build a (possibly long) String representation of
* a collection of AVM path,versions. The path,versions can be recovered
* by VersionPathUnStuffer.
* @author britt
*/
public final class VersionPathStuffer
{
/**
* The internal buffer.
*/
private StringBuilder fBuilder;
/**
* Whether any paths have been added yet.
*/
private boolean fAnyAdded;
/**
* Make up one.
*/
public VersionPathStuffer()
{
fBuilder = new StringBuilder();
fAnyAdded = false;
}
/**
* Add a version path expressed by the version and path.
*/
public VersionPathStuffer add(int version, String path)
{
if (fAnyAdded)
{
fBuilder.append(';');
}
fBuilder.append(path);
fBuilder.append('@');
fBuilder.append(version);
fAnyAdded = true;
return this;
}
/**
* Add a version path expressed as a NodeRef.
*/
public VersionPathStuffer add(NodeRef nodeRef)
{
Pair<Integer, String> versionPath =
AVMNodeConverter.ToAVMVersionPath(nodeRef);
add(versionPath.getFirst(), versionPath.getSecond());
return this;
}
/**
* Get the stuffed String version of the Version/Paths contained in this.
*/
public String toString()
{
return fBuilder.toString();
}
}