Question on Method interface

Hi
I've the following method def:
   METHODS : METH1 IMPORTING INPUT1 TYPE I  
                                                              INPUT2 TYPE REF TO  CL_1.
where CL_1 is the class withing where the method is defined.
Question is, what is this kind of definition and whats the use in real time implementation?
thkx
P.S

It can also be used in generic calls. Suppose we have vehicle class.
CLASS lcl_vehicle DEFINITION.
   PUBLIC SECTION.
      METHODS: add_vehicle IMPORTING l_veh TYPE REF TO lcl_vehicle,
                        estimate_fuel.
      "table storing vehicles
      DATA: BEGIN OF it,
                   vehicle TYPE REF TO lcl_vehicle,
                 END OF it,
                 wa LIKE LINE OF it.
ENDCLASS.
CLASS lcl_vehicle IMPLEMENTATION.
    METHOD add_vehicle.
        wa-vehicle = l_veh.
        APPEND wa TO it.
    ENDMETHOD.
    METHOD estimate_fuel.
        LOOP at IT into WA.
           wa-vehicle->estimate_fuel( ).              "here we can call same method of different subclasses with different implementation
        ENDLOOP.
    ENDMETHOD.
ENDCLASS.
Now we create to subclasses.
CLASS lcl_plane DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION.
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.
CLASS lcl_ship DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION.
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.
Two different vehicles will redefine an estimate_fuel method as each has to take different factors into account when tanking up.
We would like to handle both plane and ship from one point. For this we add our new vehicles to the table of lcl_vehicle class.
DATA: r_vehicle TYPE REF TO lcl_vehicle,
          r_plane    TYPE REF TO lcl_plane,
          r_ship      TYPE REF TO lcl_ship.
CREATE OBJECT: r_vehicle, r_plane, r_ship.
"add all vehicles to the table
r_vehicle->add( r_plane ).
r_vehicle->add( r_ship ).
"Now we can perform generic call
r_vehicle->estimate_fuel( ).  "this will call same method of two subclasses with different implementation, from one point
It would be easy now to handle new vehicle
CLASS lcl_motorbike DEFINITION INHERITING FROM lcl_vehicle.
   PUBLIC SECTION.
      METHODS estimate_fuel REDEFINITION.
ENDCLASS.
DATA: r_motorbike TYPE REF TO lcl_motobike.
r_vehicle->add( r_motorbike ). "it is enough to add the vehicle, this already suits our model and appropriate method will be called for estimating fuel
Regards
Marcin
Edited by: Marcin Pciak on Mar 23, 2009 10:17 PM

