B
bugnthecode
Hi, I've got something I'd like to do, but I'm not exactly sure what it
would be called. Basically it is a search and replace. I'll have a
"template" file setup with tokens on the lines like $name &
$phone_number. What I want to do is parse the file and replace each
token with a member from a specified object.
Psuedo code:
open file in read mode // test file defined below code block
while (line = readline()) not EOF
while (word = nextword()) not null
if word equals any predefined token // $user, $name, $phone_number,
$email etc...
send matching member variable to string builder //
tokenHolder.user, tokenHolder.name etc...
else
send word to string builder
endif
close file
end psuedo code
//test file
Hello $user, my name is $name.
My phone number is $phone_number
Please email me at $email
//end test file
This is a basic example of what I'm trying do. Basically this will
allow users of my program define their own template and wording without
the need of diving into any actual code.
My problem is not implementing this. I would probably end up using
regular expressions to do the matching. What I am asking is if there is
a term for this so that I may do google searching for libraries, or do
you know of any java libraries that already do this so I don't have to
roll my own?
Thanks,
Will
would be called. Basically it is a search and replace. I'll have a
"template" file setup with tokens on the lines like $name &
$phone_number. What I want to do is parse the file and replace each
token with a member from a specified object.
Psuedo code:
open file in read mode // test file defined below code block
while (line = readline()) not EOF
while (word = nextword()) not null
if word equals any predefined token // $user, $name, $phone_number,
$email etc...
send matching member variable to string builder //
tokenHolder.user, tokenHolder.name etc...
else
send word to string builder
endif
close file
end psuedo code
//test file
Hello $user, my name is $name.
My phone number is $phone_number
Please email me at $email
//end test file
This is a basic example of what I'm trying do. Basically this will
allow users of my program define their own template and wording without
the need of diving into any actual code.
My problem is not implementing this. I would probably end up using
regular expressions to do the matching. What I am asking is if there is
a term for this so that I may do google searching for libraries, or do
you know of any java libraries that already do this so I don't have to
roll my own?
Thanks,
Will