Derek Hulley 1b272d6766 Merged V2.1 to HEAD
6486: Fix for AWC-1134 (Made minimum length for username and password configurable)
   6487: Added "copy.verbose" property to build script to list all files being copied in the 'deploy-tomcat-exploded' and 'deploy-webclient-changes' targets
   6488: Changed default CIFS server to remove underscore as it can cause problems with OpenOffice.
   6489: Fix for WCM-498 (Expired items that are deleted are not represented as such in the change request dialog or submit dialog)
   6490: Fix for WCM-446 and WCM-624. Multi-select and All operations in Modified Files list respect items in workflow and ignore them.
   6491: Fixes profoundly brain dead behavior in AVMLockingService.init().
   6492: Refactoring of LookupCache to be clustering compatible
   6493: Staging and locking changes
   6494: WCM Revert action moved to end of all action lists to avoid accidently clicking it (as it has no confirmation screen!)
   6496: Fixes for WCM-746 and WCM-747 - Edit File Properties and Edit Folder Properties working correctly again for AVM objects.
   6497: Enable virtualization server to be (re)started at any point prior or during the startup of the alfresco webapp (fixes WCM-750).
   6498: WCM-742 - moving locks from the preview sandbox to the main user sandbox.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6739 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2007-09-10 23:15:37 +00:00

120 lines
2.4 KiB
Java

/**
*
*/
package org.alfresco.repo.avm.util;
import java.io.Serializable;
/**
* Holds a simple path.
* @author britt
*/
public class SimplePath implements Serializable
{
private static final long serialVersionUID = 2696828491008988470L;
/**
* The names of the path's components.
*/
private String [] fNames;
/**
* Construct a new one from a string.
* @param path The String representation of the path.
*/
public SimplePath(String path)
{
if (path.length() == 0)
{
fNames = new String[0];
return;
}
while (path.startsWith("/"))
{
path = path.substring(1);
}
while (path.endsWith("/"))
{
path = path.substring(0, path.length() - 1);
}
fNames = path.split("/+");
}
/**
* Get the component name at index.
* @param index The index of the component to get.
* @return The name of the component.
*/
public String get(int index)
{
return fNames[index];
}
/**
* Get the number of components in this path.
* @return The number of components.
*/
public int size()
{
return fNames.length;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj)
{
if (this == obj)
{
return true;
}
if (!(obj instanceof SimplePath))
{
return false;
}
SimplePath o = (SimplePath)obj;
if (fNames.length != o.fNames.length)
{
return false;
}
for (int i = 0; i < fNames.length; i++)
{
if (!fNames[i].equals(o.fNames[i]))
{
return false;
}
}
return true;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode()
{
int hash = 0;
for (String name : fNames)
{
hash += name.hashCode();
}
return hash;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
for (String name : fNames)
{
builder.append('/');
builder.append(name);
}
return builder.toString();
}
}