Overriding = in my AnyType class

I am trying to create an AnyType class. I am wondering if it is possible to override the = operator like you can in C++. The AnyType class will be used in a method (setValue(AnyType type, String path)) to accept any type that is passed to it. Based on what is passed in the setValue method will be doing different things. It seems easier to handle it with a single method that will accept any type as opposed to overloading the setValue method multiple times. I am also working on using the AnyType as a return from some methods. Any suggestions? Is this possible??
Thanks,
Jim Pagnotta

Hi JIM,
As in C++ no operator overloading is possible in Java. So you cannt overload = operator . and as far as i know in c++ also you cant overide = opertor .i think you are talking about overridding == operator.
My suggestion to this, is accept an instance of Object class as one of the parameters of your setValue() method and use instance of operator to find out the class of it and work accordingly.

Similar Messages

  • How to override attributes of one class into another class in OOPS ABAP

    I was trying to override attribute(data memeber) defined in super class into subclass ,
    but I didnt find any solution to that.
    Please tell me ho to do that?
    Ex
    Class ABC definition
          Public section
             data : x type i.
       end class
    Calss XYZ definition inheriting from ABC.
        Publec section.
           data : x type  i.                                            <<----
    here is the problem
    endclass.

    when you define a subclass all the properties of superclass are inherited into class.
    You dont need to define it again.
    data : x type i " delete this line.
    Object of your subclass will be able to recognize x.
    Regards,
    Lalit Mohan Gupta.

  • ToString() overrides in constructor-less classes? [CS3,JS]

    How do I override the toString() method in a class that lacks its own constructor?
    (I'm actually working with the ManagedArticle class from Woodwing's SmartConnection plugin, but the probem appears to be general for any such class, so here we are with Page).
    Example:
    Page.prototype.toString = function() {
         return "[object Page "+this.name+"]";
    p0 = app.activeDocument.pages[0];
    $.writeln("1: "+p0);
    $.writeln("2: "+p0.toString());
    $.writeln("3: "+Page.prototype.toString.call(p0));
    p1 = app.activeDocument.pages.add();
    $.writeln("4: "+p1);
    $.writeln("5: "+p1.toString());
    $.writeln("6: "+Page.prototype.toString.call(p1));
    produces:
    1: [object Page]
    2: [object Page]
    3: [object Page 1]
    4: [object Page]
    5: [object Page]
    6: [object Page 2]
    Is this a fool's errand? I'd really like easier debugging of this class and overriding the toString() would seem to be the way-to-go.
    Thanks!

    You actually can do it to InDesign DOM objects (well some of them -- in certain ways anyhow). Here's a particularly interesting one:
    var itemByLabel = function (label){
        var labelIndex = null;
        var labelArray = this.everyItem().label;
        for(var i=0;i<labelArray.length;i++){
            if(labelArray[i]==label){labelIndex = i;break}
        if(labelIndex===null){return null}
        return this.item(labelIndex);
    app.documents[0].pageItems;//needed to initialize the PageItems object
    PageItems.prototype.itemByLabel = itemByLabel;
    app.documents[0].paragraphStyles;//needed to initialize the ParagraphStyles object
    ParagraphStyles.prototype.itemByLabel = itemByLabel;
    etc...
    I am very wary of prototyping anything but the simplest JS objects though...
    You can do it with a regular function or method in a custom library (like Bob likes to do).
    function CustomToString(object){
         var string = object.toString();
         string+="bla bla bla";
         return string;
    Harbs

  • Overriding or nulling accessibility class metatag (JAWS)

    I am trying to disable the AccessibilityImplementation in parent components and allow children components, for example (disable a datagrid's accessibility implementation and allow the labels and text input (from that same datagrid control item renderers),  to expose their accessiblity name to jaws).
    I was able to do it, and it works perfectly using the monkey patch approach, I copied the source code from mx.controls.Datagrid.as and removed the line 534 [AccessibilityClass(implementation="mx.accessibility.DataGridAccImpl")] and it works as we need. We can also do our own AccessibilityImplementation as we need.
    The question is..  can we from an extended class, set to null the accessibilityclass meta tag value
    the following code throws a compile error, please check
    package mx.controls
    [AccessibilityClass(implementation=null)]
    public class ExDataGrid extends DataGrid
      public function ExDataGrid()
    thanks in advance

    RK-JAVA wrote:
    In one of the threads
    [http://forums.sun.com/thread.jspa?forumID=31&threadID=5328422|http://forums.sun.com/thread.jspa?forumID=31&threadID=5328422]
    I think reply 7 of 7 puts some good points.
    it says,
    The question then becomes of course why cannot variables be overridden?
    Well, technically I suppose they could be but the purpose of overriding is to change the behaviour of subclasses
    and variables don't represent behavior, they represent stateand it seems variables have nothing got to do with overriding, it is just the latest attribute up the stack that is used.Well, I was uj_ once so I wrote that. -:)
    It's just another way to express my reply #2 in this thread.
    There's a division of labour between methods and variables. Non-private methods represent the behavior of a type, whereas variables represent implementation and object state none of which should be exposed in a type. And because the purpose of the overriding mechanism is to modify the behaviour of subtypes, overriding really doesn't make sense for variables.
    There's a greyzone here though and that concerns so called "properties". Are they behavior or are they state? Well, it's bad encapsulation to expose naked variables in a type so if a variable represents a "property" it should be embedded in a getter/setter pair. This means that "properties" should be represented by methods in the type. The question now is whether a subtype should be able to override and modify a "property" defined by the superttype? Well as a programmer you can prevent that by declaring the "property's" getter/setter methods final.
    The conclusion I'm making is that naked variables never belong in a type so making them overridable makes no sense. If a variable represents a "property" it should be exposed via a getter/setter pair. The programmer then can decide whether this "property" should be overridable by declaring the getter/setter pair final or not.

  • BUG: ojc compiler doesnt handle @Override on anonymous inner class methods

    Hi,
    jdev 10.1.3.3.0.4157, XP SP2, jdk 5 u13:
    for the following code sample:
    Object o = new Object()
        @Override
        public String toString2()
            return "some string";
    };With ojc set as a compiler (the default), ojc doesnt catch the error about overriding toString with toString2, changing the compiler to javac achieves the required and correct behavior.

    Thanks Frank, I logged a couple more not so serious issues a while back but didnt get any feedback on them. The subject of the posts didn't have a 'BUG' prefix though. Should I edit them so to give them some attention, or were they silently logged :) ?

  • Override and replacing Tie class, logic never firing

    I'm on Windows2000 Pro, running Oracle 9i and 9ifs (1.1.9).
    I am trying to get an example from the Developer's Guide to work. It is the Chapter 17 (Customizing Content Type Behavior), Replacing a Server-side Tie Class, Complete Example (Example 17-31).
    I have correctly compiled the java class into the custom_classes directory structure (with subfolders for the package), and I have changed the CLASSPATH to reference the class before repos.jar . I also bounced 9iFS. However, iFS just isn't calling that code (I guess it's still looking in repos.jar for some reason...?), based on my own tests and the java command-line program included in the Developer's Guide.
    I have also tried various other things to get the code called and/or to determine whether or not the code is really being called. One thing I tried is to rename and repackage the example code, then update the classobject with the newly named/packaged server bean. Alas, this did not help.
    Any suggestions or thoughts?
    Thanks in Advance,
    David Frankel

    I'm on Windows2000 Pro, running Oracle 9i and 9ifs (1.1.9).
    I am trying to get an example from the Developer's Guide to work. It is the Chapter 17 (Customizing Content Type Behavior), Replacing a Server-side Tie Class, Complete Example (Example 17-31).
    I have correctly compiled the java class into the custom_classes directory structure (with subfolders for the package), and I have changed the CLASSPATH to reference the class before repos.jar . I also bounced 9iFS. However, iFS just isn't calling that code (I guess it's still looking in repos.jar for some reason...?), based on my own tests and the java command-line program included in the Developer's Guide.
    I have also tried various other things to get the code called and/or to determine whether or not the code is really being called. One thing I tried is to rename and repackage the example code, then update the classobject with the newly named/packaged server bean. Alas, this did not help.
    Any suggestions or thoughts?
    Thanks in Advance,
    David Frankel

  • Class override, how to create the child class and then the base class

    I started to write a program for a smart DMM, the problem is every version of the DMM the company change the communication commend.
    My idea is to write a child class for every DMM version and every SubVI of the child will override the base class SubVI.
    My problem is, i want first to create one child class and after i will see every thing is work,  start to create the base class. that way i will see if am thinking the right way.
    My question is
    How can i create a child class and then create the base class and configure the SubVi of the child class to be Override of the base class?
    I tried to search in the property of the class but i didn't see nothing.
    Thanks
    Solved!
    Go to Solution.

    This can be done and I've done it on occasion.
    You simply create the base class with the dynamic dispatch methods you require (connector panes need to be identical to thos of the child class).
    Then set the inheritance of the class to inherit from this base class.  If your method is defined as a dynamic dispatch method in the parent, you'll most likely now have some errors (unless your child method was already DD in which case you might just be OK already).
    To change the inheritance of a class, right-click the properties of the class in your project and select properties.  I believe the ineritance tree is at the lower end of the properties.  Click on the "change inheritance" (or something similar) to choose the class from which you now wish to inherit.
    Say hello to my little friend.
    RFC 2323 FHE-Compliant

  • Where to place application classes to override shared calsses?

    I use web application which requires to override some of shared classes. Where should I place these classes? It is necessary to override these classes in this application only. Placing it in WEB_INF/classes subdirectory inside web application folder has no effect. The only way I have found - to place these classes inside APPS subdirecory. But in this way all deployed applications will use these new classes. Can anyone help me?
    Thanks in advance,
    Vadim Lotarev

    Put these classes in WEB-INF/classes and enable dynamic reloading. To do that-
    open krededit-> SOFTWARE-> iplanet-> Application Server->6.0->CCS0->SYSTEM_JAVA->Versioning and set it to 0. Bydefault it is 1, disabled. And restart the iAS to pickup this change.
    Or, redeploy the application.
    Hope this would help.
    Should you have any question further, get back.
    Thanks,
    Rakesh.

  • Override:A class is prevented from accessing mehods in is immeditae ancesto

    Can we said about override this way:
    A class is prevented from accessing mehods in is immeditae ancestor?
    can some problem:
    1: can private method be overrided?
    2: can static method be overrided?
    3: can method be overrided as static?
    Thanks!

    Here you can see a clear difference between a) overriding a method in a subclass and b) defining two static methods, when placed in constructors.
    public class C{
    public static void main(String[] args){
         B b = new B();
    class A{
      A(){
         mm();  //call a non-static method in the constructor
          void mm(){
              System.out.println("A");
    class B extends A{
      B(){
         mm();
          void mm(){
              System.out.println("B");
    }and this.
    public class C{
    public static void main(String[] args){
         B b = new B();
    class A{
      A(){
         mm();//call a static method of A in the constructor
         static void mm(){
              System.out.println("A");
    class B extends A{
      B(){
         mm();
         static void mm(){
              System.out.println("B");
    }

  • Override SWC classes in FB?

    I have a Flash Pro project with numerous items in the Library linked to Class files.
    I can successfully export a SWC and use the items in Flash Builder.
    However, how would one override the Class in the SWC with a new one n FB?
    Currently, to edit the Class, I have to open up the project in Flash Pro, edit the Class and export the SWC again. Only then will I see the changes.
    When I try to put a new Class in Flash Builder with the same name as the one in the SWC, it will run that new Class but the assets of the Library item are not there.
    Hopefully I am missing something obvious.

    This is a working hack  but   I would still prefer a better way!
    In Flash Builder I create a Class that is near-to but not exactly the same as the original Class from the SWC.
    In this Class I make it extend the original Class in the SWC.
    eg:
    Class in SWC: SomeClass.as
    Class in FB: SomeClassExt.as
    In SomeClassExt I use:
    public class SomeClassExt extends SomeClass{
    I still need to test this out further but so far so good. Obvious or not.
    One thing I should mention, at least with my current example I need to remove a listener or the Class fires twice:
    removeEventListener(Event.ADDED_TO_STAGE,Init);
    So why do I not remove the Class from the Library item in Flash Pro to begin with?
    I built all the items and their Classes in Pro. Moving to FB for this project is recent.
    I can still test the functionality of the Classes in Flash Pro doing it this way and Not have to put them all in the same project folder in FB.
    Again, I would still prefr a better way to just override the SWC's Class and not have to create new Class Names in FB. This requires a lot of changes to an otherwise functional application.

  • How to implement custom Model Class in Oracle ADF?

    I am using Oracle ADF for one of my project and i am using Query component of ADF. For given tables the query component creates view objects and maps the relations. ADF uses its own custom model class for this component and it should understand the DB tables. But for my project i have no access to database. All i can do is pass a string or object/query to the existing (custom) Java class/object, and this model class formulates query and queries the database and returns the value to my Java class. I have to display these results using ADF to the front end. Is There a way to achieve this? Can i replace/override the existing Model class of ADF. If so how?
    Thanks in advance for your help.

    Hi, there:
    Best thing to do is to start with the default login.html page, and then modify it. The login screen is fairly complex and it's easy to just miss a JS function you need to call. To get to default page, you would need to do one deploy (to simulator or whatever), and then look for login.html page in the temporary Xcode or Android project generated from the deployment. It should be under the "deploy" directory in your JDev workspace.
    You can also see all the framework JS files and CSS files that way as well.
    We have had customers implementing custom login screen so we know it can work, but they all had to start with the default login screen and then modify it.
    Thanks,
    Joe Huang

  • Virtual function overriding

    Hi
    I am having a strange problem in my application. I have a virtual method in a base class which I override in the sub class. In my application I instantiate the subclass . This virtual function is then called from a function in the base class . Most of the time this works okay i.e. the overriden function from the subclass gets called but sometimes , for some reason , the base class function gets called , although I verified that the subclass has been instantiated properly.
    Any ideas what the problem could be ? . Is there any way to debug this , or view the virtual funtion table.
    Any help would be highly appreciated.
    Thanks
    Santosh

    1. Probably you have slicing problem, it happens when you are passing your derived class object where you have defined to pass base class object. In this case your derived class object will be sliced and you will have base class object.
    You have two solutions-
    1. First thing is you should define the functionality of this function in the base class, bcs it seems this functionality belongs to base class as you are trying to use it there.
    2. Dynamically cast the object to your derived class and then call the function. See if it helps.

  • Overriding

    Is Overriding is static or dynamic?
    The method call is decided during compile time or run time?
    public Class SuperClass{
    public void methodA(){
    System.out.println("Super class method");
    public Class SubClass{
    public void methodA(){
    System.out.println("Sub class method");
    in the main method, i create the instances as follows
    SuperClass super = new SuperClass();
    SubClass sub = new SubClass();
    if i invoke the method , as super.methodA() then output will be "Super class method" and if sub.methodA() then output will be "Sub class method". This is obvious.
    And if i create a instance of the sub class using the super class reference and invoke the method like
    SuperClass super = new SubClass();
    super.methodA();
    output wll be "Sub Class method".
    Is this call is decide during run time or compile time??????

    There is an "exception", though, when combining overriding and overloading.
    public class Test {
      public static void main(String [] args) throws Exception {
        X x = new Y();
        x.doThing(""); // prints "X"
      static class X {
        void doThing(Object o) { System.out.println("X"); }
      static class Y extends X {
        void doThing(String s) { System.out.println("Y-String"); }
        void doThing(Integer i) { System.out.println("Y-Integer"); }
    }

  • Access Scope Warning When Adjusting Mandatory Override Settings?

    Hi all,
    In my opinion, the access scope warning dialog should not appear when the user modifies mandatory override settings.
    Under "Class Properties" for a .lvclass
    Under "Item Settings"
    When modifying the settings of a dynamic dispatch VI
    If the user modifies one of the two checkboxes pertaining to mandatory override...
    Regardless of whether the access scope actually changes, a warning dialog appears, and selecting "Yes" seems to cause the IDE to mark unsaved changes for other classes in the class hierarchy chain.  The warning dialog should not appear when all the user does is set the state of the two checkboxes, and to me it doesn't make sense that all of the other classes now have to be saved.  (I claim some ignorance on the saving part, though -  it's just my intuition.)
    Does this make sense?
    Thanks,
    Mr. Jim

    This was consciously discussed when the dialog was added. We decided that it should appear. You may choose "no", but the option should be there. By setting the must override setting all the way down the tree, we felt we and our users would be less likely to introduce mistakes when refactoring to add or remove parent classes. There were times when this seemed like a good idea and so worth offering the option to automatically do it.

  • Sorting a vector of objects using attribute of object class as comparator

    i would like to sort a vector of objects using an attribute of object class as comparator. let me explain, i'm not sure to be clear.
    class MyObject{
    String name;
    int value1;
    int value2;
    int value3;
    i've got a Vector made of MyObject objects, and i would sort it, for instance, into ascending numerical order of the value1 attribute. Could someone help me please?
    KINSKI.

    Vector does not implement a sorted collection, so you can't use a Comparator. Why don't you use a TreeSet? Then you couldclass MyObject
      String name;
      int value1;
      int value2;
      int value3;
      // Override equals() in this class to match what our comparator does
      boolean equals (Object cand)
        // Verify comparability; this will also allow subclasses.
        if (cand !instanceof MyObject)
          throw new ClassCastException();
        return value1 = cand.value1;
      // Provide the comparator for this class. Make it static; instance not required
      static Comparator getComparator ()
        // Return this class's comparator
        return new MyClassComparator();
      // Define a comparator for this class
      private static class MyClassComparator implements Comparator
        compare (Object cand1, Object cand2)
          // Verify comparability; this will also allow subclasses.
          if ((cand1 !instanceof MyObject) || (cand2 !instanceof MyObject))
            throw new ClassCastException();
          // Compare. Less-than return -1
          if ((MyObject) cand1.value1 < (MyObject) cand2.value1))
            return -1;
          // Greater-than return 1
          else if ((MyObject) cand1.value1 > (MyObject) cand2.value1))
            return 1;
          // Equal-to return 0.
          else
            return 0;
    }then just pass MyObject.getComparator() (you don't need to create an instance) when you create the TreeSet.

Maybe you are looking for

  • Can't see video anymore...

    Hi, I don't know what happenned but I can't see my video anymore... They all became a white square with a X inside... It does the same thing if I import a new video. I tried uninstalling everything but it didn't work, I have Adobe presenter 9, I trie

  • Since the last update of iTunes genius will not work it updates but nothing else

    since Itunes last update I can not get genius to work, it updates but when i click on start genius nothing happens, i am verily new to this so i am not sure what to do, it did work great before this update. i now have a new ipad mini and would love t

  • How do you delete your skype messages

    This is crazy, before i could delete my messages, now cannot. Seems others are having the smae problem. No one is getting the help they need. 

  • License for Oracle Unix client

    Let say I have an application running on Unix 64bit (SunOS,HPUX or AIX) accessing a DB with proC, php or jdbc OCI. From XE doc I understood that it is possible to have the DB running Oracle XE on Linux 32bit and the application connecting to the DB w

  • Request  for sample Functional Specification for BDC to upload PA40 or PA30

    Hi Experts I need to Write a Functional specification to Guide My ABAP team member to write a BDC for uploading data in PA40. It would be great if somebody could spare me one . Thanks in advance Rajeev Chhabra <u>[email protected]</u>