Package org.ringojs.repository
Interface Resource
-
- All Superinterfaces:
java.io.Serializable
,Trackable
- All Known Implementing Classes:
AbstractResource
,FileResource
,StringResource
,WebappResource
,ZipResource
public interface Resource extends Trackable
Resource represents a pointer to some kind of information (code, skin, ...) from which the content can be fetched
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getBaseName()
Returns the short name of the resource with the file extension (everything following the last dot character) cut off.java.lang.String
getContent()
Returns the content of the resourcejava.lang.String
getContent(java.lang.String encoding)
Returns the content of the resource in a given encodingjava.io.InputStream
getInputStream()
Returns an input stream to the content of the resourcelong
getLength()
Returns the length of the resource's contentint
getLineNumber()
Return the current line number of this resource.java.io.Reader
getReader()
Returns a reader for the resourcejava.io.Reader
getReader(java.lang.String encoding)
Returns a reader for the resource using the given character encodingjava.lang.String
getRelativePath()
Get the path of this resource relative to its root repository.boolean
getStripShebang()
Returns true if the input stream for this resource will look for a first line starting with the characters #! and suppress it if foundvoid
setStripShebang(boolean stripShebang)
Switch shebang stripping on or off-
Methods inherited from interface org.ringojs.repository.Trackable
exists, getChecksum, getModuleName, getName, getParentRepository, getPath, getRootRepository, getUrl, isAbsolute, lastModified, setAbsolute
-
-
-
-
Method Detail
-
getLength
long getLength()
Returns the length of the resource's content- Returns:
- content length
-
getInputStream
java.io.InputStream getInputStream() throws java.io.IOException
Returns an input stream to the content of the resource- Returns:
- content input stream
- Throws:
java.io.IOException
- if a I/O related error occurs
-
getReader
java.io.Reader getReader(java.lang.String encoding) throws java.io.IOException
Returns a reader for the resource using the given character encoding- Parameters:
encoding
- the character encoding- Returns:
- the reader
- Throws:
java.io.IOException
- if a I/O related error occurs
-
getReader
java.io.Reader getReader() throws java.io.IOException
Returns a reader for the resource- Returns:
- the reader
- Throws:
java.io.IOException
- if a I/O related error occurs
-
getContent
java.lang.String getContent(java.lang.String encoding) throws java.io.IOException
Returns the content of the resource in a given encoding- Parameters:
encoding
- the character encoding- Returns:
- the content
- Throws:
java.io.IOException
- if a I/O related error occurs
-
getContent
java.lang.String getContent() throws java.io.IOException
Returns the content of the resource- Returns:
- the content
- Throws:
java.io.IOException
- if a I/O related error occurs
-
getBaseName
java.lang.String getBaseName()
Returns the short name of the resource with the file extension (everything following the last dot character) cut off.- Returns:
- the file name without the file extension
-
getRelativePath
java.lang.String getRelativePath()
Get the path of this resource relative to its root repository.- Specified by:
getRelativePath
in interfaceTrackable
- Returns:
- the relative resource path
-
getStripShebang
boolean getStripShebang()
Returns true if the input stream for this resource will look for a first line starting with the characters #! and suppress it if found- Returns:
- true if shebang stripping is enabled
-
setStripShebang
void setStripShebang(boolean stripShebang)
Switch shebang stripping on or off- Parameters:
stripShebang
- true to enable shebang stripping
-
getLineNumber
int getLineNumber()
Return the current line number of this resource. Useful in combination with things like shebang stripping and shell input.- Returns:
- the current line number of this resource
-
-