|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjcontrol.io.Resource
public final class Resource
Implements ROM (and Flash EEPROM) resource read access for JControl.
JControls read only memories are organised primary by banks (internal ROM, and one of external flash memory)
and secondary by archieves. All archives of these banks are merged to a flat structure,
there are no directories (the path marker '/
' is part of the resource-name).
Classes are stored using their package path with the '/
' separator but
excluding the extension (".class
"). Further there in no read access to class files possible!
Resource
combines parts of classes typically known as File
and
FileInputStream
for memory reasons. The use of this class can be simple for
opening a single resource by name and reading the resource and quite complex for browsing
the contents of archives, for example:
try{ // opening a single Resource Resource r=new Resource("readme.txt"); String s=r.readLine(); // contents of the first line inside "readme.txt" [...] // listing all Resources in the first archive of the flash memory r=new Resource(FLASHACCESS); Resource bak=r; // second reference while(r!=null){ s=r.getName(); // name of the Resource [...] r=r.next(); // opens the next Resource } r=bak.nextArchive(); s=r.getName(); // name of the first Resource of the second archive } catch(IOException ioe) {}Resources are also used by other parts of the JControl API, e.g. in
Display
Resources are used to get access to bitmap graphics and fonts.
all |
Field Summary | |
---|---|
static int |
FLASHACCESS
Constructor parameter for access to the external flash memory. |
static int |
ROMACCESS
Constructor parameter for access to the internal ROM. |
Fields inherited from interface jcontrol.comm.ConsoleInputStream |
---|
LF_CHARS |
Constructor Summary | |
---|---|
Resource(int access)
Constructs access to the first resource in the first archive of the requested bank. |
|
Resource(String name)
Constructs access to a namely known resource. |
Method Summary | |
---|---|
void |
close()
Closes the resource, further reads are not possible. |
String |
getName()
Returns the name of the current resource. |
int |
length()
Returns the length of the current resource. |
Resource |
next()
Returns itself but now accessing the next resource in the current archive or null if there is no further resource or if the archive is protected from listing. |
Resource |
nextArchive()
Returns itself but now accessing the first resource in the next archive or null if there is no further archive (in the current bank). |
char |
read()
Reads a single byte from the resource. |
int |
read(byte[] buffer,
int startindex,
int length)
Reads to a byte array from the resource. |
String |
readLine()
Reads a single String from the resource. |
int |
seek(int offset,
boolean absolute)
Sets the read-pointer of this Resource to a new position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, notifyAll, wait |
Field Detail |
---|
public static final int FLASHACCESS
public static final int ROMACCESS
Constructor Detail |
---|
public Resource(int access) throws IOException
Resource
is only for accessing the default flash bank (the bank the application is running from), for
access to other banks use Flash
.
access
- to get access to internal ROM or external flash memory
IOException
- if there is no resource in the bank
(or the bank is protected from reading)ROMACCESS
,
FLASHACCESS
public Resource(String name) throws IOException
read()
method.
name
- the resource to search
IOException
- if the named resource ist not foundMethod Detail |
---|
public void close()
close()
isn't nessecary for cleanup. After close()
it's still possible to use any file and archive access methods except for reading.
close
in interface BasicInputStream
public String getName()
getName
in interface File
public int length()
length
in interface File
public Resource next()
nextArchive()
,
getName()
public Resource nextArchive()
next()
,
getName()
public char read() throws IOException
read
in interface BasicInputStream
IOException
- if the read is past resouce endpublic int read(byte[] buffer, int startindex, int length) throws IOException
read
in interface BasicInputStream
buffer
- the buffer to fillstartindex
- the index to start filling the arraylength
- number of bytes to read; the array is filled from startindex
to
startindex
+length
-1
IOException
- if the read is past resouce endpublic String readLine() throws IOException
String
from the resource.
The String is received character-by-character until an linefeed character defined in ConsoleInputStream
is received. There is a buffer if size BUFFERSIZE
allocated to store the received bytes, if the buffer
is full a linefeed is forced.
readLine
in interface ConsoleInputStream
String
read
IOException
- if an error occursString
public int seek(int offset, boolean absolute) throws IOException
Resource
to a new position.
seek
in interface File
offset
- the new positionabsolute
- if set offset
is relative to begin of FILE
otherwise relative to the
current read-pointer position
IOException
- if the new position is out of range
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |