The Artima Developer Community
Sponsored Link

Java Answers Forum
When to use XML and Java

1 reply on 1 page. Most recent reply: Apr 15, 2002 8:20 AM by Singh M.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Hiran

Posts: 41
Nickname: jclu
Registered: Mar, 2002

When to use XML and Java Posted: Apr 15, 2002 8:02 AM
Reply to this message Reply
Advertisement
I was wondering when would be a good time to use XML with my Java app? Normally I would use XML to store vital information that might change pretty frequently. That way, instead of having to change my Java code every time the information changes, I just have to update the XML file. But then, wouldn't I still have to change my Java code to be able to read in the new information from the XML file and parse that information? So when would be a good time to use XML with my Java apps?

Let me demonstrate with an example of what I am talking about:
I was thinking of creating a Java word processor (but decided not to). I was planning on making this word processor similiar to JBuilder (and other IDEs) in that when a user/developer is creating a java file, my processor would try to be intuitive and helpful. It would accomplish this by having pop-up lists that come up suggesting java keywords/method names/variable names to choose from as the user is typing (similiar to what JBuilder does). This wasn't just going to be for java files, though. This word processor would do this for all programming files (java, cpp, js, xml, xsl, etc.). The way I was going to accomplish this was to create XML files that contained keywords and statements specific to each language. Then, as the user is typing, my word processor would compare the word being typed with all the keywords and statements specific to the language being used.

Now, I'm not creating this word processor as I said. But I realized that if I did, when I update the XML file with new keywords and statements, would I not have to update my Java app to be able to read in those new keywords and statements, and to use them in the comparison? If so, then would I not being doing the exact same (if not more) than programming those keywords and statements directly into my Java app?

Sorry for the long post, but I'm somewhat confused on when XML should be combined with Java, and how it should be combined so that I'm not doing the same amount (or more) work than if I were to not use XML. Please help. Thanks.
Hiran


Singh M.

Posts: 154
Nickname: ms
Registered: Mar, 2002

Re: When to use XML and Java Posted: Apr 15, 2002 8:20 AM
Reply to this message Reply
Now, I'm not creating this word processor as I said. But I realized that if I did, when I update the XML file with new keywords and statements, would I not have to update my Java app to be able to read in those new keywords and statements, and to use them in the comparison? If so, then would I not being doing the exact same (if not more) than programming those keywords and statements directly into my Java app?


well, not exactly. Supposing, you have keywords in an xml file (for a particular language, say Java), you will be reading this data at the time of startup of your application and store them in an ArrayList or some other container. No matter even if you add new keywords to the XML, at the startup they would be read and as far as comparison is concerned, that would be a breeze with the data stored in an ArrayList (or any other container of your choice).

Flat View: This topic has 1 reply on 1 page
Topic: Interface Question Previous Topic   Next Topic Topic: Java package naming conventions

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use