java - is not abstract and does not override abstract method error -


i totally stuck in 1 of classes showing error:

resettablehttpservletresponse not abstract , not override abstract method getheadernames() in httpservletresponse 

here entire class:

import java.io.file; import java.io.fileinputstream; import java.io.fileoutputstream; import java.io.filereader; import java.io.ioexception; import java.io.outputstream; import java.io.printwriter; import java.util.arraylist; import java.util.hashset; import java.util.list; import java.util.locale; import java.util.set;  import javax.servlet.servletoutputstream; import javax.servlet.http.cookie; import javax.servlet.http.httpservletresponse;  import org.apache.commons.io.ioutils; import org.apache.commons.lang.exception.nestableruntimeexception;   @suppresswarnings("deprecation") public class resettablehttpservletresponse implements httpservletresponse, resettable {      private interface responseoperation {          void apply();     }     private httpservletresponse wrapped;     private list<responseoperation> operations;     private locale locale;     private int buffersize;     private string contenttype;     private string charset;     private printwriter writer;     private outputstream outputstream;     private servletoutputstream servletoutputstream;     private file contents;     private set<string> headernames;     private int status;     private boolean stateapplied;      public resettablehttpservletresponse(final httpservletresponse response) {         wrapped = response;         operations = new arraylist<responseoperation>();         headernames = new hashset<string>();         resetstate();     }      @override     public void addcookie(final cookie cookie) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.addcookie(cookie);             }         });     }      @override     public void adddateheader(final string name, final long date) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.adddateheader(name, date);             }         });     }      @override     public void addheader(final string name, final string value) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.addheader(name, value);             }         });     }      @override     public void addintheader(final string name, final int value) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.addintheader(name, value);             }         });     }      @override     public void applystate() {         try {             // apply operations             (final responseoperation operation : operations) {                 operation.apply();             }             // copy response contents, if             if (outputstream != null) {                 try {                     outputstream.flush();                     ioutils.copy(new fileinputstream(contents), wrapped.getoutputstream());                 } catch (final exception e) {                     throw new nestableruntimeexception(e);                 }             } else if (writer != null) {                 try {                     writer.flush();                     ioutils.copy(new filereader(contents), wrapped.getwriter());                 } catch (final exception e) {                     throw new nestableruntimeexception(e);                 }             }             stateapplied = true;         } {             reset();         }     }      @override     public boolean containsheader(final string name) {         return headernames.contains(name);     }      @override     public string encoderedirecturl(final string url) {         return wrapped.encoderedirecturl(url);     }      @override     public string encoderedirecturl(final string url) {         return wrapped.encoderedirecturl(url);     }      @override     public string encodeurl(final string url) {         return wrapped.encodeurl(url);     }      @override     public string encodeurl(final string url) {         return wrapped.encodeurl(url);     }      @override     public void flushbuffer() throws ioexception {         // no-op, nothing has been done in real response     }      @override     public int getbuffersize() {         return buffersize;     }      @override     public string getcharacterencoding() {         return charset;     }      @override     public string getcontenttype() {         return contenttype;     }      @override     public locale getlocale() {         return locale;     }      @override     public servletoutputstream getoutputstream() throws ioexception {         if (writer != null) {             throw new illegalstateexception("getwriter() invoked in response");         }         if (servletoutputstream == null) {             contents = file.createtempfile("cyclos_", "_response");             outputstream = new fileoutputstream(contents);             servletoutputstream = new servletoutputstream() {                 @override                 public void close() throws ioexception {                     outputstream.close();                 }                  @override                 public void flush() throws ioexception {                     outputstream.flush();                 }                  @override                 public void write(final byte[] b) throws ioexception {                     outputstream.write(b);                 }                  @override                 public void write(final byte[] b, final int off, final int len) throws ioexception {                     outputstream.write(b, off, len);                 }                  @override                 public void write(final int b) throws ioexception {                     outputstream.write(b);                 }             };         }         return servletoutputstream;     }      public int getstatus() {         return status;     }      @override     public printwriter getwriter() throws ioexception {         if (outputstream != null) {             throw new illegalstateexception("getoutputstream() invoked");         }         if (writer == null) {             contents = file.createtempfile("cyclos_", "_response");             writer = new printwriter(contents);         }         return writer;     }      @override     public boolean iscommitted() {         if (!stateapplied) {             return false;         }         return wrapped.iscommitted();     }      @override     public void reset() {         resetstate();     }      @override     public void resetbuffer() {         ioutils.closequietly(outputstream);         ioutils.closequietly(writer);         outputstream = null;         servletoutputstream = null;         writer = null;         if (contents != null) {             contents.delete();             contents = null;         }     }      @override     public void resetstate() {         status = 0;         operations.clear();         headernames.clear();         charset = wrapped.getcharacterencoding();         buffersize = wrapped.getbuffersize();         contenttype = wrapped.getcontenttype();         locale = wrapped.getlocale();         resetbuffer();     }      @override     public void senderror(final int sc) {         status = sc;         operations.add(new responseoperation() {             @override             public void apply() {                 try {                     wrapped.senderror(sc);                 } catch (final ioexception e) {                     throw new nestableruntimeexception(e);                 }             }         });     }      @override     public void senderror(final int sc, final string msg) throws ioexception {         status = sc;         operations.add(new responseoperation() {             @override             public void apply() {                 try {                     wrapped.senderror(sc, msg);                 } catch (final ioexception e) {                     throw new nestableruntimeexception(e);                 }             }         });     }      @override     public void sendredirect(final string location) throws ioexception {         operations.add(new responseoperation() {             @override             public void apply() {                 try {                     wrapped.sendredirect(location);                 } catch (final ioexception e) {                     throw new nestableruntimeexception(e);                 }             }         });     }      @override     public void setbuffersize(final int buffersize) {         this.buffersize = buffersize;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setbuffersize(buffersize);             }         });     }      @override     public void setcharacterencoding(final string charset) {         this.charset = charset;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setcharacterencoding(charset);             }         });     }      @override     public void setcontentlength(final int len) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setcontentlength(len);             }         });     }      @override     public void setcontenttype(final string contenttype) {         this.contenttype = contenttype;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setcontenttype(contenttype);             }         });     }      @override     public void setdateheader(final string name, final long date) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setdateheader(name, date);             }         });     }      @override     public void setheader(final string name, final string value) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setheader(name, value);             }         });     }      @override     public void setintheader(final string name, final int value) {         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setintheader(name, value);             }         });     }      @override     public void setlocale(final locale locale) {         this.locale = locale;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setlocale(locale);             }         });     }      @override     public void setstatus(final int sc) {         status = sc;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setstatus(sc);             }         });     }      @override     public void setstatus(final int sc, final string sm) {         status = sc;         operations.add(new responseoperation() {             @override             public void apply() {                 wrapped.setstatus(sc, sm);             }         });     } } 

any 1 tell me supposed rid of error?

edit: have added following method declaration in class not seem affecting error. should do?

@override public collection<string> getheadernames() {     operations.add(new responseoperation() {         @override         public void apply() {             wrapped.getheadernames();         }     });     return headernames; } 

when implement interface class isn't abstract, have redefine methods declared in interface. here did'nt redefine method getheadernames() declared in interface httpservletresponse.

you need override method in class resettablehttpservletresponse

edit :

the error explicit. says forgot override method getheadernames of interface httpservletresponse.

you should read lesson interfaces , inheritance.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -