Method access question

I have a object which has been declared and created via another class. Is it possible to access another object and its methods in the "parent" class?
Looking at the java API i thought maybe getClass().getDeclaringClass().myMethod() might work, but getClass().getDeclaringClass() returns null. I havent been able to find anything on the internet regarding this. I wouldnt think it would be an uncommon thing to want to do?...Any ideas? Cheers in advance...Nick

Thanks for the suggestion. I actually tried this method (passing a reference to the constructor) in a previous project, but i thought maybe there was an easier way (Is this the usual way to tackle this kind of problem?). However, trying to use it in this one leads to more troubles. My instance of class1 is created when a button is clicked, through a buttonListener inner class in my MainWindow class. So what happes is that when i try to use
Class1 = new Class1(this);instead of passing a reference to MainWindow, it passes a reference to buttonListener instead. This may be where i was on the right track because i then tried
Class1 = newClass1(getClass().getEnclosingClass());i think i tried using getDeclaringClass() aswell and both would return null. Am i doing this right?

Similar Messages

  • Configuring Method Accessing

    How do you turn Method Accessing on for all Entities using Java?
    I came across this thread which mentions <uses-method-accessing> in an XML file:
    Re: An interesting TOPLINK-6044
    However, is it possible to do this via an annotation or some configuration in the persistence.xml. I want to use Method Accessing at all times for all entities. Is this possible and is it possible to configure this via annotations or in persistence.xml.

    Thanks for the reply. I tried that and it seems to work. But if I have a transient field in my entity bean and specify method level annotations, TopLink tries to map even the transient field to a table column which is undesirable.
    I also tried annotating the getter methods for the fields I wanted Method Access on and leaving the fields I didn't care about at field-level annotations. But even that resulted in the transient field getting mapped to a database column.
    Any ideas?

  • Method accessing by reflection

    Hi guys,
    I am using ValueHolder Indirection, but my attributes must be private and I don't know what should be the signature of the accessor methods that toplink will try to find by reflection.
    Does TopLink try to guess the method signature based on the attribute name and type?
    Example: private ValueHolderInterface userType;
    -> public void setUserType(ValueHolderInterface) and public ValueHolderInterface getUserType()
    I looked at http://www.oracle.com/technology/products/ias/toplink/doc/1013/main/_html/mapcfg003.htm#CEGDDEEA but I couldn't find out if I would be obliged to specify what would be the accessor methods.

    TopLink uses reflection to access private variable. Since TopLink is not really creating new objects as the application does, but really resorting the state of previously existing objects similar to Java serialization it normally makes sense for it to be using direct variable access, as this typically avoids undesired side effects that get/set method may contain.
    However, using variable versus method access is completely up to you, TopLink supports both. To use method access you must supply the get/set method names to the mapping, TopLink does not guess these, although the Mapping Workbench will fill these in for you if you select method access for the project default. For mappings using ValueHolder indirection you must provide get/set methods that return/set the ValueHolderInterface, not its value. Or you can use direct variable access for these.

  • Access Modifiers Effect on Static Method Hiding Question

    I am studying for my SCJP exam and have come across a question that I do not understand and have not yet found a satisfactory explanation.
    Given:
    package staticExtend;
    public class A{
         private String runNow(){
              return "High";
         static class B extends A{
              public String runNow(){
                   return "Low";
         public static void main(String args[]){
              A[] a=new B[]{new B(),new C()};
              for(A aa:a)
                   System.out.print(aa.runNow()+" ");
    class C extends A.B{
         public String runNow(){
              return "Out";
    }The output is "High High". The explanation in the sample exam from ExamLab was that because the runNow() method in A was private that only an explicit cast to the B class would invoke the runNow() method in B. I have verified that that is the case, but am not clear on how the runNow() method being declared static in B and how the private access modifier in A results in this behaviour.
    Any additional explanation would be greatly appreciated.
    Thanks in advance.
    -- Ryan

    Ryan_Chapin wrote:
    OK, so since runNow() in A is private the compiler determines that regardless of the available methods in any of it's sub classes that since we declared the original array reference as "A" that it will invoke the runNow() in A. It's also due to the fact that the invocation came from within A. You would have gotten a compile time error if you tried to place the code in the main method in another class.
    >
    My mistake about the second part that you mention. You are correct. runNow() in B is NOT static, but the class is static. I guess that was the red herring in this question I don't see how that is related. I actually think that the "red herring" was what I described above. The fact that the code was placed in A, and that private methods can't be overridden.
    and the fact that the class itself is static has nothing to do with the behaviour that is being illustrated. Is that correct?Correct

  • Method access$0() and Interfaces doubts

    Hello All,
    I am working on a class browser, I have created one and it works successfully to a certain extent. But The class which I am having a Demo for a Tree Implementation in GUI, has a method called access$0() which I guess is automatically created on runtime by the super classes or somewhere, please let me know how and where can I get more details about this method.
    Also If my class under inspection is implementing one or more interfaces, how can I access its method names and variables.
    Also One more question, does Java maintain a list of sub-class information for each class somewhere.. just like Small Talk or it doesn't?? Please explain.
    Thanks,
    Sirish

    access$ methods are widely used to access private
    members of enclosing class from its inner class and
    vice-versa. These methods are generated by Java
    compiler, not by JVM runtime.
    See
    http://java.sun.com/docs/books/jvms/second_edition/htm
    l/ClassFile.doc.html#80128 for more details about
    synthetic class members.
    Other questions need more clarification.I will check that link, Regarding the other two questions:
    2. What I meant in my interfaces question is that... Say I have a class X that Extends Y and implements A,B
    Then if I want to display all the methods and fields of these classes and interfaces in a recursive way, till I reach the Object class, by going to superclass every time, then I understand I can get to class Y simple by
    using x.getSuperClass()
    but how can I get the interface methods?? and go upwards in that hierarchy??
    3. Sub class question is like this - Say I have 3 classes all user defined in the same directory Class A,B,C where A is the superclass of B and C. My class browser is displaying the hierarchy details of A, then is there any way to put in the details of B and C in the same hierarchical display or just display a separate list of subclass that this class has. I am not sure whether I have made it clear still.
    (I didnot understnad your reply on changing the class path, can you please explain it in a bit more detail, provided it holds for this question.)
    Regards,
    Sirish

  • File access question

    I've written an application that runs on a server and watches a list of directories specified in an .ini file. A thread is executed every few seconds (also specified in the .ini) that checks to see if any files have been copied into any of the directories it is monitoring. If it finds one or more files, it zips them into a .zip file and copies them to an output directory.
    The problem I'm having is people are copying HUGE .eps files into the directories through our company's network. The thread gets executed before the copy is done and a .zip file of the partial .eps file gets created.
    The question is how can java know if a file is currently being written to? My application needs to wait until the file has been fully copied before it tries to zip it up and send it out. How can I achieve this?

    These are all good responses, but I've now tried most of them and I still get sent back to my original problem:
    We're using Windows NT so I don't know if this is the same case for UNIX or other OS'es but when you copy a large file from one machine to another, NT automatically allocates disk space on the target machine for the size of the file AFTER the copying is done.
    So if you were copying a 64 Meg .eps file from one machine to another, as soon as the copying starts the file system reports the file size as 64 Megs not however much has been copied so far. So I don't think filesize checking will help.
    I tried using canWrite() on a file currently being copied to and it returns true so that didn't work either. I'm sure it has something to do with the way NT copies files. It allocates all of the disk space necessary right from the start so Java thinks it is a whole file and can do whatever it wants with it.
    I also tried the rename-and-replace method but still ran into the same problem. NT reported to Java that a complete file was available even though it was a partial file. So then the renaming and deleting took place way before the file was actually done copying.
    I think what I really need is some way to access whether or not the file is currently being used. Just a simple true or false method that will tell me if another application or the file system itself is currently using a file. Then I'll just wait until it is done and then zip it up.
    I read the JavaDoc for the FilePermission class and it reads like Greek to me and I don't think it will be much help. Any ideas?

  • Method access

    I am creating a jsp web page to display the items to add to a shopping cart
    I am getting the following error message error message when i try
    to run may jsp display page i dont know what I have to do to get this working
    I am running Tomcat 5, Any help would be appreciated.
    The method addProduct(Product) in the type ShoppingCart is not applicable for the arguments (Product)
    Jsp page code snippet
    <jsp:useBean id="sCart" type="ShoppingCart" scope="session"/>
    <%@ page import="be.Product" %>
    <%@ page import="be.ShoppingCart" %>
    <% String featureTitle = request.getParameter("FeatureTitle");
       if(featureTitle!=null)
              String featureID = request.getParameter("FeatureID");
              String date = request.getParameter("Date");          
              String featureDescription = request.getParameter("FeatureDescription");
              String author = request.getParameter("Author");
              double price = Double.parseDouble(request.getParameter("Price"));
              Product newProduct = new Product(featureID, date, featureTitle, featureDescription, author, price);
              sCart.addProduct(newProduct);
    %>shopping cart class code snippet
    Vector products = new Vector();
         public void addProduct(Product i)
              boolean productFound = false;
              Enumeration productEnum = getProducts();
              while(productEnum.hasMoreElements())
                   Product product = (Product)productEnum.nextElement();
                   if(product.getId().equals(i.featureID))
                        productFound = true;
                        product.quantity += 1;
                        break;
              if (!productFound)
                   products.addElement(i);
         }product class code snippet
    public class Product
         String featureID, featureTitle, featureDescription, author, date;
         int quantity = 1;
         double price, total;
         public Product(){}
         public Product(String newid, String newdate, String newtitle, String newdescription, String newauthor, double newprice)
              this.featureID = newid;
              this.date = newdate;
              this.featureTitle = newtitle;
              this.featureDescription = newdescription;
              this.author = newauthor;
              this.price = newprice;
         }

    access$ methods are widely used to access private
    members of enclosing class from its inner class and
    vice-versa. These methods are generated by Java
    compiler, not by JVM runtime.
    See
    http://java.sun.com/docs/books/jvms/second_edition/htm
    l/ClassFile.doc.html#80128 for more details about
    synthetic class members.
    Other questions need more clarification.I will check that link, Regarding the other two questions:
    2. What I meant in my interfaces question is that... Say I have a class X that Extends Y and implements A,B
    Then if I want to display all the methods and fields of these classes and interfaces in a recursive way, till I reach the Object class, by going to superclass every time, then I understand I can get to class Y simple by
    using x.getSuperClass()
    but how can I get the interface methods?? and go upwards in that hierarchy??
    3. Sub class question is like this - Say I have 3 classes all user defined in the same directory Class A,B,C where A is the superclass of B and C. My class browser is displaying the hierarchy details of A, then is there any way to put in the details of B and C in the same hierarchical display or just display a separate list of subclass that this class has. I am not sure whether I have made it clear still.
    (I didnot understnad your reply on changing the class path, can you please explain it in a bit more detail, provided it holds for this question.)
    Regards,
    Sirish

  • WRT54GS V6 access question.

    Just set up the network.
    WRT54GS with a Wireless-G USB adapter
    2nd pc is linked and working great!
    Question is: How do I access the 2nd pc from the 1st pc?
    I click on my computer > network places > view computer work groups.
    When I click on the 2nd pc it ask for a password. Where would I find the password to access the 2nd pc? I checked the Easylink advisor but can't find anything.
    Anyone know? I would like to transfer files from one pc to the other.
    Message Edited by asgrafxx on 02-10-200712:09 PM

    Hi… This is the login password for you PC and nothing do with your router or adapter. If you have setup any account on this computer such as administrator or any other, you can provide login credentials for the same and access the shared resources on that PC.

  • Expanding network with TC and access question

    Hi All
    I need to look at a new external hard disk since my current 160gb is just getting too full, so I figured it might be time to get a Time Capsule, probably the 1tb.
    I've got two questions before I do..
    1. Currently I have Sky Broadband. I've read a lot of people saying that it is not possible to make TC part of the existing network through wifi so have to connect. If thats the case I'm probably better off with standard network drive. Has anyone managed to do this yet? Im wondering if the reviews I've read are just that people couldn't work it out?
    2. I assume this is the case, but can I access the HD as a standard network drive for general storage? Is it possible to define how much space Time Machine can use say 500gb, and leave 500gb for general usage?
    Many thanks for any answers

    The issue I have is that Sky Broadband forces you to use their router for broadband access. They hide the user name and password on a chip so it is not possible to configure.
    Besides my phone is downstairs and my printer is upstairs in the little office. My plan was to have TC upstairs, with printer connected. Have both the TC and Sky Broadband router all part of the same network.
    Then I'd use a cable to do the first backup and use wireless for incremental backups.
    It does look as though I can't use this configuration. But its a bit strange, I thought it was part of standard wireless networks that you could use access points to extend them. I assume then that apple are not using all of the standards?
    If that is the case, I'd have to plug it into my router as a wired option, in which case any external HD with a network interface will do half the job I need.
    I'm just trying to find out if anyone has managed to get it extended from sky (or other router). Note I can change my sky router settings so in theory could change the sky one to use the apple settings, does that make a difference? Anyone had success that way?

  • DVD @ access questions?

    I am putting together a short promo DVD for a client and I have a catalogue of their products as an image on the DVD that you can access via the main menu. What I want to do is have it so the products are 'clickable' and will take the user [when online] to the clients web site. I did a search but I cant find out how to link this page to the DVD access settings in the inspector. Any help? Also, can you link a button to open up and email application so the user can email direct from watching this DVD? Questions questions questions....thanks in advance. Oh, Im on DVDSP2.

    DVD@ccess is actually quite limited and not entirely compatible with the range of DVD playback software/hardware available on a PC... you might be better off using eDVD from Sonic (which is PC software, making use of the Interactual Player, rather than @ccess).
    However, @ccess links are embedded in to a menu - so any button you have got needs to go to a menu that simply has the @ccess URL embedded and the menu needs to time out to return to where the button was. For launching a web site simply use the standard URL for the site, include the http:// info in that.
    Now, sending an email is not going to work all of the time, but you can try it out and see if it has the functionality you want. The URL to place into the menu for DVD@ccess is the HTML 'mailto' code. simply write:
    mailto:[email protected], replacing name, domain and .com with the revelant info. If you have got the @ccess links enabled on your Mac, try simulating the menu with this in it... you should see Mail launch (it takes a moment for it to appear, but should work). Whether or not this will work on a PC with Outlook I don't know...

  • Method design question...and passing object as parameter to webserice

    I am new to webservice...one design question
    i am writing a webservice to check whether a user is valid user or not. The users are categorized as Member, Admin and Professional. For each user type I have to hit different data source to verify.
    I can get this user type as parameter. What is the best approach to define the method?
    Having one single method �isValidUser � and all the client web service can always call this method and provide user type or should I define method for each type like isValidMember, isValidAdmin ?
    One more thing...in future the requirement may change for professional to have more required field in that case the parameter need to have more attribute. But on client side not much change if I have a single isValidUser method...all they have to do is pass additional values
    isValidUser(String username, String usertype, String[] userAttributes){
    if usertype == member
    call member code
    else if usertype = professional
    call professional code
    else if usertype = admin
    call admin code
    else
    throw error
    or
    isValidMember(String username, String[] userAttributes){
    call member code
    One last question, can the parameter be passed as object in web service like USER object.

    First of all, here is my code
    CREATE OR REPLACE
    TYPE USERCONTEXT AS OBJECT
    user_login varchar2,
    user_id integer,
    CONSTRUCTOR FUNCTION USERCONTEXT (
    P_LOGIN IN INTEGER
    P_ID_ID IN INTEGER
    ) RETURN SELF AS RESULT
    Either your type wont be compiled or this is not the real code..

  • Call Manager 4.13 Multi-Level Access Question

    I need to configure MLA and have read the CCO documentation. My question is - I'm not familiar with the ccmadministrator account and want to make sure that when I'm prompted to reset the password to this account immediately after enabling MLA - that I'm not going to muck up any underlying service that uses this account for something other than ccmadmin web access.

    Hi Pklos,
    I enabled the MLA and configured two functional groups and everything is working like a charm!
    Thanks!
    Amir

  • Method access problem

    I am creating a jsp web page to display the items to add to a shopping cart
    I am getting the following error message error message when i try
    to run may jsp display page i dont know what I have to do to get this working
    I am running Tomcat 5, Any help would be appreciated.
    The method addProduct(Product) in the type ShoppingCart is not applicable for the arguments (Product)
    Jsp page code snippet
    <jsp:useBean id="sCart" type="ShoppingCart" scope="session"/>
    <%@ page import="be.Product" %>
    <%@ page import="be.ShoppingCart" %>
    <% String featureTitle = request.getParameter("FeatureTitle");
       if(featureTitle!=null)
              String featureID = request.getParameter("FeatureID");
              String date = request.getParameter("Date");          
              String featureDescription = request.getParameter("FeatureDescription");
              String author = request.getParameter("Author");
              double price = Double.parseDouble(request.getParameter("Price"));
              Product newProduct = new Product(featureID, date, featureTitle, featureDescription, author, price);
              sCart.addProduct(newProduct);
    %>shopping cart class code snippet
    Vector products = new Vector();
         public void addProduct(Product i)
              boolean productFound = false;
              Enumeration productEnum = getProducts();
              while(productEnum.hasMoreElements())
                   Product product = (Product)productEnum.nextElement();
                   if(product.getId().equals(i.featureID))
                        productFound = true;
                        product.quantity += 1;
                        break;
              if (!productFound)
                   products.addElement(i);
         }product class code snippet
    public class Product
         String featureID, featureTitle, featureDescription, author, date;
         int quantity = 1;
         double price, total;
         public Product(){}
         public Product(String newid, String newdate, String newtitle, String newdescription, String newauthor, double newprice)
              this.featureID = newid;
              this.date = newdate;
              this.featureTitle = newtitle;
              this.featureDescription = newdescription;
              this.author = newauthor;
              this.price = newprice;
         }

    Hi,
    Well there are several notes on the service marketplace addressing problems with access method "G" like note 821519, 841175, 868913 and 901244.
    However regardless of the problem it is always recommended to use the newest sap kernel (Backend), be on the highest support package level (Backend), and off curse on newest patch level of the SAP GUI (Frontend).
    So try check the notes, and the notes related to them, check the kernel level of your backend, and the patchlevel of you GUI.
    Regards
    Rolf

  • File Access questions

    2 questions
    1.) I can't edit files from the portal, I can only view them, is this normal?
    2.) Can I view files on my smart phone? I've seen this work for SBS so I'm wondering if there is a way to do it here?
    Thanks!

    "Users" allows you to set up custom access permissions for users or groups you specify.
    For example, for some file:
    User: me - Read & Write
    User: mywife - Read only
    Others: No Access
    You can write to the file. Your wife can open it but not edit it. Your kids cannot access it.

  • Newbie Database Access Question

    I am familiar with SQL and database access from web programming, but have never done these things from within a Java application. My google searching has been fruitless thus far, so I'd appreciate any references to beginner's guides about how to query databases from a Java app and manipulate the resulting recordsets. Anything on Access db's would be ideal.
    TIA,
    John

    Thanks for the reference. I have a question about this section of the tutorial:
    http://java.sun.com/docs/books/tutorial/jdbc/basics/connecting.html
    Under the section "Loading the Drivers" is the following paragraph:
    Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ , you would load the driver with the following line of code:
    Class.forName("jdbc.DriverXYZ");My question is: How do I decide which driver I need for connecting to an Access db on a Win XP machine? Is there perhaps another reference which answers these kinds of questions?
    Thanks again,
    John

Maybe you are looking for

  • About to buy a personal domain, any tips

    I'm new to this and about to purchase a personal domain. Do I just buy the name or must I get a hosting package with it (some offer emails, 2GB storage etc). I assume the my .mac is the host but just want to make sure. Any help appreciated. Tony

  • Financial Reporting - PDF has not been configured for this web server.

    When I try a Print Preview of my report, I received this error "PDF has not been configured for this web server". As far as I know, this error is confusing because when I look on my log files I found this: --- FRLogging.log --- [APP: FINANCIALREPORTI

  • DAC email notification not working.even if we get test mail.

    DAC clients are installed in Windows machine (Remote) and DAC servers are installed on UNIX platform. I have set up the smtp configuration in DAC client.i am also getting test mail. But after my schedule load completion i am not getting email notific

  • Listener: ORA-00604 ORA-01219

    We have a database on 10.2.0.5.0. Sometimes we are able to login, sometimes we get the error below (this is from the client, on the server it works): SQL> conn dba@tst ERROR: ORA-00604: error occurred at recursive SQL level 1 ORA-01219: database not

  • Changing timezone in ISE 1.1.2

    Hi, I need to change the timezone of two ISE 1.1.2 servers. One primary and one secondary. Both are set to "EST" timezone and i would like to change them to AMERICA/Montreal because they are now one hour late since day light saving change. According