• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrapping a class

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All, I have a spellchecker module that needs to be 'wrapped'. I need to understand a bit more about the concept of wrapping a class. My end goal/task here is to 'wrap this module so that it can be used by many different applications. I have the guts of the program, Jazzy, and I need to know how to go about making the functionality accessible through wrapping. TIA
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not really sure what you're asking: is it an API? An application?
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, sorry for the ambiguity. It is an API for a spell checker program. What I am trying to take a spellchecker program and modify it to plug into a web app we have here at the college. We are using templates for profs, etc. to send mass mailings and currently there is no spell checking on it. So...long story short I am wondering how the best way to get the spellchecker integrated into the web app. I was told I need to write a wrapper class and I was wondering what all that entails. I believe that I need ti identify the API components of the spellchecker and expose them to web app? Does this sound even close to the mark? Thanks again.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not even sure why you'd need to wrap it--just include the library in your collection of web app libs and call it from within the system.
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan Grindstaff wrote:I was told I need to write a wrapper class and I was wondering what all that entails. I believe that I need ti identify the API components of the spellchecker and expose them to web app?



Yeah, that sounds right. But is this one of the cases where the pointy-haired manager says "Simple, all you have to do is..."? Or was it said by somebody who actually knows something about the application in question? I ask because the vast majority of applications don't have a published API whereby other code can access their functions.

If your application has a GUI interface that's a pretty good sign that it wasn't designed for access like that. Of course that's just a general statement, so yes. Start by identifying the spellchecker's API components.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies! I was able to download the source code and build it and it runs as an applet so maybe it cannot be accessed as a library. I was thinking of trying to integrate the spell checking classes and methods into a new library file that (as you pointed out) could be accessed as a library. Oh, also, my tech lead suggested creating a wrapper class for it. TIA.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depending on how it's set up it might be possible to use the library as-is.

Roller, a popular Java-based blogging app, seems to use Jazzy--I suspect using it as-is is trivial.
 
Paul Clapham
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan Grindstaff wrote:... it runs as an applet so maybe it cannot be accessed as a library...



Well, at least it's Java. So it might well have an API, and the applet is just an example of a wrapper which calls that API. From what David says it sounds like you have a pretty good chance.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, again for the great answers! I have some more information that I need to share. I need to somehow modify Jazzy to function on the back end so that I pass it requests from a servlet (string) and it passes back a spelling suggestion if there is an error. These are my marching orders. This seems to me to be a little cumbersome. Shouldn't there be a way to call it's functionality like a program would reference a library? Any ideas would be greatly appreciated. Thanks!
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Dan,

Here is a link to your post on the Sun Forums. Please Be forthright when posting to other sites.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dan Grindstaff wrote:Thanks, again for the great answers! I have some more information that I need to share. I need to somehow modify Jazzy to function on the back end so that I pass it requests from a servlet (string) and it passes back a spelling suggestion if there is an error. These are my marching orders. This seems to me to be a little cumbersome. Shouldn't there be a way to call it's functionality like a program would reference a library? Any ideas would be greatly appreciated. Thanks!



Have you found its API? It looks like the site completely lacks documentation, but they do provide a source-code download so you should be able to see what methods are available, and perhaps build javadocs from it to make some reference material.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your continued help and I will follow the protocol about crossing sites, sorry about that. You are absolutely right, there is no published API but javadoc comments to be extracted from the code itself. I have decided to go this route and build a summary of methods that can be called for the simplest spell checker functionality. This project is a demo for the rest of the MnSCU college dev teams so I am really building a prototype. I was hoping to get away with implementing it as simply as possible by just referencing the jar (although there doesns'nt appear to be one) in the MnSCU web app code. Oh well, I will continue on the wrapper adventure. Thanks again for all your help guys and sorry about the crossing posts boffo. Dan.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a jar; see here.

There's an Ant task to build javadocs; ant javadoc.

There's example code of how to use it:Looks like it might be British English, but it's probably trivial to figure out their dictionary format and roll your own.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Building a Jar is trivial, the core application (in the com.swabunga.spell.engine and com.swabunga.spell.event packages have no external dependencies that I can see.

I made a local copy of the API, and the code is poorly documents (no surprise I guess being as they don't provide any documentation on their website). But there is an interface called SpellDictionary which looks to be the crux of the tool. It provides methods to check if a word is correct and methods to get suggested words if it is not correct. So you will want to look at implementations of that interface.

And I am sure looking at the provided examples will help.

Looks like their download site does have a javadoc download. Check under the >Jazzy > Jazzy 0.5 > option.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(It looks like you need to create a dict directory for a compile if you're interested in building it yourself, or fix their build script. You may want to look for a more recent spellchecker.)
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All, I was thinking of turning com.swabunga.spell.engine and com.swabunga.spell.event packages bundled with the dictionary into a bean and calling the functionality from a servlet for demo purposes, then finding a way to modify the existing communications jsp to call it when I get the go ahead. We are using JBoss. Any advice is greatly appreciated. TIA.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why can't you just use the library as-is?
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David, Could you please expand on just using the library as is? Thanks, Dan.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I posted a code sample already; not sure what else to do.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I'm sorry I should be more clear. I am wondering what context to call your code from. Should I write a JSP and call it from there or how do I make use of it? Thanks, Dan.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm... I am starting to wonder exactly how you plan to use this.

What context do you WANT to use this in? You talk about wrapping it in a bean, now to call it from a JSP. What exactly are you trying to spell check? When exactly do you expect the spellchecking to occur?

My fear is that you have client - side code, say an HTML text area, and you want to spell check the contents of it. That is fine, but using JEE technologies (alone) you would do the spell checking on the Server Side. You would have to submit the form, pass the contents through the spell checker as in the code that David provided (best called from a Servlet or an action class called from the Servlet), then send the results of the spell check back to the client. This sounds a bit out of the way, but if you are good with Ajax it may not be so tough.

If you want to spell check as the customer types, or as close to it as possible without the cost of 1 or more server round-trips then you need to work with client-side technologies. That would be Javascript for the most part. My first thought would be to see if there are already-implemented Javascript spell checkers.

If you need to use a Java spellchecker, but you want to do it client-side then you are really left with an Applet.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Steve Luke wrote:My fear is that you have client - side code, say an HTML text area, and you want to spell check the contents of it. That is fine, but using JEE technologies (alone) you would do the spell checking on the Server Side. You would have to submit the form, pass the contents through the spell checker as in the code that David provided (best called from a Servlet or an action class called from the Servlet), then send the results of the spell check back to the client. This sounds a bit out of the way, but if you are good with Ajax it may not be so tough..



Hi, This is exactly what I want to do. That is why I was thinking the bean residing on the app server would work. I am not very good with AJAX but was told I need to ramp up on JSON to pass results back to the page.
 
Steve Luke
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The you don't need to create a 'bean' or wrap the API in any way. Just use a Servlet which would be designed to receive the requests from Javascript, translates it into text and then feeds it directly into the API. I think David's example is spot on for the type of code you would need to put into the Servlet for the spell checking part.

Catch up on JSON and AJAX, as well as basic Servlet communications to address the rest.
 
Dan Grindstaff
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! David, Steve and Paul! I appreciate you being willing to help out in such great detail. I really needed this!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic