Subclassing constructor to override a method?

How would I create a subclass of the Contains query and override the expand() method? How would I do this any code examples, anything.
I'm very new to java so any help would be great.
Constructors
Contains (StringAttribute, String, InstanceMetaData)
public Contains(StringAttribute att, java.lang.String val, InstanceMetaData instmd)
This constructs a contains query on a string attribute.
Contains (String, InstanceMetaData)
public Contains(java.lang.String val, InstanceMetaData instmd)
This constructs a contains query on the document content.
Methods
compile()
public java.lang.String compile()
This compiles into a query string.
Specified By:
compile() in interface Query
Returns:
a query string representing this query.
expand(StringAttribute, String, InstanceMetaData)
public java.lang.String expand(StringAttribute att, java.lang.String str, InstanceMetaData instmd)
This translates a user?s attribute Contains query string into a text query.
Parameters:
att - a string attribute
str - the main query string
instmd - the InstanceMetaData object
Returns:
The translated Oracle Text query string (contains clause)
expand(String, InstanceMetaData)
public java.lang.String expand(java.lang.String str, InstanceMetaData instmd)
This translates a user query string into a text query.
Parameters:
str - the main query string
instmd - the InstanceMetaData object
Returns:
The translated Oracle Text query string (contains clause)
Thanks.

I get the following error
50
[jsp src:line #:45]
Return required at end of java.lang.String expand(java.lang.String, oracle.ultrasearch.query.InstanceMetaData). public java.lang.String expand(String a, InstanceMetaData b) { 
52
[jsp src:line #:47]
Only constructors can invoke constructors. super(a,b);
after adding:
class myContains extends Contains {
myContains(StringAttribute att, java.lang.String val, InstanceMetaData instmd) {
super(att,val,instmd);
myContains(java.lang.String val, InstanceMetaData instmd) {
super(val,instmd);
public java.lang.String expand(String a, InstanceMetaData b) {
// your code here
super(a,b);
}

Similar Messages

  • Superclass Constructor calling overridable validation method

    I have the following class:
    public class SuperClass
       private int x;
       public SuperClass(int x)
          setX(x);
       protected void validateX(int x)
          if(x < 0)
             throw new IllegalArgumentException("x < 0");
       public int getX()
          return x;
       public void setX(int x)
          validateX(x);
          this.x = x;
    }My question is: How can I avoid calling setX(int) in the constructor besides simply dupicating validateX(int) in the constructor if I want to subclass SuperClass? [I read in a recent Java Fundamentals newsletter that calling overridable methods in superclass constructors is a bad idea int that it tends to destabilize the whole class hierarchy.  I don't want to make validateX(int) and setX(int) final.]

    Never call overrideable methods from constructors. No exceptions.
    You can use a factory method to validate your object after its created if you must.
    public class SuperClass
       private int x;
       public SuperClass()
       static SuperClass createSuperClass(int x){
             SuperClass sc = new SuperClass();
             sc.setX(x);
             return sc;
       protected void validateX(int x)
          if(x < 0)
             throw new IllegalArgumentException("x < 0");
       public int getX()
          return x;
       public void setX(int x)
          validateX(x);
          this.x = x;
    }Or you can use template method
    public class SuperClass
    private int x;
    public SuperClass(int x)
    setXImpl(x);
    final protected void validateX(int x)
    if(x < 0)
    throw new IllegalArgumentException("x < 0");
    public int getX()
    return x;
    final void setXImpl(int x){
    validateX(x);
    this.x = x;
    public void setX(int x)
    setXImpl(x);
    In general I don't like to call any overrideable methods from within my class. I try not to be anal about it though. My personal choice would be to duplicate the set method in the constructor. You should be constructing the object not using it. access instance variables not methods.

  • How to override a method in an inner class of the super class

    I have a rather horribly written class, which I need to adapt. I could simply do this if I could override a method in one of it's inner classes. My plan then was to extend the original class, and override the method in question. But here I am struggling.
    The code below is representative of my situation.
    public class ClassA
       ValueChecks vc = null;
       /** Creates a new instance of Main */
       public ClassA()
          System.out.println("ClassA Constructor");
          vc = new ValueChecks();
          vc.checkMaximum();
         // I want this to call the overridden method, but it does not, it seems to call
         // the method in this class. probably because vc belongs to this class
          this.vc.checkMinimum();
          this.myMethod();
       protected void myMethod()
          System.out.println("myMethod(SUPER)");
       protected class ValueChecks
          protected boolean checkMinimum()
             System.out.println("ValueChecks.checkMinimum (SUPER)");
             return true;
          protected boolean checkMaximum()
             return false;
    }I have extended ClassA, call it ClassASub, and it is this Class which I instantiate. The constructor in ClassASub obviously calls the constructor in ClassA. I want to override the checkMinimum() method in ValueChecks, but the above code always calls the method in ClassA. The ClassASub code looks like this
    public class ClassASub extends ClassA
       public ClassAInner cias;
       /** Creates a new instance of Main */
       public ClassASub()
          System.out.println("ClassASub Constructor");
       protected void myMethod()
          System.out.println("myMethod(SUB)");
       protected class ValueChecks extends ClassA.ValueChecks
          protected boolean checkMinimum()
             System.out.println("ValueChecks.checkMinimum (SUB)");
             return true;
    }The method myMethod seems to be suitably overridden, but I cannot override the checkMinimum() method.
    I think this is a stupid problem to do with how the ValueChecks class is instantiated. I think I need to create an instance of ValueChecks in ClassASub, and pass a reference to it into ClassA. But this will upset the way ClassA works. Could somebody enlighten me please.

    vc = new ValueChecks();vc is a ValueChecks object. No matter whether you subclass ValueChecks or not, vc is always of this type, per this line of code.
    // I want this to call the overridden method, but it does not, it seems to > call
    // the method in this class. probably because vc belongs to this class
    this.vc.checkMinimum();No, it's because again vc references a ValueChecks object, because it was created as such.
    And when I say ValueChecks, I mean the original class, not the one you tried to create by the same name, attempting to override the original.

  • Is not abstract and does not override abstract method actionPerformed

    I dont how to corr. Please help!! and thank you very much!!
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class test extends JFrame implements ActionListener, ItemListener
              private CenterPanel centerPanel;
              private QuestionPanel questionPanel;
              private ButtonPanel buttonPanel;
              private ResponsePanel responsePanel;
              private JButton b1,b2,b3,b4,b5;               //Create five references to Jbutton instances
         private JTextField t1,t2,t3,t4,t5;          //Create five references to JTextField instances
              private JLabel label1;                    //Create one references to JLabel instances
              private JRadioButton q1,q2,q3;               //Create three references to JRadioButton instances
              private ButtonGroup radioGroup;               //Create one references to Button Group instances
              private int que1[] = new int[5];           //Create int[4] Array
              private int que2[] = new int[5];
              private int que3[] = new int[5];
              private String temp1, temp2, temp3, temp4, temp5, temp6, temp7, temp8, temp9, temp10,
                        temp11, temp12, temp13, temp14, temp15;
    public test (String header)
              super(header);
              Container container = getContentPane();
              label1 = new JLabel ("PLease click on your response to ");     
              q1 = new JRadioButton("I understand most of the content of this subject",true);
              add(q1);
              q2 = new JRadioButton("I see the relevance of the subject to my degree",false);
              add(q2);
              q3 = new JRadioButton("The workload in this subject is appropriate",false);
              add(q3);
              radioGroup = new ButtonGroup();               //JRadioButton belong to ButtonGroup
              radioGroup.add(q1);
              radioGroup.add(q2);
              radioGroup.add(q3);
              JPanel buttonPanel = new JPanel();
              JPanel responsePanel = new JPanel();
              JPanel questionPanel = new JPanel();
              JPanel centerPanel = new JPanel();
              b1 = new JButton ("Strongly DISAGREE");          //Instantiate JButton with text
              b1.addActionListener (this);               //Register JButtons to receive events
              b2 = new JButton ("DISAGREE");
              b2.addActionListener (this);
              b3 = new JButton ("Neither AGREE or DISAGREE");
              b3.addActionListener (this);
              b4 = new JButton ("AGREE");
              b4.addActionListener (this);
              b5 = new JButton ("Strongly AGREE");
              b5.addActionListener (this);
              buttonPanel.setLayout(new GridLayout(5,1));
              buttonPanel.add(b1);
              buttonPanel.add(b2);
              buttonPanel.add(b3);
              buttonPanel.add(b4);
              buttonPanel.add(b5);
              t1 = new JTextField ("0",3);               //JTextField contains empty string
              t2 = new JTextField ("0",3);
              t3 = new JTextField ("0",3);
              t4 = new JTextField ("0",3);
              t5 = new JTextField ("0",3);
              t1.setEditable( false );
              t2.setEditable( false );
              t3.setEditable( false );
              t4.setEditable( false );
              t5.setEditable( false );
              responsePanel.setLayout(new GridLayout(5,1));
              responsePanel.add(t1);
              responsePanel.add(t2);
              responsePanel.add(t3);
              responsePanel.add(t4);
              responsePanel.add(t5);
              questionPanel.setLayout(new GridLayout(4,1));
              questionPanel.add(label1);
              questionPanel.add(q1);
              questionPanel.add(q2);
              questionPanel.add(q3);
              centerPanel.add(buttonPanel,BorderLayout.CENTER);
              centerPanel.add(responsePanel,BorderLayout.EAST);
              container.add(centerPanel,BorderLayout.WEST);
              container.add(questionPanel,BorderLayout.NORTH);
              q1.addActionListener(
                   new ActionListener(){
              public void actionPerformed( ActionEvent e )          
    {                                        //actionPerformed of all registered listeners
              if (e.getSource() == b1) {
                   que1[0] = Integer.parseInt(t1.getText()) + 1;
                   String temp1 = String.valueOf(que1[0]);
              t1.setText(temp1);
              else if (e.getSource() == b2)     {
                   que1[1] = Integer.parseInt(t2.getText()) + 1;
                   String temp2 = String.valueOf(que1[1]);
              t2.setText(temp2);
              else if (e.getSource() == b3)     {
                   que1[2] = Integer.parseInt(t3.getText()) + 1;
                   String temp3 = String.valueOf(que1[2]);
              t3.setText(temp3);
              else if (e.getSource() == b4)     {
                   que1[3] = Integer.parseInt(t4.getText()) + 1;
                   String temp4 = String.valueOf(que1[3]);
              t4.setText(temp4);
              else if (e.getSource() == b5)     {
                   que1[4] = Integer.parseInt(t5.getText()) + 1;
                   String temp5 = String.valueOf(que1[4]);
              t5.setText(temp5);
    } //end action performed
              q2.addActionListener(
                   new ActionListener(){
              public void actionPerformed( ActionEvent e )          
    {                                        //actionPerformed of all registered listeners
              if (e.getSource() == b1) {
                   que2[0] = Integer.parseInt(t1.getText()) + 1;
                   String temp6 = String.valueOf(que2[0]);
              t1.setText(temp1);
              else if (e.getSource() == b2)     {
                   que2[1] = Integer.parseInt(t2.getText()) + 1;
                   String temp7 = String.valueOf(que2[1]);
              t2.setText(temp7);
              else if (e.getSource() == b3)     {
                   que2[2] = Integer.parseInt(t3.getText()) + 1;
                   String temp8 = String.valueOf(que2[2]);
              t3.setText(temp8);
              else if (e.getSource() == b4)     {
                   que2[3] = Integer.parseInt(t4.getText()) + 1;
                   String temp9 = String.valueOf(que2[3]);
              t4.setText(temp9);
              else if (e.getSource() == b5)     {
                   que2[4] = Integer.parseInt(t5.getText()) + 1;
                   String temp10 = String.valueOf(que2[4]);
              t5.setText(temp10);
    } //end action performed
              q3.addActionListener(
                   new ActionListener(){
              public void actionPerformed( ActionEvent e )          
    {                                        //actionPerformed of all registered listeners
              if (e.getSource() == b1) {
                   que3[0] = Integer.parseInt(t1.getText()) + 1;
                   String temp11 = String.valueOf(que3[0]);
              t1.setText(temp11);
              else if (e.getSource() == b2)     {
                   que3[1] = Integer.parseInt(t2.getText()) + 1;
                   String temp12 = String.valueOf(que3[1]);
              t2.setText(temp12);
              else if (e.getSource() == b3)     {
                   que3[2] = Integer.parseInt(t3.getText()) + 1;
                   String temp13 = String.valueOf(que3[2]);
              t3.setText(temp13);
              else if (e.getSource() == b4)     {
                   que3[3] = Integer.parseInt(t4.getText()) + 1;
                   String temp14 = String.valueOf(que3[3]);
              t4.setText(temp14);
              else if (e.getSource() == b5)     {
                   que3[4] = Integer.parseInt(t5.getText()) + 1;
                   String temp15 = String.valueOf(que3[4]);
              t5.setText(temp15);
    } //end action performed
    }//end constructor test
    public void itemStateChanged(ItemEvent item) {
    //int state = item.getStateChange();
    //if (q1 == item.SELECTED)
              public class ButtonPanel extends JPanel
                   public ButtonPanel()
              public class CenterPanel extends JPanel
                   public CenterPanel()
              public class QuestionPanel extends JPanel
                   public QuestionPanel()
              public class ResponsePanel extends JPanel
                   public ResponsePanel()
    public static void main(String [] args)
         test surveyFrame = new test("Student Survey") ;
         surveyFrame.setSize( 500,300 );
         surveyFrame.setVisible(true);
         surveyFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
         }//end main
    }//end class test

    is not abstract and does not override abstract method actionPerformed
    Oh, I see that the title of your post is an error message? Ok. Well, the test class is declared as implementing an ActionListener. That means the test class must have an actionPerformed() method. Your test class apparently does not.
    It does not appear that the test class needs to implement ActionListener. You are using annonymous classes as listeners.

  • Overriding a method which is protected

    I have written a subclass 'B' to a parent class 'A' which is in different package than the parent class, but one of the method (almost same as parent classes method) which i have overridden in the subclass invokes a method (which has 'protected' access) of other classes say class 'C' of parent class package which will not work due to visibility. What is the best way to over come this problem. I have to override the code which is in the parent class.
    a) Is it to create subclass of 'C' in the same package of class 'B' and override the method which is being called.
    b) Is it to name the subclass package similar to the parent class Package.
    Note : - Parent class package is in different project.

    If it's protected then either it was made that way for a good reason (to not let you invoke it, so -- success!), or not for a good reason (bad design).
    The simple answer is you can't invoke that method as it currently stands, as you already know due to the compile time error message you're getting. If you're in control of its design and actually do need it to be accessed from outside its own package, then make it public.

  • Can we override Static methods?

    Hi all, I m in little bit confusion abt static methods overriding.
    Could you help me on this issue.,
    Can we override Static methods?

    You can provide static methods with same name in both super class and subclass. But it is not overriding in this scenario. Both will act as independent methods.
    Example:
    have a super class:
    public class Test1 {
    public static void mthdA()
    System.out.println("in super");
    have a sub class:
    public class Test2 extends Test1{
    public static void mthdA()
    System.out.println("inside sub");
    public static void main(String[] args){
    Test1 objTest = new Test2();
    objTest.mthdA();
    Try to run the sub class Test2. The output would be "in super".
    Remove static modifier in mthdA() in both the classes and then run. The output would be "in sub". Meaning, methdA is overriden in sub class.

  • Conditions within subclass constructors?

    My assignment is to create a Ticket class with three subclasses, WalkupTicket, AdvanceTicket and StudentAdvanceTicket.
    AdvanceTicket and StudentAdvanceTicket both must have two parameters, the ticket number, and the number of days in advance the ticket is purchased. Depending on how early the ticket was purchased, the price varies. WalkupTicket is easy since it only has one price, but the other two are giving me a hard time. What I want to do is something like this;
    public class Ticket {
         private int number; // Instance variable containing ticket number
         private int price;  // Instance variable containing ticket price
         public Ticket (int n, int p) {
              number = n;
              price = p;
         public static class AdvanceTicket extends Ticket {
              public AdvanceTicket (int n, int d) {
                   if (d >= 10) super(n, 30);
                   else super(n, 40);
    }But that doesn't work because the first line in the subclass constructor must call the superclass constructor.
    I've tried creating a checkPrice method within the subclass, then using super(n, checkPrice(d)); but that gives me an error as well, telling me I have to call the super constructor before calling the method.
    Can someone point me in the right direction?

    While it is possible to achieve by making the field package private/protected/public, that is not a good approach. Fields should be made private unless you have good reason not to. Furthermore doing so won't change anything, you will still be invoking a super constructor; an [implicit call to super();|http://java.sun.com/docs/books/jls/third_edition/html/classes.html#8.8.7] will be inserted for you.
    The wording of the assignment is somewhat woolly, but I'm certain the original solution does not violate the requirements.
    EDIT: I just realized you are using an inner class. The reason you can't instantiate it is that it needs an instance of Ticket first:
    Ticket t = null;
    WalkupTicket wt = t.new WalkupTicket(1);So in order to create a ticket you would need a ticket first, that's not useful.. ;)
    Using a nested class (making WalkupTicket static again) can be made to work with an explicit upcast:
    public abstract class Ticket {
        private int number; // Instance variable containing ticket number
        private int price;  // Instance variable containing ticket price
        // Creates a WalkupTicket
        // @param n is the ticket number
        public static class WalkupTicket extends Ticket {
            public WalkupTicket (int n) {
                ((Ticket)this).number = n;
                ((Ticket)this).price = 50;
    }With kind regards
    Ben
    Edited by: BenSchulz on Feb 13, 2010 12:27 PM

  • Overriding private methods

    Is it possible to override private methods??
    class A {
    private void print() {
    System.out.println("Hello Super");
    class B extends A{
    public void print() {
    System.out.println("Hello Sub");
    class C {
    public static void main(String args[]) {
    A a=new B();
    a.print();
    According to overriding rules the sub class method should not be more restrictive than the super class method. SO we are making it public (From private).
    So the above code is an example of overriding but when compiled it gives error.
    Please explain why??

    Oh wait, I had a second look and compiled & ran your program. This is the error message:
    A.java:16: print() has private access in A
    a.print();
    ^
    1 errorYou are trying to call a private method, so you get an error. You can't make private methods public by subclassing.

  • Override JUNavigationBar method's

    Hi!
    I would like to override JUNavigationBar method's actionPerformed. But I doesn't work.
    I wrote this:
    private JUNavigationBar navBar = new JUNavigationBar()
    public void actionPerformed(ActionEvent ev)
         //something...
         System.out.println("MyactionPerformed!");
    super.actionPerformed(ev);
    The original method:
    * Applications should override this method to perform custom Action based on a button click/press.
    * Calling super will perform the default button actions.
    * &lt;p&gt;
    * For example, if an application needs to override commit and rollback operations so that they
    * can hold on to some application state before commit/rollback occurs, this method could be
    * overriden to cache the application state, call the super.actionPerformed() to do the
    * button action and then restore the application state.
    public void actionPerformed(ActionEvent ev)
    Object source = ev.getSource();
    for (int i = 0; i &lt;= BUTTON_EXECUTE; i++)
    if (source == _buttons)
    doAction(i);
    return;
    It always called the original method. Why is it wrong? And how can I made this?
    Thanks,
    Orsi

    I tried this in JDeveloper 9.0.5.2 and the actionPerformed method in my subclassed JUNavigationBar does get invoked on every button press.

  • Providing new doc comments w/o overriding a method

    Is there a way to provide new documentation of a method inherited from a subclass with out overriding it? The superclass' implementation is
    fine however the comments are not descriptive enough so I'd like to add more. But I dont' want to idiotically override it like so:
    * new comment
    public void method()
    super.method();
    thanks,
    n.r.

    Yes, use in-line tag {@inheritDoc}./**
    * new comment
    * <p>
    * {@inheritDoc}
    public void method()
      super.method();
    }You can write above or below in-line tags.
    I show it with a <p> paragraph separator.
    -Doug

  • Is not abstract and does not override abstract method tablechanged

    I will remove all the gui code to make it shorter, but my problem lies with my InteractiveTableModelListener.
    public class Meet extends JPanel{
      private static void createAndShowGUI() {
            JFrame frame = new JFrame("MEET_dataTable");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(new Meet(), BorderLayout.CENTER);
            frame.pack();
            frame.setVisible(true);
    public class InteractiveTableModelListener implements TableModelListener {
         public void TableChanged(TableModelEvent evt) {
      if (evt.getType() == TableModelEvent.UPDATE) {
          int column = evt.getColumn();
          int row = evt.getFirstRow();
          dataTable.setColumnSelectionInterval(column + 1, column + 1);
          dataTable.setRowSelectionInterval(row, row);
    class InteractiveRenderer extends DefaultTableCellRenderer {
      protected int interactiveColumn;
      public InteractiveRenderer(int interactiveColumn) {
          this.interactiveColumn = interactiveColumn;
    public Component getTableCellRendererComponent(JTable dataTable,
         Object value, boolean isSelected, boolean hasFocus, int row,
         int column)
      Component c = super.getTableCellRendererComponent(dataTable, value, isSelected, hasFocus, row, column);
       if (column == interactiveColumn && hasFocus) {
         if ((Meet.this.tableModel.getRowCount() - 1) == row &&
            !Meet.this.tableModel.hasEmptyRow())
             Meet.this.tableModel.addEmptyRow();
        highlightLastRow(row);
      return c;
    public void highlightLastRow(int row) {
         int lastrow = tableModel.getRowCount();
      if (row == lastrow - 1) {
          dataTable.setRowSelectionInterval(lastrow - 1, lastrow - 1);
      else {
          dataTable.setRowSelectionInterval(row + 1, row + 1);
         dataTable.setColumnSelectionInterval(0, 0);
    public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                UIManager.put("swing.boldMetal", Boolean.FALSE);
                createAndShowGUI();
    }As i say, i have removed all the gui code to make it shorter, but in this code i create the table and add all the model to it. I am being returned with the error
    Meet.InteractiveTableModelListener is not abstract and does not override abstract method tableChanged(javax.swing.event.TableModelEvent)in javax.swing.event.TableModelListener
    what would be causing this error?
    Cheers

    Sorry, just figured out my silly error, the method is tableChanged not TableChanged.
    cheers
    TOPIC CLOSED
    Edited by: nick2price on Sep 11, 2008 7:08 AM

  • Is not abstract and does not override abstract method ERROR

    Hello. I'm new at all this, and am attempting to recreate a sample code out of my book (Teach Yourself XML in 24 Hours), and I keep getting an error. I appriciate any help.
    This is the Error that I get:
    DocumentPrinter is not abstract and does not override abstract method skippedEntity(java.lang.String) in org.xml.sax.ContentHandler
    public class DocumentPrinter implements  ContentHandler, ErrorHandler
            ^This is the sourcecode:
    import org.xml.sax.Attributes;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.ErrorHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.SAXParseException;
    import org.xml.sax.XMLReader;
    public class DocumentPrinter implements  ContentHandler, ErrorHandler
    // A Constant containing the name of the SAX parser to use.
    private static final String PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
    public static void main(String[] args)
       // Check to see whether the user supplied any command line arguments.  If not, print an error and exit.
       if (args.length == 0)
         System.out.println("No XML document path specified.");
         System.exit(1);
       // Create a new instance of the DocumentPrinter class.
       DocumentPrinter dp = new DocumentPrinter();
       try
         // Create a new instance of the XML Parser.
         XMLReader parser = (XMLReader)Class.forName(PARSER_NAME).newInstance();
         // Set the parser's content handler
        // parser.setContentHandler(dp);
         // Set the parsers error handler
         parser.setErrorHandler(dp);
         // Parse the file named in the argument
         parser.parse(args[0]);
       catch (Exception ex)
         System.out.println(ex.getMessage());
         ex.printStackTrace();
    public void characters(char[] ch, int start, int length)
       String chars ="";
       for (int i = start; i < start + length; i++)
         chars = chars + ch;
    System.out.println("Recieved characters: " + chars);
    public void startDocument()
    System.out.println("Start Document.");
    public void endDocument()
    System.out.println("End of Document.");
    public void startElement(String namespaceURI, String localName, String qName, Attributes atts)
    System.out.println("Start element: " + localName);
    for (int i = 0; i < atts.getLength(); i++)
    System.out.println(" Attribute: " + atts.getLocalName(i));
    System.out.println(" Value: " + atts.getValue(i));
    public void endElement(String namespaceURI, String localName, String qName)
    System.out.println("End of element: " + localName);
    public void startPrefixMapping(String prefix, String uri)
    System.out.println("Prefix mapping: " + prefix);
    System.out.println("URI: " + uri);
    public void endPrefixMapping(String prefix)
    System.out.println("End of prefix mapping: " + prefix);
    public void ignorableWhitespace(char[] ch, int start, int length)
    System.out.println("Recieved whitespace.");
    public void processingInstruction(String target, String data)
    System.out.println("Recieved processing instruction:");
    System.out.println("Target: " + target);
    System.out.println("Data: " + data);
    public void setDocumentLocation(Locator locator)
    // Nada
    public void error(SAXParseException exception)
    System.out.println("Parsing error on line " + exception.getLineNumber());
    public void fatalError(SAXParseException exception)
    System.out.println("Fatal parsing error on line " + exception.getLineNumber());
    public void warning(SAXParseException exception)
    System.out.println("Warning on line " + exception.getLineNumber());

    Check to make sure that the arguments are consistent with your ContentHandler class. Probably the wrong type.
    I think you forgot to include the skippedEntity method, it seems to be missing. Even if an implemented class has a method that you are not using, you still have to include the method in your code even if it doesn't do anything.
    Message was edited by:
    ChargersTule1

  • ...is not abstract and does not override abstract method compare

    Why am I getting the above compile error when I am very clearly overriding abstract method compare (ditto abstract method compareTo)? Here is my code -- which was presented 1.5 code and I'm trying to retrofit to 1.4 -- followed by the complete compile time error. Thanks in advance for your help (even though I'm sure this is an easy question for you experts):
    import java.util.*;
       This program sorts a set of item by comparing
       their descriptions.
    public class TreeSetTest
       public static void main(String[] args)
          SortedSet parts = new TreeSet();
          parts.add(new Item("Toaster", 1234));
          parts.add(new Item("Widget", 4562));
          parts.add(new Item("Modem", 9912));
          System.out.println(parts);
          SortedSet sortByDescription = new TreeSet(new
             Comparator()
                public int compare(Item a, Item b)   // LINE CAUSING THE ERROR
                   String descrA = a.getDescription();
                   String descrB = b.getDescription();
                   return descrA.compareTo(descrB);
          sortByDescription.addAll(parts);
          System.out.println(sortByDescription);
       An item with a description and a part number.
    class Item implements Comparable     
          Constructs an item.
          @param aDescription the item's description
          @param aPartNumber the item's part number
       public Item(String aDescription, int aPartNumber)
          description = aDescription;
          partNumber = aPartNumber;
          Gets the description of this item.
          @return the description
       public String getDescription()
          return description;
       public String toString()
          return "[descripion=" + description
             + ", partNumber=" + partNumber + "]";
       public boolean equals(Object otherObject)
          if (this == otherObject) return true;
          if (otherObject == null) return false;
          if (getClass() != otherObject.getClass()) return false;
          Item other = (Item) otherObject;
          return description.equals(other.description)
             && partNumber == other.partNumber;
       public int hashCode()
          return 13 * description.hashCode() + 17 * partNumber;
       public int compareTo(Item other)   // OTHER LINE CAUSING THE ERROR
          return partNumber - other.partNumber;
       private String description;
       private int partNumber;
    }Compiler error:
    TreeSetTest.java:25: <anonymous TreeSetTest$1> is not abstract and does not over
    ride abstract method compare(java.lang.Object,java.lang.Object) in java.util.Com
    parator
                public int compare(Item a, Item b)
                           ^
    TreeSetTest.java:41: Item is not abstract and does not override abstract method
    compareTo(java.lang.Object) in java.lang.Comparable
    class Item implements Comparable
    ^
    2 errors

    According to the book I'm reading, if you merely take
    out the generic from the code, it should compile and
    run in v1.4 (assuming, of course, that the class
    exists in 1.4). I don't know what book you are reading but that's certainly incorrect or incomplete at least. I've manually retrofitted code to 1.4, and you'll be inserting casts as well as replacing type references with Object (or the erased type, to be more precise).
    These interfaces do exist in 1.4, and
    without the generics.Exactly. Which means compareTo takes an Object, and you should change your overriding method accordingly.
    But this raises a new question: how does my 1.4
    compiler know anything about generics? It doesn't and it can't. As the compiler is telling you, those interfaces expect Object. Think about it, you want to implement one interface which declares a method argument type of Object, in several classes, each with a different type. Obviously all of those are not valid overrides.

  • Product is not abstract and does not override abstract method

    Received the following errors.
    Product.java:3: Product is not abstract and does not override abstract method ge
    tDisplayText() in Displayable
    public class Product implements Displayable
    ^
    Product.java:16: getDisplayText() in Product cannot implement getDisplayText() i
    n Displayable; attempting to use incompatible return type
    found : void
    required: java.lang.String
    public void getDisplayText()
    ^
    2 errors
    Code reads as follows
    import java.text.NumberFormat;
    public class Product implements Displayable
         private String code;
         private String description;
         private double price;
         public Product()
              this.code = "";
              this.description = "";
              this.price = 0;
    public void getDisplayText()
    String message =
    "Code: " + code + "\n" +
    "Description: " + description + "\n" +
    "Price: " + this.getFormattedPrice() + "\n";
         public Product(String code, String description, double price)
              this.code = code;
              this.description = description;
              this.price = price;
         public void setCode(String code)
              this.code = code;
         public String getCode(){
              return code;
         public void setDescription(String description)
              this.description = description;
         public String getDescription()
              return description;
         public void setPrice(double price)
              this.price = price;
         public double getPrice()
              return price;
         public String getFormattedPrice()
              NumberFormat currency = NumberFormat.getCurrencyInstance();
              return currency.format(price);
    Please help!

    Received the following errors.
    Product.java:3: Product is not abstract and does not
    override abstract method ge
    tDisplayText() in Displayable
    public class Product implements Displayable
    ^
    Product.java:16: getDisplayText() in Product cannot
    implement getDisplayText() i
    n Displayable; attempting to use incompatible return
    type
    found : void
    required: java.lang.String
    public void getDisplayText()
    ^
    2 errors
    Code reads as follows
    Please use the code tags when posting code. There is a code button right above the text box where you enter your post. Click on it and put the code between the code tags.
    These error messages are quite clear in telling what is wrong. You have an Interface called Displayable that specifies a method something like thispublic String getDisplayText() {But in your Product source code, you created thismethodpublic void getDisplayText() {The compiler is complaining because the methods are not the same.
    You also need to return a String in the method probalby like thisreturn message;

  • Overriding a method in abap

    In Java it is simple to extend a class and override a method - the whole idea of polymorphism. In abap, I'm attempting to do the same, but don't know quite how. I've created as a demo a zclass and made a sap standard class its superclass in properties. How do I override a protected method from here?

    Marcin says:
    Unfortunatelly overriding is not possible in ABAP, only redefinition is allowed. The method singature must stay the same in all subsequent classes.
    I guess,
    Overriding - Redefinition of the implementation of inherited method. This is possible by addition REDEFINITION to the method.
    Overloading - Changing the method parameters of inherited method
    Regards,
    Naimesh Patel

Maybe you are looking for

  • CD ROM/Blu-Ray player now missing in Windows Explorer for HP HDX18

    I currently have a: HP HDX X18T-1100 CTO Premium Notebook PC, product number: FJ927AV All of a sudden, I can no longer see the  CD player in windows explorer. If I put a CD in nothing plays, no blu-ray, no DVD, no music CD. If I look at the device in

  • HT204406 my itunes match has frozen 2 songs from the end of matching my music. what do i do to fix this?

    I have subscribed to itunes match and it checked all of my songs but has frozed 2 somge from the end of step 2 and won't move on to the next step. I don't know how to resolve this as I have tried stopping and starting it but it seems to freeze in the

  • Cant get itunes on my pc

    it downloads then says it cant instiall because something about 32win  i was told to try downloading the 32 bit version instead of the 64 but i am unable to find it on the website  this is all an attempt to upgrade my iphone through itunes because it

  • Ias version 10.1.3.4.0

    Hello, After the upgrade 12.1.3 , my ias version is 10.1.3.4.0. I thought 12.1.3 bring to 10.1.3.5.0. so do I need to apply any patches or upgrade? Thanks Prince

  • Can't open PS CC.

    A week ago I cancelled my full subscription and signed up for the PS Photographer CC. Everything was going fine until a few minutes ago. No matter what approach I take I can't open PSCC. I keep getting that I'm signed out or when online a 504 error,