Similar Messages

  • Question about IDashedAttributeValues interface

    Hi to everyone,<br />I have a question about IDashedAttributeValues interface.<br />If I would like to apply custom dashes kDashedAttributeValuesBoss to a page item. I would expect that my code will look like this:<br /><br />InterfacePtr<IDashedAttributeValues> pAttribute(::CreateObject(kDashedAttributeValuesBoss));<br /><br />pAttribute->SetPhase( nPhase );<br />pAttribute->SetCornerAdjustment((IDashedAttributeValues::CornerAdjustment)nCornerAdjust ment);<br />pAttribute->SetValue( 0, nDash0 );<br /><br />But InDesign crashes at SetValue code. I could understand InDesign. It is out of range. But, how to specify the length of value array or to add value into array?<br /><br />Thanks in advance,<br />Alexander Staroverov<br />Developer Engineer<br />Comosoft GmbH

    Thank you to all, I have found the answer in SDK samples:<br /><br />void SnpGraphicHelper::AddDashedValues(const K2Vector<PMReal>& dashAndGapValues)<br />{<br />IDataBase* db = fItemList.GetDataBase();<br />InterfacePtr<IDocument> theDocument(db, db->GetRootUID(), UseDefaultIID());<br />     InterfacePtr<IUIDData> uidData(::CreateObject2<IUIDData>(kDashedAttributeValuesBoss));<br />     ASSERT(uidData != nil);<br />     uidData->Set(::GetUIDRef(theDocument));<br />     InterfacePtr<IDashedAttributeValues> dashedAttributeValues(uidData, UseDefaultIID());<br />     if (dashedAttributeValues != nil && dashAndGapValues.size() > 0) {<br />          for (int32 i = 0; i < dashAndGapValues.size(); i++) {<br />               dashedAttributeValues->SetValue(i, dashAndGapValues[i]);<br />          }<br />          this->AddAnAttribute(dashedAttributeValues);<br />     }<br />}

  • Is there anyone using Java Methods interface of IREP in his application

    Hello everyone,
    Are you using Java Methods interface of IREP in your application?
    Nowadays I am trying to using Java Methods in my application. But I'm puzzled how to get the interface jar files that the Java Methods would import. It seems that Oracle doesn't provide such interface jar files for all Java Methods shipped in IREP. How do you do with this?
    If you have some experience about using Java Methods in application, hope to hear your voice. Thanks in advance.

    Hi friend,
    Thanks for you update.
    I'm referring to Java Methods that can be called directly by applications not Java Service Interface. These are two different kinds of IREP interfaces. In Oracle Integration Repository User's Guide, there aren't much guidance about how to use Java Methods.
    I appreciate you can help me further.

  • A question on methods and parameters.

    Hey guys, it's my first time posting here. I'm very new to Java, and did a bit of C++ prior to Java. I had a question on methods and parameters. I don't quite understand methods; I know that they can be repeated when called, but thats almost about it. I also know that a program must have one class that holds the main method. What I truly, truly don't understand about methods is what parameters are. I know they go in the parentheses, and that's it. Could you please explain what they are? I truly appreciate it. Thanks to all in advance. Regards, Michael

    Taking an example :
    Suppose you are calculating area of rectangle you need two inputs one is length and breadth.Area = l X b where l = length, b = breadth
    So your method, say, calculateAreaOfRectangle(int length, int breadth) will have two input parameters as arguments.
    System.out.println("Area of rectangle:"+calculateAreaOfRectangle(40,30);
    public int calculateAreaOfRectangle(int length, int breadth) {
    int Area;
    Area = length * breadth;
    return Area;
    So if you call this method then the output will be returned as 120.
    Parameters of a method are just the input variables needed for the method to process for any calculations or anything useful.
    And we cant have methods inside main method in Java. It is against the java syntax and if you do, it will throw a syntax error.

  • HT5787 i forgot Icloud password and security question what method i can use to reset it is ther any or what i am still using iphone but my icloud is disabled for to many atempts what now how to rest the password

    i forgot Icloud password and security question what method i can use to reset it is ther any or what i am still using iphone but my icloud is disabled for to many atempts what now how to rest the password

    Hi bekimlorini,
    Thanks for visiting Apple Support Communities.
    You may find this article helpful with resetting your security questions:
    Rescue email address and how to reset Apple ID security questions
    http://support.apple.com/kb/HT5312
    If you're not able to receive email to your rescue email address, you may need to contact iTunes Store Support:
    You'll need to contact iTunes Store support to have your questions and answers reset.
    All the best,
    Jeremy

  • Method / interface question

    How do i write a method that takes an interface as an argument ?
    void MethodName(interface InterfaceName){  }
    void MethodName(InterfaceName){  }
    ????

    Same as you would with any other Class:
    public MyClass {
      public void myMethod(InterfaceName interfaceInstance) {
    }

  • Question related to interface....

    hello everybody,
    Consider following example as :
    Interface Inter1{
       public void showResult();
    Class Abc implements Inter1{
       // Other stuff for class Abc.
       // implementation for method showResult()
       public void showResult()[
         System.out.println("Inside class Abc");
    Class Pqr implements Inter1{
       // Other stuff for class Pqr.
       // implementation for method showResult()
       public void showResult()[
         System.out.println("Inside class Pqr");
    // Now, main class as :
    Class MainClass{
       public static void main(string []args){
          Inter1 i1 = (Inter1) some_method_which_return_object();
        // Now, if I make call like this :
        i1.showResult();        
    Now, my question is if I run above code then what ll be the output & why??
    can anybody please help me in detail...
    Thank you very much

    Dream-suyog wrote:
    Now, my question is if I run above code then what ll be the output
    The answer to that is always the same: Run it and see.
    & why??*The answer to that is: What do you think? Once you provide your thoughts, somebody else will be happy to comment on them.
    (And yes, I'm aware that it won't compile because some_method_which_return_object() does not exist. I still think it's best for the OP to acknowledge that first, either because he knows it, or because he gets an error when he tries to compile, and then work from there.)

  • Question about documentation & interface inheritance

    If I have interface Foo that extends interface Bar, I'm wondering if there's a way for Foo to add more documentation to one of Bar's methods.
    For example, if I have:
    public interface Foo {
      * The "stuff" that gets done by this method should be more properly defined in the implementing class.
      void doStuff();
    public interface Bar extends Foo {
    }Is there any way for me to specify for Bar to override the doc on the doStuff() method inherited from Foo (such that it might read something like "The doStuff() method of all implementers of Bar should [behave in x manner]")?
    I realize I'm probably not articulating myself totally clearly, so let me know if I need to shed light on anything.
    Thanks!
    Edited by: Caryy on Nov 30, 2010 4:06 PM

    jverd wrote:
    I think you're allowed to declare an identical doStuff() method in Bar and give it its own documentation. It won't just get concatenated on to the supertype's doc, but the javadoc tool might generate a link to the parent method like it does when a class overrides or implement a method.Wow... >_< I thought I tried that and failed before asking this question, but it appears that you are correct (I must have typo'd or something)! Thanks for the fast reply and sorry for the n00b question....

  • A question about using INTERFACE?

    I was writing a xml dom application..
    I tried to use some sample code,
    it works fine..
    I import some class for xml parsing..
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    and I open the Node.java and NodeList.java in the dom directory, and see the Node is an public interface
    public interface Node {
    my question is..
    if Node is an interface, why I can use directly the function of Node object in my DOM application code..
    like:
    Node node;
    String val=node.getNodeValue()
    I don't understand that.
    why we can declare an object of Node(which is interface), and use it's function??

    If Node is an interface, why I can use directly
    the function of Node object in my DOM
    application code..
    like:
    Node node;
    String val=node.getNodeValue()
    I don't understand that. why we can declare an
    object of Node(which is interface), and use it's
    function??
    Just like u can use the Connection interface in JDBC to
    create a Statement interface object.
    U can have objects whose reference belongs to an interface type. That way the ppl here at SUN have
    restricted you from running any other methods other
    than those listed in the interface object reference. This
    creates a very strict inheritance heirarchy which is
    impossible to break.
    For example, you cannot possiblly run or create any
    other methods than those listed in the Connection
    interface in JDBC API. This is bcoz although the object
    at runtime might denote an implementation of the
    interface BUT the reference through which u have
    access to it is only a predefined interface.

  • EXTREMELY URGENT!!  Last question on Local Interfaces

    Using Oracle9iAS 9.0.3
    Running on RedHat 8.0
    Trying to implement local interfaces to my entity bean. (Oracle9iAS Containers for J2EE for 9.0.3) provides an example for writing local interfaces.
    pg. 2-10 states:
    //The variable is specified in the assembly descriptor (META-INF/ejb-jar.xml)
    Object homeObject = context.lookup("java:comp/env/EmployeeLocalBean");
    but, if you look at the ejb-jar.xml they reference, it's as follows (pg. 2-12):
    <ejb-jar>
    <enterprise-beans>
    <session>
    <description>Session Bean Employee Example</description>
    <ejb-name>EmployeeBean</ejb-name>
    <home>employee.EmployeeHome</home>
    <remote>employee.Employee</remote>
    <local-home>employee.EmployeeLocalHome</local-home>
    <local>employee.EmployeeLocal</local>
    <ejb-class>employee.EmployeeBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    Where does the EmployeeLocalBean name come from for the lookup?!
    Also, do I NEED to deploy BOTH remote and local interfaces to get my local interfaces to work? Another post on this forum had a problem where they couldn't view the configurations of the EJB because there were not remote interfaces available, but then later they said it was just a problem with the web-based Enterprise Manager.
    Please, can someone let me know if these questions are not interesting enough to the forum? Has nobody here ever implemented Local Interfaces on 9.0.3? Do I need to be posting these questions to a different forum? Please advise and I will take care to get my answers elsewhere if necessary.
    It's just that every resource I've looked at for Local Interfaces (which 9.0.3 CAN implement...right?!) has conflicting information and seems to have buggy implementations. Please....help!
    Thanks in advance!

    Strangely enough, I'm not aware of troubles with enviroment variables and JNDI lookup. There are some misunderstandings - compared to WLS, JNDI tree is different.
    Here is an example of Session EJB settings:
    <session>
    <description>Session Bean ( Stateless )</description>
    <display-name>XSLTransformerEJB</display-name>
    <ejb-name>XSLTransformerEJB</ejb-name>
    <local-home>com.ness.europe.integration.transformer.XSLTransformerEJBLocalHome</local-home>
    <local>com.ness.europe.integration.transformer.XSLTransformerEJBLocal</local>
    <ejb-class>com.ness.europe.integration.transformer.impl.XSLTransformerEJBBean</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Bean</transaction-type>
    <env-entry>
    <description>path to root transformatin file</description>
    <env-entry-name>config/RootTransformFile</env-entry-name>
    <env-entry-type>java.lang.String</env-entry-type>
    <env-entry-value>/oracle/product/IAS903/j2ee/MwCezPassport/xslt/passport.xslt</env-entry-value>
    </env-entry>
    </session>
    Next, there is an MDB with reference to it:
    <message-driven>
    <description>Message Driven Bean</description>
    <display-name>PassportMDB</display-name>
    <ejb-name>PassportMDB</ejb-name>
    <ejb-class>com.ness.europe.integration.inbound.mdb.InboundMDBBean</ejb-class>
    <transaction-type>Bean</transaction-type>
    <acknowledge-mode>Auto-acknowledge</acknowledge-mode>
    <message-driven-destination>
    <destination-type>javax.jms.Queue</destination-type>
    <subscription-durability>Durable</subscription-durability>
    </message-driven-destination>
    <ejb-local-ref>
    <ejb-ref-name>ejb/XSLTransformerEJB</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <local-home>com.ness.europe.integration.transformer.XSLTransformerEJBLocalHome</local-home>
    <local>com.ness.europe.integration.transformer.XSLTransformerEJBLocal</local>
    <ejb-link>XSLTransformerEJB</ejb-link>
    </ejb-local-ref>
    There is basically this piece of code to do lookup environment variable:
    String toRet = (String)this.initCtx.lookup("java:comp/env/config/" + paramName);
    (of course, the config prefix is our syntax)
    As for EJB lookup, this is used:
    final InitialContext context = new InitialContext();
    return (XSLTransformerEJBLocalHome)context.lookup("java:comp/env/ejb/XSLTransformerEJB");
    I didn't created those beans but I asked mate from my team and answer as to troubles was "no".
    Is the problem lies in "not hard coded" names of beans in lookup? We are not trying to get "env/ejb" but just straighforwardly EJB using its name.
    Myrra

  • A question about share interface in java card

    I meet a big problem in java card recently.
    I try to develop a loyalty and a purse in the JCOP 20 . I use the share interface to share data between two applets.At first I write two small applets to test the share interface.Then I manully dowon the two applets into the card but it doesn't work. The error always happen to the "getAppletShareableInterfaceObject" method.
    Following is part of the code.
    buffer[0]=(byte)0x06; buffer[1]=(byte)0x05; buffer[2]=(byte)0x04; buffer[3]=(byte)0x03; buffer[4]=(byte)0x02; buffer[5]=(byte)0x01; buffer[6]=(byte)0x01;
    //server applet ID
    AID loyaltyAID2 = JCSystem.lookupAID(buffer, (short) 0,(byte)7);
    if(loyaltyAID2==null) ISOException.throwIt((short)0x0902);
    loyaltySIO = (JavaLoyaltyInterface) JCSystem.getAppletShareableInterfaceObject(loyaltyAID2,(byte)0);
    //...........................................error happen in this line
    I try to find the error I find the error, so I trace to the server applet,I add a "ISOException.throwIt " method in the getShareableInterfaceObject in the server applet.
    I find if I add it,the "getAppletShareableInterfaceObject" will return but get the null object.
    It's correct.But when I remark the "ISOException.throwIt" and just return "this" ,the card will get "6F00".
    Following is my code.
    public Shareable getShareableInterfaceObject(AID clientAID,byte parameter)
    //ISOException.throwIt((short)0x9999);
    return this; } error happen in this line
    TKS...

    Yes I did do it,I modify the sample code of the SUN micro's loality and purse .Following is my source code.
    Client code(purseeasy).......
    //=========================
    package purseeasy;
    import com.sun.javacard.samples.JavaLoyalty.JavaLoyaltyInterface;
    import javacard.framework.*;
    public class purseeasy extends javacard.framework.Applet
    private byte[] echoBytes;
    private static final short LENGTH_ECHO_BYTES = 256;
         public purseeasy()
         echoBytes = new byte[LENGTH_ECHO_BYTES];
    register();
    public static void install(byte[] bArray, short bOffset, byte bLength)
    new purseeasy();
    public void process(APDU apdu)
    byte buffer[] = apdu.getBuffer();
    short bytesRead = apdu.setIncomingAndReceive();
    short echoOffset = (short)0;
    switch(buffer[2])
    case 0x31:
    AID loyaltyAID1 =JCSystem.getAID();
    short i=loyaltyAID1.getBytes(buffer,(short)0);
    if(loyaltyAID1==null)
              ISOException.throwIt((short)0x0901);
    buffer[0]=(byte)0xd1;buffer[1]=(byte)0x58;
         buffer[2]=(byte)0x00;buffer[3]=(byte)0x00;
         buffer[4]=(byte)0x01;buffer[5]=(byte)0x00;
         buffer[6]=(byte)0x00;buffer[7]=(byte)0x00;
         buffer[8]=(byte)0x00;buffer[9]=(byte)0x00;
         buffer[10]=(byte)0x00;buffer[11]=(byte)0x00;
         buffer[12]=(byte)0x00;buffer[13]=(byte)0x00;
         buffer[14]=(byte)0x31;buffer[15]=(byte)0x00;
         AID loyaltyAID2 = JCSystem.lookupAID(buffer,
    (short)0,(byte)16);
    if(loyaltyAID2==null)
         ISOException.throwIt((short)0x0902);
         JavaLoyaltyInterface loyaltySIO =
    (JavaLoyaltyInterface)
         JCSystem.getAppletShareableInterfaceObject(loyaltyAID2,(byte)1);
    if(loyaltySIO ==null)
         ISOException.throwIt((short)0x0903);
    loyaltySIO.grantPoints (buffer);
    break;
    apdu.setOutgoingAndSend((short)0, (short)18);
    //=====================================
    //Server program....share interface
    package com.sun.javacard.samples.JavaLoyalty;
    import javacard.framework.Shareable;
    public interface JavaLoyaltyInterface extends Shareable
    public abstract void grantPoints (byte[] buffer);
    //=============================================
    //Server program....loyalty
    package com.sun.javacard.samples.JavaLoyalty;
    import javacard.framework.*;
    public class JavaLoyalty extends javacard.framework.Applet     implements JavaLoyaltyInterface
    public static void install(byte[] bArray, short bOffset,
    byte bLength)
    {new JavaLoyalty(bArray, bOffset, bLength);
    public JavaLoyalty(byte[] bArray, short bOffset, byte
    bLength)
    register();
    public Shareable getShareableInterfaceObject(AID
    clientAID,byte parameter)
    return (this);
    public void process(APDU apdu)
    byte buffer[] = apdu.getBuffer();
    short bytesRead = apdu.setIncomingAndReceive();
    apdu.setOutgoingAndSend((short)0, (short)18);
    public void grantPoints (byte[] buffer)
         buffer[0]=0x08;
         buffer[1]=0x08;
         buffer[2]=0x08;
         buffer[3]=0x08;
         buffer[4]=0x08;
         buffer[5]=0x08;
         buffer[6]=0x08;
         buffer[7]=0x08;
    Could you tell me what wrong with my code???
    Thanks....

  • Question about message interface

    I developed a jdbc to file scenario, it works, but I'm confused.
    I designed a message interface for jdbc outbound,
    CustomerRow
    |--row
         |--CUST_NO
         |--......
    I set Document Name = 'resultset' in jdbc sender adapter.
    I can see payload in SXMB_MONI.
    <?xml version="1.0" encoding="utf-8" ?>
    - <resultset>
    - <row>
      <CUST_NO>pp3433</CUST_NO>
      <SALES_ORG>org1</SALES_ORG>
      <DISTRIBUTION_CHANNEL>dis1</DISTRIBUTION_CHANNEL>
      <DIVISION>div1</DIVISION>
      <FLAG>N</FLAG>
      <LAST_UPDATE>2008/11/05 15:24:53:843</LAST_UPDATE>
      </row>
    - <row>
      <CUST_NO>ppy3233</CUST_NO>
      <SALES_ORG>org2</SALES_ORG>
      <DISTRIBUTION_CHANNEL>dis2</DISTRIBUTION_CHANNEL>
      <DIVISION>div2</DIVISION>
      <FLAG>N</FLAG>
      <LAST_UPDATE>2008/11/05 15:24:53:843</LAST_UPDATE>
      </row>
      </resultset>
    You noticed that resultset is not 'CustomerRow' in message interface which I defined.
    I don't know how it can work.

    The parameter Document Name should ideallly contain ur Message Type root name. As u have changed it to 'resultset', it is replaced at the sender adapter and then flow continues.
    There are very few occasions when success raises a question
    Regards,
    Prateek

  • Question about photo interface...please help

    hi. i'll explain what i want to do, and hopefully you can help. when exporting a photo album from iphoto to iweb, it creates thumbnails...and then when you double click on one of those thumnails, it brings up a much nicer looking interface with that photo nice and big, and all the others lined up above. Is there anyway i can skip the first set of thumbnails, and only display the second method of display. so when someone clicks on my photo page, they are presented with a nice big photo, and all the others lined up above. thanks...much appreciated, ben

    Add your photos to your website as a flash slideshow using, for example, the FAExporter plugin......
    http://roddymckay.com/VisualMedia/FlashAlbumExporter.html

  • Question: Best method for mounting drives at log-in time?

    I would like to know what others consider the best method for mounting drives at log-in time is? I can see a few methods such as start-up items on the client, start-up items on the server to managed users and possibly a start-up script. One wrinkle in the scenario is that users can log-in directly to the server so the method should allow that to happen gracefully. Thanks in advance for your help.

    Hi Bigsky,
    You are asking some really fundamental questions that require quite a lot of explanation. Luckily Apple has some great documentation on their server software.
    You will be able to find your answers here by diggin in a bit:
    http://www.apple.com/server/documentation/
    Good Luck!
    Dual 2.0Ghz G5   Mac OS X (10.4.3)  

  • Hi,all i think it seems to be silly question about markable interface

    i know that markable interface doesnt consists any methods.But when we implements those interfaces how they behave to service the class.
    ex.
    public class MyClass implements java.io.Serializable
    MyClass is serializable but the java.io.Serializable doesnt consist any methods how it service to MyClass

    you implement the Serializable interface just to let the API/JVM to know that the instances of the class can be serialized.
    These kind of interfaces are called marker interfaces.
    By the way some time ago there was a good discussion on marker interfaces on this forums. Try searching you might find it.

Maybe you are looking for