|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.golden.gamedev.engine.BaseIO
public class BaseIO
Class to get external resources object, such as java.io.File
,
java.io.InputStream
, and java.net.URL
.
There are four types mode of how BaseIO
getting the external
resources object :
By default BaseIO
class is using CLASS_URL
.
Field Summary | |
---|---|
static int |
CLASS_LOADER
IO mode constant for class loader. |
static int |
CLASS_URL
IO mode constant for class url. |
static int |
SYSTEM_LOADER
IO mode constant for system loader. |
static int |
WORKING_DIRECTORY
IO mode constant for working directory. |
Constructor Summary | |
---|---|
BaseIO(Class base)
Construct new BaseIO with specified class as the base loader
using CLASS_URL mode as the default. |
|
BaseIO(Class base,
int mode)
Construct new BaseIO with specified class as the base
loader, and specified IO mode (one of CLASS_URL ,
WORKING_DIRECTORY , CLASS_LOADER ,
or SYSTEM_LOADER ). |
Method Summary | |
---|---|
Class |
getBase()
Returns the base class where the resources will be taken from. |
protected String |
getException(String path,
int mode,
String method)
Returns exception string used whenever resource can not be found. |
File |
getFile(String path)
Returns file from specified path with this BaseIO default
mode. |
File |
getFile(String path,
int mode)
Return file from specified path with specified mode. |
ClassLoader |
getLoader()
Returns the class loader associated with this BaseIO . |
int |
getMode()
Returns the default IO mode used for getting the resources. |
String |
getModeString(int mode)
Returns the official statement of specified IO mode, or [UNKNOWN-MODE] if the IO mode is undefined. |
String |
getRootPath(int mode)
Returns the root path of this BaseIO if using specified mode. |
InputStream |
getStream(String path)
Returns input stream from specified path with this BaseIO
default mode. |
InputStream |
getStream(String path,
int mode)
Returns input stream from specified path with specified mode. |
URL |
getURL(String path)
Returns URL from specified path with this BaseIO default
mode. |
URL |
getURL(String path,
int mode)
Returns URL from specified path with specified mode. |
void |
setBase(Class base)
Sets the base class where the resources will be taken from. |
File |
setFile(String path)
Returns file on specified path with this BaseIO default mode
for processing. |
File |
setFile(String path,
int mode)
Returns file on specified path with specified mode for processing. |
void |
setMode(int i)
Sets the default IO mode used for getting the resources. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int CLASS_URL
public static final int WORKING_DIRECTORY
public static final int CLASS_LOADER
public static final int SYSTEM_LOADER
Constructor Detail |
---|
public BaseIO(Class base, int mode)
BaseIO
with specified class as the base
loader, and specified IO mode (one of CLASS_URL
,
WORKING_DIRECTORY
, CLASS_LOADER
,
or SYSTEM_LOADER
).
base
- the base class loadermode
- one of IO mode constantsCLASS_URL
,
WORKING_DIRECTORY
,
CLASS_LOADER
,
SYSTEM_LOADER
public BaseIO(Class base)
BaseIO
with specified class as the base loader
using CLASS_URL
mode as the default.
base
- the base class loaderMethod Detail |
---|
public URL getURL(String path, int mode)
public URL getURL(String path)
BaseIO
default
mode.
public InputStream getStream(String path, int mode)
public InputStream getStream(String path)
BaseIO
default mode.
public File getFile(String path, int mode)
public File getFile(String path)
BaseIO
default
mode. File object usually used only for writing to disk.
Caution: always try to avoid using java.io.File
object (this method), because java.io.File
is system
dependent and not working inside jar file, use java.net.URL
OR java.io.InputStream
instead.
getURL(String)
,
getStream(String)
,
setFile(String)
public File setFile(String path, int mode)
public File setFile(String path)
BaseIO
default mode
for processing.
public String getRootPath(int mode)
BaseIO
if using specified mode.
The root path is the root where all the resources will be taken from.
For example :
The root path = "c:\games\spaceinvader"
The resource name = "images\background.png"
The resource then will be taken from =
"c:\games\spaceinvader\images\background.png"
public String getModeString(int mode)
[UNKNOWN-MODE]
if the IO mode is undefined.
getMode()
public int getMode()
setMode(int)
,
getModeString(int)
public void setMode(int i)
getMode()
,
CLASS_URL
,
WORKING_DIRECTORY
,
CLASS_LOADER
,
SYSTEM_LOADER
protected String getException(String path, int mode, String method)
public void setBase(Class base)
getBase()
public Class getBase()
setBase(Class)
public ClassLoader getLoader()
BaseIO
.
setBase(Class)
public String toString()
toString
in class Object
|
GTGE API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |