Class ClasspathResourceSource

    • Field Detail

      • CLASSPATH_SCHEME

        public static final java.lang.String CLASSPATH_SCHEME
        URI scheme for classpath resources: "classpath"
        Since:
        1.3
        See Also:
        Constant Field Values
      • classpathResourceName

        private final java.lang.String classpathResourceName
    • Constructor Detail

      • ClasspathResourceSource

        private ClasspathResourceSource​(java.lang.String classpathResourceName)
      • ClasspathResourceSource

        private ClasspathResourceSource​(java.lang.String classpathResourceName,
                                        FilePosition filePosition)
    • Method Detail

      • from

        public static ClasspathResourceSource from​(java.lang.String classpathResourceName)
        Create a new ClasspathResourceSource using the supplied classpath resource name.

        The name of a classpath resource must follow the semantics for resource paths as defined in ClassLoader.getResource(String).

        If the supplied classpath resource name is prefixed with a slash (/), the slash will be removed.

        Parameters:
        classpathResourceName - the name of the classpath resource; never null or blank
        See Also:
        ClassLoader.getResource(String), ClassLoader.getResourceAsStream(String), ClassLoader.getResources(String)
      • from

        public static ClasspathResourceSource from​(java.lang.String classpathResourceName,
                                                   FilePosition filePosition)
        Create a new ClasspathResourceSource using the supplied classpath resource name and FilePosition.

        The name of a classpath resource must follow the semantics for resource paths as defined in ClassLoader.getResource(String).

        If the supplied classpath resource name is prefixed with a slash (/), the slash will be removed.

        Parameters:
        classpathResourceName - the name of the classpath resource; never null or blank
        filePosition - the position in the classpath resource; may be null
      • from

        public static ClasspathResourceSource from​(java.net.URI uri)
        Create a new ClasspathResourceSource from the supplied URI.

        The path component of the URI (excluding the query) will be used as the classpath resource name. The query component of the URI, if present, will be used to retrieve the FilePosition via FilePosition.fromQuery(String).

        Parameters:
        uri - the URI for the classpath resource; never null
        Returns:
        a new ClasspathResourceSource; never null
        Throws:
        PreconditionViolationException - if the supplied URI is null or if the scheme of the supplied URI is not equal to the CLASSPATH_SCHEME
        Since:
        1.3
        See Also:
        CLASSPATH_SCHEME
      • getClasspathResourceName

        public java.lang.String getClasspathResourceName()
        Get the name of the source classpath resource.

        The name of a classpath resource follows the semantics for resource paths as defined in ClassLoader.getResource(String).

        See Also:
        ClassLoader.getResource(String), ClassLoader.getResourceAsStream(String), ClassLoader.getResources(String)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object