Class URIUtils


  • public final class URIUtils
    extends Object
    Helper methods for conversions between different types of resource identifiers
    Version:
    $Rev$
    Author:
    herrmama, $Author$
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.eclipse.core.resources.IFile getFile​(org.eclipse.emf.common.util.URI uri)
      Convert EMF URI to Eclipse file
      static org.eclipse.core.resources.IFolder getFolder​(org.eclipse.emf.common.util.URI uri)
      Convert EMF URI to Eclipse folder
      static InputStream getInputStream​(org.eclipse.emf.common.util.URI uri)
      Get an input stream from the given URI.
      static File getJavaFile​(org.eclipse.emf.common.util.URI uri)
      Get the Java file for a URI
      static OutputStream getOutputStream​(org.eclipse.emf.common.util.URI uri)
      Get an output stream from the given URI.
      static org.eclipse.emf.common.util.URI getRelativePath​(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.common.util.URI relativeTo)
      Get the relative path of a URI w.r.t.
      static org.eclipse.emf.common.util.URI getURI​(File file)
      Convert a file name to an EMF URI
      static org.eclipse.emf.common.util.URI getURI​(String fileName)
      Convert a file name to an EMF URI
      static org.eclipse.emf.common.util.URI getURI​(URL url)
      Get EMF URI from Java URL
      static org.eclipse.emf.common.util.URI getURI​(org.eclipse.core.resources.IResource file)
      Convert Eclipse resource to EMF URI
      static org.eclipse.emf.common.util.URI getURI​(org.eclipse.core.runtime.IPath path)
      Create an EMF URI from an Eclipse path
      static URL getURL​(org.eclipse.emf.common.util.URI uri)
      Get Java URL from EMF URI
      static String incrementVersionSegment​(String segment)
      Increment the first part of a version number in a URI segment, as might be in a package namespace URI, if it appears to contain a version number.
      static org.eclipse.core.resources.IFile replaceExtension​(org.eclipse.core.resources.IFile file, String ext)
      Replace extension of a file
      static org.eclipse.emf.common.util.URI replaceExtension​(org.eclipse.emf.common.util.URI uri, String ext)
      Replace extension of a EMF URI
    • Method Detail

      • getFile

        public static org.eclipse.core.resources.IFile getFile​(org.eclipse.emf.common.util.URI uri)
        Convert EMF URI to Eclipse file
      • getFolder

        public static org.eclipse.core.resources.IFolder getFolder​(org.eclipse.emf.common.util.URI uri)
        Convert EMF URI to Eclipse folder
      • getURI

        public static org.eclipse.emf.common.util.URI getURI​(org.eclipse.core.resources.IResource file)
        Convert Eclipse resource to EMF URI
      • getURI

        public static org.eclipse.emf.common.util.URI getURI​(org.eclipse.core.runtime.IPath path)
        Create an EMF URI from an Eclipse path
      • getURI

        public static org.eclipse.emf.common.util.URI getURI​(String fileName)
        Convert a file name to an EMF URI
        Parameters:
        fileName -
        Returns:
        EMF URI
      • getURI

        public static org.eclipse.emf.common.util.URI getURI​(File file)
        Convert a file name to an EMF URI
        Parameters:
        file -
        Returns:
        EMF URI
      • getURL

        public static URL getURL​(org.eclipse.emf.common.util.URI uri)
        Get Java URL from EMF URI
        Parameters:
        uri - EMF URI
        Returns:
        Java URL
      • getURI

        public static org.eclipse.emf.common.util.URI getURI​(URL url)
        Get EMF URI from Java URL
        Parameters:
        url - Java URL
        Returns:
        EMF URI
      • replaceExtension

        public static org.eclipse.core.resources.IFile replaceExtension​(org.eclipse.core.resources.IFile file,
                                                                        String ext)
        Replace extension of a file
        Parameters:
        file - File
        ext - New extension
        Returns:
        New file
      • replaceExtension

        public static org.eclipse.emf.common.util.URI replaceExtension​(org.eclipse.emf.common.util.URI uri,
                                                                       String ext)
        Replace extension of a EMF URI
        Parameters:
        uri - EMF URI
        ext - New extension
        Returns:
        New EMF URI
      • getJavaFile

        public static File getJavaFile​(org.eclipse.emf.common.util.URI uri)
        Get the Java file for a URI
        Parameters:
        uri -
        Returns:
        Java file
      • getInputStream

        public static InputStream getInputStream​(org.eclipse.emf.common.util.URI uri)
        Get an input stream from the given URI.
        Returns:
        an InputStream or null if no stream could be created
      • getOutputStream

        public static OutputStream getOutputStream​(org.eclipse.emf.common.util.URI uri)
        Get an output stream from the given URI.
        Returns:
        an OutputStream or null if no stream could be created
      • getRelativePath

        public static org.eclipse.emf.common.util.URI getRelativePath​(org.eclipse.emf.common.util.URI uri,
                                                                      org.eclipse.emf.common.util.URI relativeTo)
        Get the relative path of a URI w.r.t. another URI.
      • incrementVersionSegment

        public static String incrementVersionSegment​(String segment)
        Increment the first part of a version number in a URI segment, as might be in a package namespace URI, if it appears to contain a version number.
        Parameters:
        segment - an URI segment
        Returns:
        the incremented segment, or just the segment as is if it does not appear to be or to contain a discrete a version number