Calling the super class method from the subclass

Hi all,
I have a question about inheritence and redefinition of methods. Is it possible to call the superclass implementation of a method which is redefined in the subclass in another method of the subclass?There are possbilities like creation of an explicit super class instance or delegating the super class method implementation to another method which is also protected etc. What i mean is, is there a direct way of calling it?We have ,me,   as the reference for the instance we have(which is the subclass instance in this case), is there also a way of pointing the superclass implementation(with super we can reference in the subclass redefinition, my question is if we have such a parameter in other methods of the subclass too)
Thanks in advance
Sukru

Hi,
The super reference can only be used in redefined methods to call superclass implementation . So probably what you can do is use upcasting and access the required superclass implementation. I can think of only this way...;-)
Ex data lr_super type ref to cl_superclass
lr_super = lr_subclass.
lr_super->method().
~Piyush Patil

Similar Messages

  • Can we call super class method from Overwrite method using SUPER keyword

    Hi All,
    For one of our requirement , I need to overwrite "Process Event" method of a feeder class  ,where process event is present is protected method. so when we are making a call , then its saying
    "Method  "process event"  is unknown or Protected  or PRIVATE ".
        But we are just copied the source code in the "Process Event" method to the Overwrite method.
    Can anyone provide me the clarification , why system behaving like this.
    Thanks
    Channa

    Hi,
    I think you can not.
    Because, only public attributes can be inherited and they will remain public in the subclass.
    for further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    regards,
    Anirban

  • Calling public class method  from the servlet dopost() implementation

    Hi!
    My application is a simple application where i wrote a JSP page to enter the USERNAME and PASSWORD. And this JSP will call a HttpServlet
    with in which i am calling another Java class ValidateUser which will check aginst the Oracle Database table whether that Username and password combination exists and returns the user's name.
    But when i am trying to call that method is throwing me an error. here is the typical code i wrote.
    servlet
    package isispack;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.*;
    public class Login extends HttpServlet{
    public void doPost(HttpServletRequest req, HttpServletResponse res)
                   throws ServletException,IOException{
    String userId = req.getParameter("user_id");
    String password = req.getParameter("user_pass");
    // if uName is null .. user is not authorized.
    String uName = Validate(userId, password);
    and
    Validate class
    package isispack;
    import java.sql.*;
    import java.util.*;
    import java.lang.*;
    public class ValidateUser
    public String ValidateUser(String inputUserid, String inputPwd) throws
    SQLException{
         String returnString = null;
         String dbUserid = "isis"; // our Database user id
         String dbPassword = "isisos" ; // our Database password
         Connection con = DriverManager.getConnection("jdbc:odbc:JdbcOdbcDriver","isis","osiris");
         Statement stmt = con.createStatement();
         String sql= "select user_id from isis_table where user_id = '" inputUserid + "' and user_pass= '" + inputPwd +"' ;" ;
         ResultSet rs = stmt.executeQuery(sql);
         if (rs.next())
         returnString = rs.getString("user_id");
         stmt.close();
         con.close();
         return returnString ;
    The ERROR
    Error(18,18): method ValidateUser(java.lang.String, java.lang.String) not found in class isispack.Login
    One more thing i forgot to tell you. I am trying to run this application on JDeveloper. Please helpme out if you can . Thank you.
    -Sreekanth

    OK! I made it static method
    and tried to call the method as follows
    String uName = ValidateUser.ValidateUser(userId, password);
    even if i create the instence and
    ValidateUser Validate;
    then call
    String uName= Validate.ValidateUser(userId,password)
    In either case is giving me the following error.Tarun, am new to Java programming, please help me out. And can you please tell me where can i find things in consise to brush up my fundamentals?.
    Error(18,43): unreported exception: java.sql.SQLException; must be caught or declared to be thrown

  • Accessing a java class method from the jsp page.

    Hi im a beginner with jsp and im trying to find a way to access a method of my java class file in jsp page. After searching through the forums i tried to use the usebean tag. Im using apache to host the jsp file.Below is an excerpt of my code and the error message i got. What am i doing wrong? anyone know?
    <%@ page language="java" %>
    <jsp:useBean id="movies" class="movie.Movie" />
    <jsp:setProperty name="movies" property="*"/>
    <%
    movies.getStart("file:///C:/Video/Applications2/sun.mpg");
    response.setContentType("text/xml");
    %>
    exception
    org.apache.jasper.JasperException: Exception in JSP: /View.jsp:7
    4: <jsp:setProperty name="movies" property="*"/>
    5: <%
    6:
    7: movies.getStart("file:///C:/Video/Applications2/sun.mpg");
    8: response.setContentType("text/xml");
    9: %>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.ServletException: javax/media/ControllerListener

    Hi thanks for responding. Ok i did look through and it was opening some gui. I still need the program to do server side processes so cant use an applet.but i dont need the gui so i revised it and removed the gui. also im using a servlet to call the class now yet i still have the same error. Any ideas?
    Below is the vid2jpg code minus the gui.
    import java.io.*;
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class vid2jpg implements ControllerListener
         Processor p;
         Object waitObj = new Object();
         boolean stateOK = true;
         DataSourceHandler handler;
    int imgWidth;int imgHeight;
         Image outputImage;
         String sep = System.getProperty("file.separator");
         int[] outvid;
         int startFr = 1;int endFr = 1000;int countFr = 0;
         boolean sunjava=true;
         * Static main method
         public static void main(String[] args)
              if(args.length == 0)
                   System.out.println("No media address.");
                   new vid2jpg("file:///C:/Video/applications2/sun.mpg");     // or alternative "vfw://0" if webcam
              else
                   String path = args[0].trim();
                   System.out.println(path);
                   new vid2jpg(path);
         * Constructor
         public vid2jpg(String path)
              MediaLocator ml;String args = path;
              if((ml = new MediaLocator(args)) == null)
                   System.out.println("Cannot build media locator from: " + args);
              if(!open(ml))
                   System.out.println("Failed to open media source");
         * Given a MediaLocator, create a processor and start
         private boolean open(MediaLocator ml)
              System.out.println("Create processor for: " + ml);
              try
                   p = Manager.createProcessor(ml);
              catch (Exception e)
                   System.out.println("Failed to create a processor from the given media source: " + e);
                   return false;
              p.addControllerListener(this);
              // Put the Processor into configured state.
              p.configure();
              if(!waitForState(p.Configured))
                   System.out.println("Failed to configure the processor.");
                   return false;
              // Get the raw output from the Processor.
              p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW));
              TrackControl tc[] = p.getTrackControls();
              if(tc == null)
                   System.out.println("Failed to obtain track controls from the processor.");
                   return false;
              TrackControl videoTrack = null;
              for(int i = 0; i < tc.length; i++)
                   if(tc.getFormat() instanceof VideoFormat)
                        tc[i].setFormat(new RGBFormat(null, -1, Format.byteArray, -1.0F, 24, 3, 2, 1));
                        videoTrack = tc[i];
                   else
                   tc[i].setEnabled(false);
              if(videoTrack == null)
                   System.out.println("The input media does not contain a video track.");
                   return false;
              System.out.println("Video format: " + videoTrack.getFormat());
              p.realize();
              if(!waitForState(p.Realized))
                   System.out.println("Failed to realize the processor.");
                   return false;
              // Get the output DataSource from the processor and set it to the DataSourceHandler.
              DataSource ods = p.getDataOutput();
              handler = new DataSourceHandler();
              try
                   handler.setSource(ods);     // also determines image size
              catch(IncompatibleSourceException e)
                   System.out.println("Cannot handle the output DataSource from the processor: " + ods);
                   return false;
         //     setLayout(new FlowLayout(FlowLayout.LEFT));
    //          currPanel = new imgPanel(new Dimension(imgWidth,imgHeight));
         //     add(currPanel);
         //     pack();
              //setLocation(100,100);
         //     setVisible(true);
              handler.start();
              // Prefetch the processor.
              p.prefetch();
              if(!waitForState(p.Prefetched))
                   System.out.println("Failed to prefetch the processor.");
                   return false;
              // Start the processor
              //p.setStopTime(new Time(20.00));
              p.start();
              return true;
         * Sets image size
         private void imageProfile(VideoFormat vidFormat)
              System.out.println("Push Format "+vidFormat);
              Dimension d = (vidFormat).getSize();
              System.out.println("Video frame size: "+ d.width+"x"+d.height);
              imgWidth=d.width;
              imgHeight=d.height;
         * Called on each new frame buffer
         int nextframetime = 0;
    private void useFrameData(Buffer inBuffer)
    try
    if(inBuffer.getData()!=null) // vfw://0 can deliver nulls
    if(sunjava) // and with import javax.imageio.*;
    int frametimesecs = (int)(inBuffer.getTimeStamp()/1000000000);
    if(frametimesecs%10 == 0 && frametimesecs==nextframetime)
    nextframetime+=10;
    BufferedImage bi = new BufferedImage(outputImage.getWidth(null), outputImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics g = bi.getGraphics();
    ImageIO.write(bi, "png", new File("images"+sep+"image_"+(inBuffer.getTimeStamp()/1000000000)+".png"));
    catch(Exception e){}
         * Tidy on finish
         public void tidyClose()
              handler.close();
              p.close();
         * Block until the processor has transitioned to the given state
         private boolean waitForState(int state)
              synchronized(waitObj)
                   try
                        while(p.getState() < state && stateOK)
                        waitObj.wait();
                   catch (Exception e)
              return stateOK;
         * Controller Listener.
         public void controllerUpdate(ControllerEvent evt)
              if(evt instanceof ConfigureCompleteEvent ||     evt instanceof RealizeCompleteEvent || evt instanceof PrefetchCompleteEvent)
                   synchronized(waitObj)
                        stateOK = true;
                        waitObj.notifyAll();
              else
              if(evt instanceof ResourceUnavailableEvent)
                   synchronized(waitObj)
                        stateOK = false;
                        waitObj.notifyAll();
              else
              if(evt instanceof EndOfMediaEvent || evt instanceof StopAtTimeEvent)
                   tidyClose();
         * Inner classes
         * A DataSourceHandler class to read from a DataSource and displays
         * information of each frame of data received.
         class DataSourceHandler implements BufferTransferHandler
              DataSource source;
              PullBufferStream pullStrms[] = null;
              PushBufferStream pushStrms[] = null;
              Buffer readBuffer;
              * Sets the media source this MediaHandler should use to obtain content.
              private void setSource(DataSource source) throws IncompatibleSourceException
                   // Different types of DataSources need to handled differently.
                   if(source instanceof PushBufferDataSource)
                        pushStrms = ((PushBufferDataSource) source).getStreams();
                        // Set the transfer handler to receive pushed data from the push DataSource.
                        pushStrms[0].setTransferHandler(this);
                        // Set image size
                        imageProfile((VideoFormat)pushStrms[0].getFormat());
                   else
                   if(source instanceof PullBufferDataSource)
                        System.out.println("PullBufferDataSource!");
                        // This handler only handles push buffer datasource.
                        throw new IncompatibleSourceException();
                   this.source = source;
                   readBuffer = new Buffer();
              * This will get called when there's data pushed from the PushBufferDataSource.
              public void transferData(PushBufferStream stream)
                   try
                        stream.read(readBuffer);
                   catch(Exception e)
                        System.out.println(e);
                        return;
                   // Just in case contents of data object changed by some other thread
                   Buffer inBuffer = (Buffer)(readBuffer.clone());
                   // Check for end of stream
                   if(readBuffer.isEOM())
                        System.out.println("End of stream");
                        return;
                   // Do useful stuff or wait
                   useFrameData(inBuffer);
              public void start()
                   try{source.start();}catch(Exception e){System.out.println(e);}
              public void stop()
                   try{source.stop();}catch(Exception e){System.out.println(e);}
              public void close(){stop();}
              public Object[] getControls()
                   return new Object[0];
              public Object getControl(String name)
                   return null;
    below is the servlet code.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class ShowMovie extends HttpServlet {
    String rootURL="http://127.0.0.1:8080/Video/";
    public void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         //String movie=request.getParameter("movie");
         String movie ="son";
         getStart(movie);
              response.sendRedirect(rootURL+"View.jsp");
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
         public void getStart(String url){
              new vid2jpg(url);
    this is the error from the server. Im using tomkat 5
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoClassDefFoundError: javax/media/ControllerListener
         java.lang.ClassLoader.defineClass1(Native Method)
         java.lang.ClassLoader.defineClass(Unknown Source)
         java.security.SecureClassLoader.defineClass(Unknown Source)
         org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
         org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         java.lang.ClassLoader.loadClassInternal(Unknown Source)
         ShowMovie.getStart(ShowMovie.java:31)
         ShowMovie.processRequest(ShowMovie.java:14)
         ShowMovie.doGet(ShowMovie.java:22)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

  • Calling a Swing class method from from another swing class method

    Hi guys,
    I'm desperate for help or a pointing in the right direction. Basically, I want to call the public void createUI method in class AddressUI in the public void createUI method of PartnerUI class. Is that legal? How do I go about it? Thanks.
    package com.client.gui;
    import java.awt.*;
    import javax.swing.*;
    import client.application.MainFrame;
    import client.gui.base.BasicDialogUI;
    import client.page.base.BasicDialogPage;
    import client.table.model.AddressModel;
    public class AddressUI extends BasicDialogUI{
         private static final long serialVersionUID = -1214150134433745466L;
         public AddressUI(MainFrame frame, BasicDialogPage page) {
              super(frame, page);
         @Override
         public void createUI() {
         AddressModel am = new AddressModel();
         JTable table = new JTable(am);
         table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         table.setColumnSelectionAllowed(true);
         JScrollPane scroller = new JScrollPane(table);
         scroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         scroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
         JPanel addressPanel = new JPanel(new FlowLayout());
         addressPanel.setBackground(Color.BLUE);
         addressPanel.setForeground(Color.WHITE);
         addressPanel.setOpaque(true);
         JLabel addressHeader = new JLabel("Anschriften:");
         JPanel addressHeaderPanel = new JPanel();
         addressHeaderPanel.setBackground(Color.BLUE);
         addressHeaderPanel.setForeground(Color.WHITE);
         addressHeader.setOpaque(true);
         addressHeaderPanel.add(addressHeader);
         JButton buttonNew = new JButton("Neu");
         JButton buttonChange = new JButton("Ändern");
         JButton buttonDelete = new JButton ("Löschen");
         JPanel buttonsPanel = new JPanel(new FlowLayout());
         buttonsPanel.add(buttonNew);
         buttonsPanel.add(buttonChange);
         buttonsPanel.add(buttonDelete);
         addressPanel.add(buttonsPanel, FlowLayout.RIGHT);
         addressPanel.add(scroller, FlowLayout.CENTER);
         addressPanel.add(addressHeaderPanel, FlowLayout.LEFT);
         public final void showUI() {
              createUI();
              getMainFrame().setDialogPanel(this);
              getMainFrame().pack();
              this.setVisible(true);
         @Override
         public void formToModel() {
         @Override
         public void modelToForm() {
         @Override
         public boolean validateUI() {
              return true;
    package com.impaqgroup.pp.client.gui;
    import java.awt.BorderLayout;
    import java.awt.Color;
    import javax.swing.JPanel;
    import javax.swing.JTable;
    import com.impaqgroup.pp.client.application.MainFrame;
    import com.impaqgroup.pp.client.gui.base.BasicDialogUI;
    import com.impaqgroup.pp.client.page.base.BasicDialogPage;
    import com.impaqgroup.pp.client.table.model.PartnerModel;
    public class PartnerUI extends BasicDialogUI{
         private static final long serialVersionUID = 1024614598666310834L;
         public PartnerUI(MainFrame frame, BasicDialogPage page) {
              super(frame, page);
         @Override
         public void createUI() {
              JPanel partnerPanel = new JPanel();
              partnerPanel.setBackground(Color.BLUE);
              partnerPanel.setForeground(Color.WHITE);
              partnerPanel.setOpaque(true);
              PartnerModel pm = new PartnerModel();
              JTable partnerTable = new JTable(pm);
              partnerTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
              partnerTable.setColumnSelectionAllowed(true);
              partnerPanel.add(partnerTable, BorderLayout.CENTER);
         @Override
         public final void showUI() {
              createUI();
              getMainFrame().setDialogPanel(this);
              getMainFrame().pack();
              this.setVisible(true);
         @Override
         public void formToModel() {
         @Override
         public void modelToForm() {
         @Override
         public boolean validateUI() {
              return true;
    }

    Have you tried adding something like the below to PartnerUI#createUI() ?
    AddressUI aui = new AddressUI( getMainFrame(), getPage() );
    aui.createUI();

  • Weird one..  i can't return a variable from the extended to the super class

    Hey everyone, i hope i'm not annoying you guys :)
    So today's problem is to return a variable (int) from a method of the extended class and print it ont the super class.
    I'm just testing the super class , if it works fine.
    So the extended class ( FileIO) just read the file txt and return the integer or string ( from the txt file)
    I already did a main method to that class and tested it, it works fine.
    So now the problem is to print the integer ( that the extended class gets from the txt. ) inside the Super class. I mean , is the same thing but now im testing the Super class , just have to do the same thing, a super class method calls the extended class method and receive the integer from the txt file.
    i think the problem is when i create the instance of the FileIO object , maybe its constructor ...i don't know.
    The name of the txt file is passed from the super class to the extended class, but i think the error is not from there.
    this.aero_le = new BufferedReader(new FileReader(super.ficheiroleitura_aero()));  //  super calls ficheiroleitura_aero()  and receive the name of the txt file ( e.g "temp.txt")  so i think that is correct.
    here's the code of the Super class public class Aeroporto {
         private String filereader_voo = "temporary.txt";
         private String filereader_aero = "temp.txt";
         private String siglaAero = "";
         public FileIO file;
         public Aeroporto(){};
         public Aeroporto(String filereader_voo, String filereader_aero) throws IOException{
              this.filereader_voo = filereader_voo;
              this.filereader_aero =filereader_aero;     
              file = new FileIO();
         public String siglaAero() {
              return siglaAero; }
         public String filereader_aero(){
              return filereader_aero;
    public int nrLines() throws IOException{   // it was supose to retunr the number of lines ( integer) from the txt file .
              return Integer.parseInt(file.lerLinhaN(1,1));
    // main() {
    Aeroporto a = new Aeroporto();
              int v = a.nrLines();
              System.out.print(v);
    // ***********************************************************+
    // Extended Class
    public class FileIO extends Aeroporto{
         private String ficheiroescrita;
         private PrintWriter vooescreve, aeroescreve ;
         private BufferedReader voo_le, aero_read;
         public FileIO(){}
         public FileIO(String filereader_voo, String filereader_aero, String ficheiroescrita) throws IOException {
              super(filereader_voo, filereader_aero);
              this.ficheiroescrita = ficheiroescrita;
              //If file does not exists , create one.
              try{
                   this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
                   aero_read.close();
              catch(IOException ex){
                   this.aeroescreve = new PrintWriter(new FileWriter(ficheiroescrita));
                   aeroescreve.close();
    public String lerLinhaN(int line, int column) throws IOException{  // this method works fine , i already tested this class.
              this.aero_read = new BufferedReader(new FileReader(super.filereader_aero()));
              for(int i = 0; i != line-1; ++i) aero_read.readLine();
              String linha = aero_read.readLine();
              String [] words = linha.split(" ");
              return words[column-1];
    Maybe the error is that i use to test the Super class a default contructor on both classes... i don't know where the error is, i also did two small classes ( super and another that extends ) and get the string "Hello" from the super and print it inside the extended..and it works, that's why i think the error is when i call the extended class .. need help.
    thanks.

    Ok,
    This one might actually work... atleast it compiles.import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.File;
    import java.io.PrintWriter;
    import java.io.FileWriter;
    import java.io.IOException;
    public abstract class FileIO {
         public static boolean CreateOutputFileIfNotExists(
              String outputFilename //the name of the file to ensure exists.
         ) throws IOException
              final String functionName = "FileIO.CreateOutputFileIfNotExists";
              boolean retVal = false;
              //If the output file does does not exist then create it.
              //post condition: output file exists or an IOException has been thrown.
              BufferedReader infile = null;
              try{
                   infile = new BufferedReader(new FileReader(outputFilename));
                   retVal = true;
              } catch(IOException ex) {
                   PrintWriter outfile = null;
                   try {
                        outfile = new PrintWriter(new FileWriter(outputFilename));
                        retVal = true;
                   } catch(IOException ex2){
                        throw new IOException(functionName + ": cannot create output file " + outputFilename, ex2);
                   } finally {
                        outfile.close();
                        if (outfile.checkError()) {
                             throw new IOException(functionName + ": error on output stream " + outputFilename);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close output file " + outputFilename, ex);
              return(retVal);
         public static String readLine(
                   String  inputFilename //the name of the file to read.
              , int     lineNumber    //1 based number of the line to read from.
         ) throws IOException
              final String functionName = "FileIO.readLine";
              String outputLine = null;
              // reads the numbered "lineNumber" from "inputFilename".
              BufferedReader infile = null;
              try {
                   infile = new BufferedReader(new FileReader(new File(inputFilename)));
                   for(int i=1; i<lineNumber; ++i) infile.readLine();
                   outputLine = infile.readLine();
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              } finally {
                   try {
                        infile.close();
                   } catch(IOException ex){
                        throw new IOException(functionName + ": cannot close input file " + inputFilename, ex);
              return(outputLine);
         public static String readWord(
                   String inputFilename  //the name of the file to read.
              , int lineNumber        //1 based number of the line to read from.
              , int wordNumber        //0 based number of the word to read.
         ) throws IOException
              final String functionName = "FileIO.readWord";
              String outputWord = null;
              // reads the numbered space-seperated "wordNumber" from the numbered "lineNumber" of "inputFilename"
              try {
                   String[] words = FileIO.readLine(inputFilename, lineNumber).split(" ");
                   if (wordNumber>0 && wordNumber<words.length) outputWord = words[wordNumber-1];
              } catch(IOException ex){
                   throw new IOException(functionName + ": cannot read input file " + inputFilename, ex);
              return(outputWord);
    }Design notes... FileIO is a generic helper class... there is nothing specific to Airports, flights, or any other "domain" specific stuff in it... so it's re-usable... you can keep it and reuse it on other projects, or even share it with your friends.
    So... The airport class will just call the static methods on FileIO like this    ....
        int lineNumber=1;
        int wordNumber=1;
        String airportCode = FileIO.readWord(airportsFilename, lineNumber, wordNumber);
        ....How's that?
    corlettk: my now mandatory edit.

  • Can we chagne Super class method parameters in Sub class

    Hi,
    I created a super class.  In that class i created a method. That method is having 4 input parameters and 4 export parameters.
    I created a sub class for that super class. I need to use only 2 input parameters in this class rather than 4 parameters. I want to delete 2 Input parameters in the sub class of the super class method.  Is it possible.
    If possible. can we give an simple code or pseudo code?
    regards,
    krishna

    Hi,
    I think you can not.
    Because, only public attributes can be inherited and they will remain public in the subclass.
    for further detail check,
    http://help.sap.com/saphelp_nw70/helpdata/en/1d/df5f57127111d3b9390000e8353423/content.htm
    regards,
    Anirban

  • 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.

  • Calling methods from the Business Object BUS2032

    Hi all,
    Is it possible to call methods from the Business Object BUS2032.
    If so, how can it be done??
    Regards,

    Hi Marv,
    you sure can. Here is an extract from the SAP Help. I found it at http://help.sap.com/saphelp_46c/helpdata/en/c5/e4ad71453d11d189430000e829fbbd/frameset.htm
    <b>Programmed Method Call</b>
    Call (fictitious) method Print of object type VBAK (sales document). The method receives the parameters Paperformat and Printertype as input.
    * Call method Print of object type VBAK
    * Data declarations
    DATA: VBAK_REF TYPE SWC_OBJECT.
    SWC_CONTAINER CONTAINER.
    * Create object reference to sales document
    SWC_CREATE_OBJECT VBAK_REF 'VBAK' <KeySalesDoc>
    * Fill input parameters
    SWC_CREATE_CONTAINER CONTAINER.
    SWC_SET_ELEMENT CONTAINER 'Paperformat' 'A4'.
    SWC_SET_ELEMENT CONTAINER 'Printertype' 'Lineprinter'.
    * Call Print method
    SWC_CALL_METHOD VBAK_REF 'Print' CONTAINER.
    * Error handling
    IF SY-SUBRC NE 0.
    ENDIF.
    Cheers
    Graham

  • How to find the arguments of a static method from the class file

    Hi,all !
    How to find the arguments of a static method from the class file? for example, when we meet a bytecode "invokestatic", how can I know the arguments of this static method?

    Hi,all !
    How to find the arguments of a static method from the
    class file? for example, when we meet a bytecode
    "invokestatic", how can I know the arguments of this
    static method?You mean
    1. The values?
    2. Argument names?
    3. Argument signatures.
    I would suppose for the last that the easiest way would be to parse the signature string.
    The first is not possible - not from the class file.
    The second is only in the debug information stored in the optional part of the class file. And figuring out the format for that is going to be a problem.

  • How to pass importing parameter of super class method to subclass method?

    hi all,
    i have defined  a class
    CLASS CUST_REPORT DEFINITION.
      PUBLIC SECTION.
        METHODS:DATA_RETRIVE IMPORTING  CUSTID_LOW  TYPE ZCUSTOMER-ZCUSTID
                                       CUSTID_HIGH TYPE ZCUSTOMER-ZCUSTID.
        DATA:IT_CUST TYPE TABLE OF ZCUSTOMER,
             WA_CUST TYPE ZCUSTOMER.
    ENDCLASS.                    "cust_report DEFINITION
    The method DATA_RETRIVE   in this class  has two importing parameters named CUSTID_LOW   and CUSTID_HIGH.
    then i have defined subclas of this clas.
    LASS CUST_ORD DEFINITION INHERITING FROM CUST_REPORT.
      PUBLIC SECTION.
        DATA:IT_ORD TYPE TABLE OF ZORDER.
        METHODS:DATA_RETRIVE  REDEFINITION,
               DISPLAY.
    ENDCLASS.                    "cust_ord DEFINITION
    Method DATA_RETRIVE   is redefined.
    So how to pass importing parameteres of super class method to sub class method with the same name.
    Thanks and Regards,
    Arpita

    Hi,
    I tried like this.
    METHOD DATA_RETRIVE.
    CALL METHOD SUPER->DATA_RETRIVE
          EXPORTING
            CUSTID_LOW  = I_CUSTLOW
            CUSTID_HIGH = I_CUSTHIGH.
    ENDMETHOD.
    But  parameters I_CUSTLOW and I_CUSTHIGH are not getting values after call to method.
    Thanks and Regards,
    Arpita

  • How do I call an Application Module method from a EntityImpl class?

    Guys and Gals,
    Using Studio Edition Version 11.1.1.3.0.
    I've got a price update form, that when submitted, takes the part numbers and prices in the form and updates the corresponding Parts' price in the Parts table. Anytime this Parts view object's ReplacementPrice attribute is changed, an application module method needs to be called which updates a whole slew of related view objects. I know you can modify view objects via associations (How do I call an Application Module method from a ViewObjectImpl class? but that's not what I'm trying to do. These AppModuleImpl methods are the hub for all price updates, as many different operations may affect related pricing (base price lists, price buckets, etc) and hence, call the updatePartPricing(key) method.
    For some reason, the below code does not call / run / activate the application module's method. The AppModuleDataControl exists and recordPartHistory(key) is registered and public. At runtime, the am.<method> code is simply ignored, and as a weird side-effect, I cannot navigate out of my current page flow.
      public void setReplacementPrice(Number value)
        setAttributeInternal(REPLACEMENTPRICE, value);
        AppModuleImpl am = (AppModuleImpl)this.getDBTransaction().findApplicationModule("AppModuleDataControl");
        Key key = new Key(new Object[]
            { getPartNumber() });
        am.recordPartHistory(key);  // AppModuleImpl method which records pricing history
        am.updatePartPricing(key); // AppModuleImpl method which updates a whole slew of related pricing tables
      }Any ideas?

    Thanks Timo.
    Turns out the code provided was correct, but the AppModuleImpl method being called was not. A dependent ViewObject wasn't returning the row I was expecting. I then tried to perform some operations on that row, which in turn ... just stopped everything, but didn't give me an error.
    It was the lack of the error that threw me off. I had never messed with calling an AppModuleImpl method from the EntityImpl so I assumed that's what was messing up.
    You are correct. It is available from the ViewRow, but I thought it better to put it in the EntityImpl. This method will be called every time the replacement cost is modified. If I didn't put it in the EntityImpl, I'd have to remember to call it every time a replacement cost changed.

  • Call enhancement class method from Bus. workflow task

    Hi all,
    I recently enhanced a global class from SAP (add a new method). Now I would like to call it from a workflow task (ABAP Class object used in the task). So it seems that only "native" methods from the class itself can be selected for the object method of the task.
    Same issue if I try to call it via secondary methods options...
    Last idea I have before the repair is: retrieve the instance saved into the WF container via a custom class interfacing IF_IFS_SWF_CONTAINER_EXIT (program exit) and call the enhanced method from the method proposed in this interface.
    Maybe someone had the same issue? Anyone could help or propose solution?
    Many thanks in advance for your help,
    KR,
    Olivier

    I think it might qualify for an OSS message.
    There was simmilar note for BADIs which was corrected: https://service.sap.com/sap/support/notes/1156392
    CL_SWF_UTL_DEF_SERVICES which is used in PFTC to determine callable methods doesn't include enhancements when calling  function SEO_CLASS_TYPEINFO_GET (parameter WITH_ENHANCEMENTS is default FALSE)

  • How to indicate the object of the super Class ?

    hello,
    I need to notify when one dialog is close to the class that generated it.
    Of course I do it from the method windowClosing() in the class WindowAdapter.
    But if I use "this" how parameter in the method, I noted the value is that of the inner anonymous class, and not that of the dialog class.
    I write down some code to reproduce the problem ....
    public ReferenceToTheSuperClass() {
            final SecondClass sc = new SecondClass(this);
            jButton1 = new javax.swing.JButton();
    //        final ReferenceToTheSuperClass xx = this;
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                     sc.checkSuper(xx);                    // work
                     sc.checkSuper(this);                   // not work
                     sc.checkSuper(super.getClass()); // not work
    }  // ReferenceToTheSuperClass
    class SecondClass {
        ReferenceToTheSuperClass superiorClass;
        public SecondClass(ReferenceToTheSuperClass supClass){
            superiorClass = supClass;
        public void checkSuper(Object o){
            if (o instanceof ReferenceToTheSuperClass){
                JOptionPane.showMessageDialog(null,"HELLO");
    } // SecondClass My ask is: It is possible to indicate the value of the instance of the super Class, inside one his anonynimous inner class?
    thank you
    regards
    tonyMrsangelo

    thank you for your kinkly answer jeverd,
    yes what you say is right, in this case the class is only nested (in the hurry I used a wrong word).
    About the sintax, I vould find only a short statement to use inside the inner anomymous class and, reading what you say, I can guess it is not possible to do it..
    again thank you
    regards
    tonyMrsangelo

  • Invoking the scheduler's doScheduledTask method from the jsp

    Hi Folks,
    Could you please throw some ideas on my issue,
    I would like to invoke the scheduler's doScheduledTask method from the jsp.
    approach is like...
    I have JSP and a form. Form has a one text field and i will give some value and clicks on the submit button, it should invoke the scheduler method.
    or
    if you know any other approach to invoke the scheduler's doScheduledTask method from the jsp is invitable.
    Thanks much in advance

    Hi,
    1. Create the form in the jsp and a form handler to process this form, say InvokeSchedulerFormHandler.
    2. Create a variable to refer to the scheduler.
    MyScheduler myScheduler;
    // create getter and setter for this.
    3.. Create a handle method, handleInvokeScheduler(). Do any validations if required.
    4. After the validations, call getMyScheduler().doScheduledTask();
    5. In the jsp, map the submit button to this handle method.
    <dsp:input type="submit" bean="InvokeSchedulerFormHandler.invokeScheduler" value="Submit"/>
    6. Create the .properties file to the form handler and to your scheduler.
    MyScheduler.properties
    $class=com.package.MyScheduler
    $scope=global
    InvokeSchedulerFormHandler.properties
    $class=com.package.InvokeSchedulerFormHandler
    $scope=request
    myScheduler=/com/package/MyScheduler
    (Am wondering about this requirement :) . If you can specify the reason, it will be helpful).
    Hope this helps.
    Keep posting the questions / updates.
    Thanks,
    Gopinath Ramasamy

Maybe you are looking for

  • How do i turn off Mobile Me sync? It paralyzes my machine!

    I no longer have my MobileMe account, but the MobileMe sync icon is still at the top right of my screen and periodically tries to identify sync conflicts (it says there are 24) and then totally slows down my machine to a crawl and the spinning wheel

  • Itunes 11.1.4 won't drag and drop for ios 5.0.1

    I have an older iPod touch running 5.0.1 and have ALWAYS manually managed the music on it.  I recently updated itunes to 11.1.4.62 and now the 'drag and drop' function in itunes doesn't work.  I have verified that the 'manually mangage music and vide

  • HT1212 I CANT GET IT TO RESTORTE CAN SOMEBODY PLEASE HELP ME

    please somebody please tell what do i click on to restore my ipad please i really need help please

  • Error with Windows NT?

    Hi, i just installed the JMF Performance Pack for Windows. When auto detecting Capture Devices, i recieve (german) 'Ordnungsfehler 6' in dsound.dll. What does this error mean? (Fehler=error) thanks in advance, JCheckBox

  • Migrate from SDK 3 to 4 or 5

    Im using a borrowed imac with os x leopard version to develop my first iphone app. The problem is that i can't use the sdk 4 or 5. In case i need to migrate my sdk 3 based app to those versions, will be any problem with xcode or anything?