- Joined
- Mar 12, 2002
Ok well as some of you may know I have been building a Java + LWJGL based game engine over the past year, and I have finally wrapped up my 3rd stage prototype game. So going forward now that I have an established set of objects, entities, and so fourth Its time to start making tools that can do bits of the game building for me.
Before anyone brings it up I am fully aware that there are indeed existing Java XML parsing libraries, however, I will not be using one for a few reasons. One of which is distribution size, another is potential platform related issues, along with a bit of my own stubbornness, and not caring to read any of there license agreements. So it falls upon me to create a system of parsing resources from text.
My plan is to attack this with a 2 part setup. Part 1 is the ResourceParser class and Part 2 will be the ResBlock class. Now this is just the initial idea and it really needs to be worked out a bit before I get neck deep down a code path thats going to bite me in the ***.
So my thoughts on doing this is that the ResourceParser is responsible for opening the text file and wrapping up the text into String arrays. It would then push that array into a new ResBlock object.
ResBlock is then responsible for handling the many lines of text. I am thinking a field known as Identity which will contain the opening tag of the given array. For example a block structured like
[resource]
.
.
.
[/resource]
Its Identity would be "resource". I am thinking It will need a few methods as well. Probably something like containsSubBlock which will search the String array for any potential sub blocks such as:
[imageResource]
file-id = ...
resource-id = ...
etc..
[/imageResource]
if a sub block is found it would return true. This would then allow the ResourceLoader to ask for the blocks. The thought is that a [resource] block could hold multiple sub resources. It would also need to be able to return these blocks one at a Time so that ResourceLoader can then take each individual resource and build them.
If anyone has experience parsing XML, or building a similar parsing tool, or even just working with one I'd absolutely ecstatic to hear your input on this. Im open to suggestions on approaching this idea from a totally different angle if it seems more appropriate. So let me know what you think people!
Before anyone brings it up I am fully aware that there are indeed existing Java XML parsing libraries, however, I will not be using one for a few reasons. One of which is distribution size, another is potential platform related issues, along with a bit of my own stubbornness, and not caring to read any of there license agreements. So it falls upon me to create a system of parsing resources from text.
My plan is to attack this with a 2 part setup. Part 1 is the ResourceParser class and Part 2 will be the ResBlock class. Now this is just the initial idea and it really needs to be worked out a bit before I get neck deep down a code path thats going to bite me in the ***.
So my thoughts on doing this is that the ResourceParser is responsible for opening the text file and wrapping up the text into String arrays. It would then push that array into a new ResBlock object.
ResBlock is then responsible for handling the many lines of text. I am thinking a field known as Identity which will contain the opening tag of the given array. For example a block structured like
[resource]
.
.
.
[/resource]
Its Identity would be "resource". I am thinking It will need a few methods as well. Probably something like containsSubBlock which will search the String array for any potential sub blocks such as:
[imageResource]
file-id = ...
resource-id = ...
etc..
[/imageResource]
if a sub block is found it would return true. This would then allow the ResourceLoader to ask for the blocks. The thought is that a [resource] block could hold multiple sub resources. It would also need to be able to return these blocks one at a Time so that ResourceLoader can then take each individual resource and build them.
If anyone has experience parsing XML, or building a similar parsing tool, or even just working with one I'd absolutely ecstatic to hear your input on this. Im open to suggestions on approaching this idea from a totally different angle if it seems more appropriate. So let me know what you think people!