Top Fields Constructors Methods
org.jruby.util

public Class URLResource

extends Object
implements FileResource, FileResourceExt
Class Inheritance
All Implemented Interfaces
org.jruby.util.DummyResourceStat.FileResourceExt, org.jruby.util.FileResource
Imports
java.io.*, java.net.MalformedURLException, .URI, .URISyntaxException, .URL, .URLClassLoader, java.nio.channels.Channel, .Channels, java.nio.file.attribute.FileTime, java.util.*, jnr.constants.platform.Errno, jnr.posix.FileStat, org.jruby.Ruby, .RubyInstanceConfig

Field Summary

Modifier and TypeField and Description
private final ClassLoader
public static final String
private final String[]
private final String
public static final String
private final String
public static final String
private final URL

Constructor Summary

AccessConstructor and Description
pack-priv
URLResource(String uri, URL url, String[] files)

pack-priv
URLResource(String uri, ClassLoader cl, String pathname, String[] files)

private
URLResource(String uri, URL url, ClassLoader cl, String pathname, String[] files)

Method Summary

Modifier and TypeMethod and Description
public String
private static boolean
addDirectoriesFromClassloader(ClassLoader cl, Set<String> list, String pathname, boolean isDirectory)

private static boolean
addDirectoryEntries(Set<String> entries, URL url, boolean isDirectory)

public boolean
public String
public boolean
public boolean
private static void
close(final Closeable resource)

public static FileResource
create(Ruby runtime, String pathname, boolean asFile)

public static FileResource
createClassloaderURI(Ruby runtime, String pathname, boolean asFile)

private static FileResource
createRegularURI(String pathname, boolean asFile)

public FileTime
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public int
public boolean
public static URL
getResourceURL(Ruby runtime, String location)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
public boolean
public FileTime
public long
public FileTime
public long
public String[]
private static String[]
listClassLoaderFiles(ClassLoader classloader, String pathname)

private static String[]
listFiles(String pathname)

private static String[]
public FileStat
public Channel
openChannel(int flags, int perm)

Implements org.jruby.util.FileResource.openChannel.

public InputStream
openInputStream()

Implements org.jruby.util.FileResource.openInputStream.

Opens a new input stream to read the contents of a resource and returns it.

public String
public FileStat
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public <T> T
unwrap(Class<T> type)

Implements org.jruby.util.FileResource.unwrap.

Unwrap the resource backend (replacement for hackyGetJRubyFile()).

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

clback to summary
private final ClassLoader cl
CLASSLOADERback to summary
public static final String CLASSLOADER
listback to summary
private final String[] list
pathnameback to summary
private final String pathname
URIback to summary
public static final String URI
uriback to summary
private final String uri
URI_CLASSLOADERback to summary
public static final String URI_CLASSLOADER
urlback to summary
private final URL url

Constructor Detail

URLResourceback to summary
pack-priv URLResource(String uri, URL url, String[] files)
URLResourceback to summary
pack-priv URLResource(String uri, ClassLoader cl, String pathname, String[] files)
URLResourceback to summary
private URLResource(String uri, URL url, ClassLoader cl, String pathname, String[] files)

Method Detail

absolutePathback to summary
public String absolutePath()

Implements org.jruby.util.FileResource.absolutePath.

Annotations
@Override
addDirectoriesFromClassloaderback to summary
private static boolean addDirectoriesFromClassloader(ClassLoader cl, Set<String> list, String pathname, boolean isDirectory) throws IOException
addDirectoryEntriesback to summary
private static boolean addDirectoryEntries(Set<String> entries, URL url, boolean isDirectory)
canExecuteback to summary
public boolean canExecute()

Implements org.jruby.util.FileResource.canExecute.

Annotations
@Override
canonicalPathback to summary
public String canonicalPath()

Implements org.jruby.util.FileResource.canonicalPath.

Annotations
@Override
canReadback to summary
public boolean canRead()

Implements org.jruby.util.FileResource.canRead.

Annotations
@Override
canWriteback to summary
public boolean canWrite()

Implements org.jruby.util.FileResource.canWrite.

Annotations
@Override
closeback to summary
private static void close(final Closeable resource)
createback to summary
public static FileResource create(Ruby runtime, String pathname, boolean asFile)
createClassloaderURIback to summary
public static FileResource createClassloaderURI(Ruby runtime, String pathname, boolean asFile)
createRegularURIback to summary
private static FileResource createRegularURI(String pathname, boolean asFile)
creationTimeback to summary
public FileTime creationTime()

Implements org.jruby.util.DummyResourceStat.FileResourceExt.creationTime.

equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
errnoback to summary
public int errno()

Implements org.jruby.util.FileResource.errno.

Annotations
@Override
existsback to summary
public boolean exists()

Implements org.jruby.util.FileResource.exists.

Annotations
@Override
getResourceURLback to summary
public static URL getResourceURL(Ruby runtime, String location)
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isDirectoryback to summary
public boolean isDirectory()

Implements org.jruby.util.FileResource.isDirectory.

Annotations
@Override
isFileback to summary
public boolean isFile()

Implements org.jruby.util.FileResource.isFile.

Annotations
@Override
lastAccessTimeback to summary
public FileTime lastAccessTime()

Implements org.jruby.util.DummyResourceStat.FileResourceExt.lastAccessTime.

lastModifiedback to summary
public long lastModified()

Implements org.jruby.util.FileResource.lastModified.

Annotations
@Override
lastModifiedTimeback to summary
public FileTime lastModifiedTime()

Implements org.jruby.util.DummyResourceStat.FileResourceExt.lastModifiedTime.

lengthback to summary
public long length()

Implements org.jruby.util.FileResource.length.

Annotations
@Override
listback to summary
public String[] list()

Implements org.jruby.util.FileResource.list.

Annotations
@Override
listClassLoaderFilesback to summary
private static String[] listClassLoaderFiles(ClassLoader classloader, String pathname)
listFilesback to summary
private static String[] listFiles(String pathname)
listFilesFromInputStreamback to summary
private static String[] listFilesFromInputStream(InputStream is)
lstatback to summary
public FileStat lstat()

Implements org.jruby.util.FileResource.lstat.

Annotations
@Override
openChannelback to summary
public Channel openChannel(int flags, int perm) throws IOException

Implements org.jruby.util.FileResource.openChannel.

Annotations
@Override
openInputStreamback to summary
public InputStream openInputStream() throws IOException

Implements org.jruby.util.FileResource.openInputStream.

Doc from org.jruby.util.FileResource.openInputStream.

Opens a new input stream to read the contents of a resource and returns it. Note that implementations may be allocating native memory for the stream, so callers need to close this when they are done with it. users of this method should follow the pattern: close the stream where you open it.

Returns:InputStream

InputStream

Annotations
@Override
pathback to summary
public String path()

Implements org.jruby.util.FileResource.path.

Annotations
@Override
statback to summary
public FileStat stat()

Implements org.jruby.util.FileResource.stat.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
unwrapback to summary
public <T> T unwrap(Class<T> type) throws UnsupportedOperationException

Implements org.jruby.util.FileResource.unwrap.

Doc from org.jruby.util.FileResource.unwrap.

Unwrap the resource backend (replacement for hackyGetJRubyFile()).

Returns:T

backend if supported

Annotations
@Override