%PathTools
% Several tools to convert between local file paths and IRIs.

%   Copyright 2014-2016 The MathWorks, Inc.

classdef (Sealed, Hidden) PathTools < matlab.io.datastore.internal.PathTools
    methods (Static)
        % Check if the given IRI is compatible with java.net.URI and
        % Hadoop.
        function throwIfInvalidIri(iri)
            try
                java.net.URI(iri);
            catch err
                mErr = MException(message('parallel:mapreduce:InvalidURL', iri));
                mErr.addCause(err);
                throw(mErr);
            end
        end
        
        % Ensure than the input is an absolute local path.
        function path = ensureIsAbsoluteLocalPath(value)
            import parallel.internal.mapreduce.PathTools;
            
            % The rules for converting to IRI ensure absolute path as the
            % canonical form so we simply round-trip.
            path = PathTools.convertIriToLocalPath(PathTools.ensureIsIri(value));
        end
    end
    
    methods (Access = private)
        % Not instantiable
        function obj = PathTools(); end
    end
end
