How to write a wrapper class

I am new to the concept of wrapper classes. I have a small spell checker program that I need to access via a servlet by passing a string in and getting a string out with spelling suggestions. I could really use some advice on how to write a servlet that would do such a thing. TIA

grin1dan wrote:
I am new to the concept of wrapper classes. I have a small spell checker program that I need to access via a servlet by passing a string in and getting a string out with spelling suggestions. I could really use some advice on how to write a servlet that would do such a thing. TIABasically, a wrapper class is a class that "wraps" another - otherwise referred to as a "HAS-A" relationship (as opposed to a sub-class, which involves an "IS-A" relationship). It does this by including an instance of the wrapped class as one of its fields.
In many cases, wrapping is actually superior to inheritance.
I don't know how this fits with your servlet, but - assuming that your SpellChecker is implemented as a class - all you need to do is have your servlet define a "spellchecker" field; perhaps something like:
private final SpellChecker spellCheck = new SpellChecker();Probably worth reading up on though. Google "wrapper classes" and "forwarders".
Winston

Similar Messages

  • How to get SDKODBC Wrapper class for indesign cs3

    Hi,
         I have to implement the mysql database with my indesign plugin. I didn't have a SDKODBC Wrapper class. Can any one say how to get SDKODBC Wrapper class from adobe.
    Regards,
    saravanan.

    I doubt if change documents are generated for SE78 transaction.
    For list of change documents defined, please check table: TCDOB.
    Hope this helps.
    Kind Regards
    Eswar

  • Best way to write an Wrapper class around a POJO

    Hi guys,
    What is the best way to write an Wrapper around a Hibernate POJO, given the latest 2.2 possibilities? The goal is, of course, to map 'regular' Java Bean properties to JavaFX 2 Properties, so that they can be used in GUI.
    Thanks!

    what about this:
    import javafx.beans.property.SimpleStringProperty;
    import javafx.beans.property.StringProperty;
    public class PersonPropertyWrapper {
         private StringProperty firstName;
         private StringProperty lastName;
         private Person _person;
         public PersonPropertyWrapper(Person person) {
              super();
              this._person = person;
              firstName = new SimpleStringProperty(_person.getFirstName()) {
                   @Override
                   protected void invalidated() {
                        _person.setFirstName(getValue());
              lastName = new SimpleStringProperty(_person.getLastName()) {
                   @Override
                   protected void invalidated() {
                        _person.setLastName(getValue());
         public StringProperty firstNameProperty() {
              return firstName;
         public StringProperty lastNameProperty() {
              return lastName;
         public static class Person {
              private String firstName;
              private String lastName;
              public String getFirstName() {
                   return firstName;
              public void setFirstName(String firstName) {
                   this.firstName = firstName;
              public String getLastName() {
                   return lastName;
              public void setLastName(String lastName) {
                   this.lastName = lastName;
         public static void main(String[] args) {
              Person p = new Person();
              p.setFirstName("Jim");
              p.setLastName("Green");
              PersonPropertyWrapper wrapper = new PersonPropertyWrapper(p);
              wrapper.firstNameProperty().setValue("Jerry");
              System.out.println(p.getFirstName());
    }Edited by: 906680 on 2012-7-27 上午10:56

  • How to see the wrapper classes generated for CMP 2.1 in jdeveloper10g

    I have developed CMP entity bean (2.1) using jdeveloper wizard. I want to see the wrapper class generated for the bean. How can I do that in jdeveloper 10g.

    No you got me wrong. I wan't to see the actual implementated classes (extended from the generated bean) by the container. ie the ones that actually run in the container.
    rgds,
    Jatin

  • How to write c wrapper it containing callback functions

    hi here shambhu below call can be containing some call back functions ,how can create wrapper for this,please suggest me
    _export int GDSRegisterStation(char *sPort, char* sPanel, int iStation, GDSCallback lpGDSTaskCall); /*
    This call hooks up user application onto the GDS environment. From this point on, the GDS application has continuous, concurrent access to the virtual machine representing the test system. As multiple independent test systems may be hooked onto the same host computer, the call needs to specify a "Port" (unsigned uPort) to which GDS memory access is sought. Character string sPanel (up to 63 chars) identifies the calling GDS task to the Virtual Machine. This entry will assist the System Manager in monitoring active GDS tasks by their assigned names. As multiple test stations (each with one or more control channels) may be associated with the same controller, (int) iStation specifies the station to which this application will be connected. (GDSCallback) lpGDSTaskCal specifies the subroutine in the user application that is to be installed as the real-time callback into the Virtual Machine. From this moment on, the specified subroutine will be automatically called by the Virtual Machine to periodically All subsequent calls to the GDS library will apply to this Station and its control channels. This call is made only once and prior to other GDS calls. 0 is returned upon normal completion -1 is returned if the call was a failure due to absence of GDS space associated with the call. Make sure station is connected and On-Line and make sure Port No was correct in the call -2 is returned if the application was already registered by a previous call

    You will have to write a wrapper DLL in C which converts the callback event into a LabVIEW compatible event. The most versatile way would be to generate a user event with the PostLVUserEvent() LabVIEW manager function. Callback functions are however an advanced C programming construct, so you should definitely have a pretty decent understanding of C programming before starting this endeavour. Otherwise you end up with a not working solution or maybe even worse, one that seems to work sometimes but doesn't really do the right thing.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How do I create Wrapper class for Message Box?

    I want to create Wrapper class for Message Box class in my project. I am using Telerik Testing FrameWork. In that message box was not recognized in unit testing thats y i want to create wrapper class, for creating the
    instance for that mesage box.

    A wrapper class is simply a class that for example wraps another object or a subset of its methods. You could just create a class that exposes the same methods as the MessageBox and uses the MessageBox internally.
    If you define an interface and program against this in your application, you could replace your wrapper object with another object that implements the same interface when you are doing the unit tests. Something like this:
    public interface IMessageBoxWrapper
    System.Windows.Forms.DialogResult Show(string text, string caption);
    public class MessageBoxWrapper
    public System.Windows.Forms.DialogResult Show(string text, string caption)
    return System.Windows.Forms.MessageBox.Show(text, caption);
    public class MockMessageBoxWrapper
    public System.Windows.Forms.DialogResult Show(string text, string caption)
    return System.Windows.Forms.DialogResult.OK;
    private readonly IMessageBoxWrapper _mbw;
    public Form1(IMessageBoxWrapper mbw)
    InitializeComponent();
    _mbw = mbw;
    private void SomeMethod()
    _mbw.Show("...", "...");
    Hope that helps.
    Please remember to close your threads by marking all helpful posts as answer and please start a new thread if you have a new question.

  • How to keep track of status using wrapper class?

    Hi,
    I got the following code on the server side:
    ..........//this method invocation may take a long time to do
    Object methodResult = method.invoke(object, args);
    if (methodResult != null) //method invocation return results
          //convert the methodResult Object into JDOM Element   
         ObjectWriter writer = new SimpleWriter();  
         Element element = writer.write(methodResult); 
         //return result to client--------------------------------------------------------  
         //Results tag to notify incoming result from method invocation on next incoming byte  
         out.println("Results"); 
         //convert the element into String  
        String strXML = Util.convertXMLtoString(element);  
        //send the String xml out to the client. The client will receive the string representation of the xml  
        out.println("strXML):        
    else //there are no results return from method invocation
        //save the result into xml file  
        Util.createFile(element, new File(filename));
    .......................The problem is how to I keep track of the status of the method invocation.
    As can be seen from the above code, Object methodResult = method.invoke(object, args);
    the method invocation will take a long time!
    How do I write a wrapper class to keep track of the status of the method invocation that can be check by the client? I am thinking of using a url to keep track of method invocation so that the client can continously poll the wrapper object to check if the method invocation has finished.
    Can anyone change my code and give advice?
    Thanks a lot!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

    No,
    I am not using Java threads at all.
    I just need to keep track of the status of the method invocation and report to the client.
    Sometimes, the method invocation can take ages so it is not acceptable for the client to invoke a method and wait a long time without any response: but in fact the server is still in the process of executing the method.
    Please advice.

  • How do i set up the wrapper classes in borland c++ for CWIMAQFullParticleReport

    I am using the IMAQVision version 1.0 ActiveX control in a Borland C++ 5 environment. I am happy that this is working but cannot find an example or help file that indicates how to create the wrapper classes for this environment, for example _CWIMAQFullParticleReport. I realise this may be a hole in my knowledge but would very much appreciate if somebody could point me in the right direction!

    Hello m2ls,
    I found a video on HP's YouTube channel, HP Printer Support. I think this will solve your problem.
    The video shows how to scan to you Mac Yosemite computer with an HP scanner without installing HP software.
    http://youtu.be/HVCE7dq8g6E?list=UUHranSHHa1qo6Pg4​JStkL7Q
    I hope this helps.
    Thanks,
    -hjs_19 *I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution. Click the “Kudos Thumbs Up" on the bottom right of this post to say "Thanks" for helping!

  • Wrapper class

    Hello,
    ist it possible to write a wrapper class for a BPEL process? How can i do it?
    Thanks,
    Matthias

    I am not sure you can do it or not. But I am wondering why you need to do this ?
    You can initiate any process using the Java API as well as through web service call.
    Could you please elaborate your usecase for this ?
    Thanks,
    Rakesh

  • (I can't compile it .I don't know how to write constructor in Initial Class

    All class and main program is OK except the inital class.
    Author Class
    class Author {
    private String authorName;
    private Initials inits;
    private int numTitles = 0;
    // PRE True POST Prompts user for details
    // and RETURNS new Author constructed from details
    public Author(BufferedReader in) {
    System.out.print("\nSurname ==> ");
    authorName = Text.ReadString(in);
    inits = new Initials(in);
    numTitles = 0;
    // PRE TRUE
    // POST RETURNS String representation of Author
    public String toString() {
    String result;
    result = "NAME : " + authorName + " " + inits.toString() + "\n";
    result = result + "Number of titles is " + numTitles;
    return(result);
    // PRE TRUE
    // POST Increments number of titles
    public void incTitles() {
    numTitles++;
    Book Class
    public class Book {
    private String title;
    private Author author;
    // PRE TRUE // POST Prompts user for details
    // and RETURNS new Author constructed from details
    public Book(Author author, BufferedReader in) {
    System.out.print("\nTitle ==> ");
    title = Text.ReadString(in);
    this.author = author;
    author.incTitles();
    // PRE TRUE
    // POST RETURNS String representation of Book
    public String toString() {
    String result;
    result = "TITLE : " + title + "\n";
    result = result + "AUTHOR\n" + author.toString() + "\n";
    return(result);
    *****Initial Class (I can't compile it . I don't know how to write constructor
    class Initials
    {   private char[] inits;
         public Initials(BufferedReader in)
         System.out.print("\nInitails Testing ==> ");
         inits = Text.ReadString(in);
         public String toString()
              String result;
              result="Testing";
              return(result);
    Main program
    public class BookMain {
    static private BufferedReader in = new BufferedReader(new                                    InputStreamReader(System.in));
    public static void main(String[] args) {
    Author authorRec1, authorRec2;
    Book bookRec1, bookRec2;
    System.out.println("\n\n****** First author input");
    authorRec1 = new Author(in);
    System.out.println("\n\n****** First author output\n" + authorRec1.toString());
    System.out.println("\n\n****** Second author input");
    authorRec2 = new Author(in);
    System.out.println("\n\n****** Second author output\n" + authorRec2.toString());
         System.out.println("\n\n****** First book input");
    bookRec1 = new Book(authorRec2, in);
    System.out.println("\n\n****** First book output\n" + bookRec1.toString());
    System.out.println("\n\n****** Second book input");
    bookRec2 = new Book(authorRec2, in);
    System.out.println("\n\n****** Second book output\n" + bookRec2.toString());
    System.out.println("\n\n****** First book output\n" + bookRec1.toString());

    Change this
    class Initials {
    private char[] inits;
    to this
    class Initials {
    private String inits;
    import java.io.*;
    public class BookTest {
      static private BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
      public static void main(String[] args) {
        Author authorRec1, authorRec2;
        Book bookRec1, bookRec2;
        System.out.println("\n\n****** First author input");
        authorRec1 = new Author(in);
        System.out.println("\n\n****** First author output\n" + authorRec1.toString());
        System.out.println("\n\n****** Second author input");
        authorRec2 = new Author(in);
        System.out.println("\n\n****** Second author output\n" + authorRec2.toString());
        System.out.println("\n\n****** First book input");
        bookRec1 = new Book(authorRec2, in);
        System.out.println("\n\n****** First book output\n" + bookRec1.toString());
        System.out.println("\n\n****** Second book input");
        bookRec2 = new Book(authorRec2, in);
        System.out.println("\n\n****** Second book output\n" + bookRec2.toString());
        System.out.println("\n\n****** First book output\n" + bookRec1.toString());
    class Author {
      private String authorName;
      private Initials inits;
      private int numTitles = 0;
      // PRE True POST Prompts user for details
      // and RETURNS new Author constructed from details
      public Author(BufferedReader in) {
        System.out.print("\nSurname ==> ");
        authorName = Text.ReadString(in);
        inits = new Initials(in);
        numTitles = 0;
      // PRE TRUE
      // POST RETURNS String representation of Author
      public String toString() {
        String result;
        result = "NAME : " + authorName + " " + inits.toString() + "\n";
        result = result + "Number of titles is " + numTitles;
        return(result);
      // PRE TRUE
      // POST Increments number of titles
      public void incTitles() {
        numTitles++;
    class Book {
      private String title;
      private Author author;
      // PRE TRUE // POST Prompts user for details
      // and RETURNS new Author constructed from details
      public Book(Author author, BufferedReader in) {
        System.out.print("\nTitle ==> ");
        title = Text.ReadString(in);
        this.author = author;
        author.incTitles();
      // PRE TRUE
      // POST RETURNS String representation of Book
      public String toString() {
        String result;
        result = "TITLE : " + title + "\n";
        result = result + "AUTHOR\n" + author.toString() + "\n";
        return(result);
    class Initials {
      private String inits;
      public Initials(BufferedReader in) {
        System.out.print("\nInitails Testing ==> ");
        inits = Text.ReadString(in);
      public String toString() {
        String result;
        result = inits;
        return(result);
    class Text {
      static String ReadString(BufferedReader in) {
        String text = "";
        try {
          text = in.readLine();
        catch (IOException e) {
          System.out.println(e.getMessage());
          System.exit(0);
        return text;
    }

  • How to write hasCode() & equals(0) methods in Compound Key Class

    Hi Java Helpdesk,
    I am wondering how to write the hashCode() and equals() methods that is mandatory when creating composite
    @IdClass. Below is the combination of primary @Id keys that I would like to make up in a compound key class:
    public final class PatientKey implements java.io.Serializable
        private String firstnameId;
        private String SurnameId;
        private String DateOfBirthID;
        private String Sex;
        public int hashCode()
        public boolean equals(Object otherOb)
    }The Order application in Java EE 5 Tutorial (page 841) is made up of only 2 primary keys.
    Thanks,
    Jack

    Hi,
    Thanks for your very brief response and I had a look at both EqualsBuilder and HashCodeBuilder from the URL links you have provided. These methods may improve the comparison accuracy but I was more interested on how to implement the equals() and hashCode methods when comparing 3 or more primary keys in order to make up a primary key class. Below is my first attempt to compose the PatientPK primary key class:
    1. public class PatientPK implements java.io.Serializable {
    2.
    3.     private String firstName;
    4.     private String lastName;
    5.     private String dateOfBirth;
    6.     private Char sex;
    7.
    8.     public PatientPK() {}
    9.
    10.   public PatientPK(String firstName, String lastName, Date dateOfBirth, Char sex)
    11.   {
    12.       this.firstName = firstName;
    13.       this.lastName = lastName;
    14.       this.dateOfBirth = dateOfBirth;
    15.       this.sex = sex;
    16.   }
    17.
    18.   public String getFirstName() { return this.firstName; }
    19.   public void setFirstName(String firstname) { this.firstName = firstName; }
    20.
    21.   public String getlastName() { return this.lastName; }
    22.   public void setLastname(String lastName) { this.lastName = lastName; }
    23.
    24.   public String getDateOfBirth() { return this.dateOfBirth; }
    25.   public void setDateOfBirth(String dateOfBirth) { this.dateOfBirth = dateOfBirth; }
    26.
    27.   public Char getSex() { return this.sex; }
    28.   public void setSex(String sex) { this.sex = sex; }
    29.
    30.   public boolean equals(Object obj)
    31.   {
    32.       if (obj == this) return true;
    33.       if (!(obj instanceof PatientPK)) return false;
    34.       PatientPK pk = (PatientPK) obj;
    35.       if (!firstName.equals(pk.firstName)) return false;
    36.       if (!lastName.equals(pk.lastName)) return false;
    37.       if (!dateOfBirth.equals(pk.dateOfBirth)) return false;
    38.       if (!sex.equals(pk.sex)) return false;
    39.       return true;
    40.   }
    41.
    42.   public hashCode()
    43.   {
    44.       return firstName.hashCode() + lastName.hashCode() + dateOfBirth.hashCode() + sex.hashCode();
    45.   }
    46.}Please advice whether both these equals() and hashCode() implementations are correct.
    Thanks in advance,
    Jack

  • How to write comments for a class

    hi
    how to write comments for a class

    I'm reeling with incredulity, and as such am unable to do anything except just post some code
    // this is a single line comment
    /* this is a multiline comment.
        it can be spread over as many lines as you
        want */Or are you asking about how to decide what the content should be?

  • How to write a class for this?

    how do i write a different class for this? how do i implement the "a.add(b)"? it code is to test basic arithmetic operations.
              System.out.print ("Arithmetic: enter two integer numbers: ");
              Integer a = new Integer (Integer.parseInt(kbd.readLine()));
              Integer b = new Integer (Integer.parseInt(kbd.readLine()));
              System.out.println (a + "+" + b + "-" + b + "*" + a + "/" + a + "%" + b + " is: "                                    + a.add(b).sub(b).mul(a).div(a).rem(b));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    public class arthOperation{
         add()
              sub()
         sub(){
              mul()
         mul(){
              div()
         div(){
              rem()
         rem(){
    is it write?

  • How do I regenerate the JDBC wrapper class?

    I am seeing the following in Weblogic 10.3.
    java.lang.IllegalAccessError: tried to access class oracle/bi/jdbc/AnaJdbcResultSetImpl from class weblogic/jdbc/wrapper/ResultSet_oracle_bi_jdbc_AnaJdbcResultSet
    As I understand it, the wrapper class is auto-generated. How do I re-grenerate the wrapper class to get it in sync?

    It should never not be in sync. It is generated dynamically according to the BI classes currently
    available, which doesn't change while the JVM is running. Open a BI JDBC SR.
    Joe

  • How do I write an external class with global constants?

    Hi you all !
    First I want to explain what exactly I want to do:
    I have an application that should run in different resolutions. The app runs fullscreen, and I don't use Layouts or something, just a single Frame with a Graphics Object.
    Now to handle the different resolutions, I want to write an external class with some constants to use. The usage in my main Class should be something like this:
    public
    class blah
    private Constants myConstants;
    public blah()
    if (highResolution)
    myConstants = new hiResConstants();
    else
    myConstants = new loResConstants();
    System.println(String.valueOf(myConstants.SCREEN_WIDTH);
    }or somthing like that. The important fact is that I can choose the constants at runtime and that I am NOT forced to use methods to get the values, cause something like
    System.println(String.valueOf(myConstants.getScreenWidth());sux if you have methods using 5 or more parameters.
    Anybody out there who understood my problem and can help me??? PLEASE?
    best regards,
    Skippy

    First, what's so much worse about
    System.println(myConstants.getScreenWidth());
    than
    System.println(myConstants.ScreenWidth);
    Is the extra five characters really that bad? (Note
    you don't need the String.valueOf method call.)Well actually it was a wrong example I gave here, but it's not the call that makes me shake but the implementation:
    public int screenWidth = 1024;vs.
    public
    int getScreenWidth()
    return 1024;
    }Here it makes a bigger difference, even when you think of managing about 100 or even more constants.
    Second, why do you have methods that take five or more
    parameters!?Well, maybe this example show up what I mean:
    if (cursorIsInArea(100,100,200,200,areaId))
    doSomeStuff();Ok, I could use Rectangles here, but if you think of the timing here (I draw 30 frames / sec and this check comes about every frame or the animation would be choppy) I refuse to create an Object everytime I make this call.
    Btw: Is it worth thinking about the time of execution like I did in this example? OO is a neat thing, but is it that fast?
    I don't think isCursorInArea(new Rectangle(100,100,200,200),areaId) is such a great idea, but I might be wrong.
    It sounds like you're trying to compound a bad design
    with an even worse design for no good reason!Well, I'm not that experienced Java programmer to judge about that, but I (and my profs at university too) found my codes well structured and designed so far.
    Skippy
    PS: the string.valueOf(123) call came from cut&paste:
    system.out.println(string.valueOf(number1)+string.valueOf(number2));Try this without the function.... ;-)

Maybe you are looking for

  • Accessing properties of a UI element in wdDoInit()

    I would like to interrogate the value of a DateNavigator elements startsWith property in the wdDoInit method of the view controller, by using the IWDDateNavigator.getStartsWith() method. The problem is, I cannot figure out to programmatically access

  • Ultrabeat Saving Issues

    Greetings, I did a bit of searching on this and other forums, but found very little on this subject. When saving Ultrabeat presets, sometimes the sample OSC has none loaded and sometimes, it loads a completely different drum (Taiko for example). Has

  • HT1338 I have Mac OS X 10.5.8 (9L31a)

    I need to update my software. I currently have OS X 10.5.8. What software do I need next to update my computer and where do I get it?

  • ItemListener problems

    Hi guys, having problems with ItemListener, seems the compiler doesn't recognize the variable. Here's the code ... public void itemStateChanged(ItemEvent ie)           String arg = e.getActionCommand();              //have also tried ie.getActionComm

  • Compiling a client of an application using a library

    Hi, I got a library that wraps 3GL code. I build this library first (projtype 3), then I distribute as client my forte application, and I'm able to compile the client on the same node where the library has been made, but not on other node types. i.e.