public static CloudStoreObject extractObject( CloudPath path,
boolean preferDirectory )
{
assertValidCloudStorePath( path );
CloudStore parentStore = ( CloudStore ) path.getCloudProvider( );
CloudStoreObjectType objType = CliUtil.determinePathType( path );
switch ( objType )
{
case DIRECTORY :
return parentStore.getDirectory( path.getPath( ) );
case FILE :
return parentStore.getFile( path.getPath( ) );
case OBJECT :
if ( preferDirectory )
{
return parentStore.getDirectory( path.getPath( ) );
}
else
{
return parentStore.getFile( path.getPath( ) );
}
default :
throw new IllegalStateException( "Unknown object type '" + objType + "'." );
}