Design Question - Class Must Implement Interface

I'm not sure how to describe this in summary, really. I'd say that I sort of want multiple inheritance, but I don't want to be shot. :-P So let me describe the situation:
I have an interface, DataEditingComponent<T>. The idea is that anything implementing the interface is capable of allowing the user to edit an object of type T. For example, a DataEditingComponent<Integer> would allow the user to input an integer. A DataEditingComponent<Map<SomeObj,Integer>> might represent an object capable of editing a table describing the number of instances of SomeObj. You get the idea. DataEditingComponent<T> describes three methods: getEditingData():T, setEditingData(T):void, and getDefaultEditingData():T. I'm assuming you can guess what those do.
Well, the practical application of this interface is in the use of a Swing application. It provides a very clean and standardized way of adjusting the contents of components which edit data. Obviously, a JTextField would work about as well as a DataEditingComponent<String>, but for more complicated components (DataEditingComponent<GameWorldMap>, for instance), the standardized interface is very helpful.
Since in practice everything that ever implements DataEditingComponent<T> extends JComponent, it would be nice to declare this as a requirement somehow. However, given that JComponent is extended into a number of various subclasses, I can't just go making DataEditingComponent<T> an abstract subclass.
So far, the only conclusion I've reached is that I can take each and every JComponent subclass and extend it into an abstract subclass which implements DataEditingComponent<T>... but that's very ugly and quickly leads to other problems. And presently, I'm left casting things from one to the other, with which I am also not happy.
So... any way out of this? Have I done something wrong design-wise? Or am I just stuck in a language limitation?
Thanks for reading!

I'm not sure how to describe this in summary, really.
I'd say that I sort of want multiple inheritance,
but I don't want to be shot. :-P So let me
describe the situation:
I have an interface, DataEditingComponent<T>. The
idea is that anything implementing the interface is
capable of allowing the user to edit an object of
type T. For example, a DataEditingComponent<Integer>
would allow the user to input an integer. A
DataEditingComponent<Map<SomeObj,Integer>> might
represent an object capable of editing a table
describing the number of instances of SomeObj. You
get the idea. DataEditingComponent<T> describes
three methods: getEditingData():T,
setEditingData(T):void, and
getDefaultEditingData():T. I'm assuming you can
guess what those do.
Well, the practical application of this interface is
in the use of a Swing application. It provides a
very clean and standardized way of adjusting the
contents of components which edit data. Obviously, a
JTextField would work about as well as a
DataEditingComponent<String>, but for more
complicated components
(DataEditingComponent<GameWorldMap>, for instance),
the standardized interface is very helpful.
Since in practice everything that ever implements
DataEditingComponent<T> extends JComponent, it would
be nice to declare this as a requirement somehow.
However, given that JComponent is extended into a
number of various subclasses, I can't just go making
DataEditingComponent<T> an abstract subclass.
So far, the only conclusion I've reached is that I
can take each and every JComponent subclass and
extend it into an abstract subclass which implements
DataEditingComponent<T>... but that's very ugly and
quickly leads to other problems. And presently, I'm
left casting things from one to the other, with which
I am also not happy.
So... any way out of this? Have I done something
wrong design-wise? Or am I just stuck in a language
limitation?Hmm. The component is part of the view. The data is part of the model. Putting them together seems to go against the whole Model-View-Controller concept. You may want to have a look at how Swing separates the editing from the rendering from the model for complicated widgets such as JTable. The editors hava methods such as getEditorComponent() which returns the Component used to edit the data. Everywhere you are currently adding DataEditingComponent instances to your GUI, you can instead call a getDataEditingComponent() method, which can require that the returned object is a JComponent.

Similar Messages

  • "Bean Class Must Implement X" message, but bean class does implement X

    When trying to deploy an .ear file on WebLogic 9.0 that contains an MDB EJB, I get a message like the following:
    In EJB ITS-MDB(Application: ITSNO,
    EJBComponent: ITSMDB.jar), the bean class must implement
    its.common.TelnetMessageListener. '
    The ITS-MDB EJB class (its.mdb.TelnetMessageListenerImpl) referenced in ejb-jar.xml DOES implement its.common.TelnetMessageListener, and both .class files exist in the same .jar file.
    (The TelnetMessageListener interface extends javax.ejb.MessageDrivenBean.)
    This .ear deploys without a problem on Oracle's OC4J and IBM's Websphere, so it appears that there is some Weblogic peculiarity (a bug, a different spec interpretation, etc.) causing the problem.
    This problem is happening on Weblogic 9.0 using Java 1.5.0_03 on Windows XP.
    Any ideas why this might be happening?

    Thanks for the suggestion, Rob.
    I checked to ensure that no out-dated TelnetMessageListenerImpl and TelnetMessageListener were being used. It looks like I am not using older versions.
    I first checked the classpath specified by the log, and did not see anywhere in there that would contain either of these classes.
    To be sure, I then decided to remove each class from the jar file and attempt to deploy it. If it succeeded, that would mean there was some other version of that file on the classpath.
    I first removed TelnetMessageListenerImpl from ITSMDB.jar, and then tried deploying it. As expected, I received the following message:
    Unable to deploy EJB: C:\bea\user_projects\domains\domain_good\.\servers\AdminServer\tmp\_WL_user\ITSNOMinus\fvdi9g\ITSMDB.jar from ITSMDB.jar:
    Unable to load a class specified in your ejb-jar.xml: its.mdb.TelnetMessageListenerImpl
         at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:371)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:90)
    I then replaced TelnetMessageListenerImpl and attempted to remove TelnetMessageLister. I got a slightly different (but essentially the same) error:
    java.lang.NoClassDefFoundError: oracle/wireless/its/common/TelnetMessageListener
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
         at weblogic.utils.classloaders.GenericClassLoader.defineClass(GenericClassLoader.java:302)
         at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:255)
         at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:223)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:158)
         at weblogic.ejb20.deployer.EJBModule.setupEJBToImplClassDependencies(EJBModule.java:1396)
    Here is the exception stack I get will the original ITSNO deployment:
    ####<Sep 20, 2005 11:20:57 AM PDT> <Info> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240457892> <BEA-149059> <Module ITSMDB.jar of application ITSNO is transitioning from STATE_NEW to STATE_PREPARED on server AdminServer.>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Info> <EJB> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458002> <BEA-010008> <EJB Deploying file: ITSMDB.jar>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Info> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458080> <BEA-149061> <Module ITSMDB.jar of application ITSNO failed to transition from STATE_NEW to STATE_PREPARED on server AdminServer.>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Info> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458080> <BEA-149059> <Module ITSRA.rar of application ITSNO is transitioning from STATE_PREPARED to STATE_NEW on server AdminServer.>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Info> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458111> <BEA-149060> <Module ITSRA.rar of application ITSNO successfully transitioned from STATE_PREPARED to STATE_NEW on server AdminServer.>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Error> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458158> <BEA-149265> <Failure occured in the execution of deployment request with ID '1127240456080' for task '0'. Error is: 'weblogic.application.ModuleException: Exception preparing module: EJBModule(ITSMDB.jar)
    Unable to deploy EJB: C:\bea\user_projects\domains\domain_good\.\servers\AdminServer\tmp\_WL_user\ITSNO\x5gd0k\ITSMDB.jar from ITSMDB.jar:
    In EJB ITS-MDB(Application: ITSNO, EJBComponent: ITSMDB.jar), the bean class must implement its.common.TelnetMessageListener.
    weblogic.application.ModuleException: Exception preparing module: EJBModule(ITSMDB.jar)
    Unable to deploy EJB: C:\bea\user_projects\domains\domain_good\.\servers\AdminServer\tmp\_WL_user\ITSNO\x5gd0k\ITSMDB.jar from ITSMDB.jar:
    In EJB ITS-MDB(Application: ITSNO, EJBComponent: ITSMDB.jar), the bean class must implement its.common.TelnetMessageListener.
         at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:371)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:90)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:318)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:53)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:43)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:236)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:191)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:84)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:197)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:724)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1137)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:224)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:109)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:166)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:54)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    In EJB ITS-MDB(Application: ITSNO, EJBComponent: ITSMDB.jar), the bean class must implement its.common.TelnetMessageListener.
         at weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.initializeOnMessageMethodInfo(MessageDrivenBeanInfoImpl.java:593)
         at weblogic.ejb20.deployer.MessageDrivenBeanInfoImpl.<init>(MessageDrivenBeanInfoImpl.java:346)
         at weblogic.ejb20.deployer.BeanInfoImpl.createBeanInfoImpl(BeanInfoImpl.java:551)
         at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.initializeBeanInfos(MBeanDeploymentInfoImpl.java:597)
         at weblogic.ejb20.deployer.MBeanDeploymentInfoImpl.<init>(MBeanDeploymentInfoImpl.java:221)
         at weblogic.ejb20.deployer.EJBDeployer.prepare(EJBDeployer.java:1165)
         at weblogic.ejb20.deployer.EJBModule.prepare(EJBModule.java:344)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:90)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:318)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:53)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:43)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:615)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:26)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:236)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:147)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.createAndPrepareContainer(ActivateOperation.java:191)
         at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doPrepare(ActivateOperation.java:84)
         at weblogic.deploy.internal.targetserver.operations.AbstractOperation.prepare(AbstractOperation.java:197)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentPrepare(DeploymentManager.java:724)
         at weblogic.deploy.internal.targetserver.DeploymentManager.prepareDeploymentList(DeploymentManager.java:1137)
         at weblogic.deploy.internal.targetserver.DeploymentManager.handlePrepare(DeploymentManager.java:224)
         at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.prepare(DeploymentServiceDispatcher.java:109)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doPrepareCallback(DeploymentReceiverCallbackDeliverer.java:166)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:12)
         at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:54)
         at weblogic.work.ServerWorkManagerImpl$WorkAdapterImpl.run(ServerWorkManagerImpl.java:518)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:207)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:179)
    >
    ####<Sep 20, 2005 11:20:58 AM PDT> <Warning> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458252> <BEA-149004> <Failures were detected while initiating distribute task for application 'ITSNO'.>
    ####<Sep 20, 2005 11:20:58 AM PDT> <Warning> <Deployer> <jrozier-pc> <AdminServer> <[STANDBY] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1127240458252> <BEA-149078> <Stack trace for message 149004
    There are a few other updates since my first post as well:
    (1) I get the same message when I try to deploy just ITSMDB.jar as an application as I do when I try to deploy my ITSNO.ear (which contains both an RA and the MDB).
    (2) This same application now also works on JBoss. (I had to add a jboss.xml to tell the MDB about the RA.)
    (3) I fixed the ejb-jar.xml container-transaction element to refer to ITS-MDB (with a dash) instead of ITS_MDB (with an underscore). (This fix goes to show that some containers are more forgiving than others--OC4J and Websphere did not complain about it, but JBoss gave an error message and would not deploy until this was fixed.)

  • Derived class also implements interface?

    Hi guys,
    If a base class A implements an interface (e.g. Comparable), does a derived class of A also implement this interface (or is of this type e.g Comparable, if this is a more correct way to say it)??
    If so, would it be wrong to write "public class B extends A implements Comparable", because class A already implements it?
    I am aware of that class B will inherit methods from class B and that way have "compareTo()" method. But can objects of class B be plugged in for method parameter of Comparable ( someMethod(Comparable obj) )?

    LencoTB wrote:
    Hi guys,
    If a base class A implements an interface (e.g. Comparable), does a derived class of A also implement this interface (or is of this type e.g Comparable, if this is a more correct way to say it)??Yes. The way you said it is fine, although another way to say it is "Comparable is a base interface(or class) of derived class B"
    >
    >
    If so, would it be wrong to write "public class B extends A implements Comparable", because class A already implements it?Not necessarily, but it is unnecessary. The only reason you would do this is to specifically document that the class is changing the implementation of compareTo.
    >
    I am aware of that class B will inherit methods from class B and that way have "compareTo()" method. But can objects of class B be plugged in for method parameter of Comparable ( someMethod(Comparable obj) )?use "implements Comparable<B>"

  • A non abstract child class must implement all pure virtual function of  parent abstract class in c++

    Hi,
    In Indesign SDK there is a class  IActionComponent having two pure virtual functions:
    virtual void
    UpdateActionStates(IActiveContext* ac, IActionStateList *listToUpdateGSysPoint mousePoint = kInvalidMousePoint, IPMUnknown* widget = nil) = 0;
    virtual void
    DoAction(IActiveContext* ac, ActionID actionID, GSysPoint mousePoint = kInvalidMousePoint, IPMUnknown* widget = nil)= 0;
    But, the child class
    class WIDGET_DECL CActionComponent : public IActionComponent
    implements only UpdateActionStates function and not DoAction function.
    There is no compilation error and the code is running fine..HOW
    Can some one please explain me?

    Oops!!! there is a small correction in my C++ program. The JunkMethod is being called from the constructor...like the following code.
    #include <iostream.h>
    #include <stdlib.h>
    class Base
        public:
            Base()
                cout<<"In Base Class constructor..."<<endl;
                JunkMethod();
            void JunkMethod()
                TestAbsFunc();
            virtual void TestAbsFunc()= 0;
    class TestAbstract:public Base
        public:
            TestAbstract()
                cout<<"In Extend Class constructor..."<<endl;
            void TestAbsFunc()
                cout<<"In TestAbsFunc...."<<endl;
    int main()
          TestAbstract test;
          return 0;
    }You can see the change in the constructor of the Base class. JunkMethod is being called, just to bluff the compiler to call the virtual method (so that it won't crib saying that abstract method cannot be called from the constructor). When Java is supporting this functionality without giving any errors, C++ gives errors when you call an abstract method from the constructor or fails to execute when I do some work around like this. Isn't it a drawback of abstract funcationality supported by C++ (I'm not sure if it's a drawback or not)
    Regards,
    Kalyan.

  • Stipulate that a parameterised type must implement an interface

    Hi,
    1000 excuses if this has been asked before:
    I want to say "abstract class AbstractHolder<Y>" and also say "oh by the way, Y must implement interface Snodgrass"
    In other words I want to limit the kind of subelements which are held by the AbstractHolder so that an attempt to establish an AbstractHolder subclass which holds subelements which do not implement Snodgrass results in a compiler error.
    Of course you can put in an "instanceof" check in the constructor... but I think generics should enable you to say "abstract class AbstractHolder<Y implements Snodgrass>"... they don't appear to...
    Anything to be done?
    Thanks - MRodent

    <Y extends Whatever>This works if Y is an interface extending interface Whatever.
    It works if Y is a class extending class Whatever.
    It works if Y is a class implementng interface Whatever.
    I believe you can also say <Y extends A, B, C> or <Y extends A & B & C>
    http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
    http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

  • Reading the Interfaces name which the class is implementing in a COM dll is implementing.

    Hi All,
    I'm using .NET Reflection to read a COM dll. I'm able to fetch the classes that are present in the dll. But I would like to know interface name which this class is implementing.
    For a .NET dll we can know the name of class's implementing interface name using the <classname>.BaseType.Name property.
    How can I know the interface name which this class is implementing (if any).
    Please let me know how to do this for a COM dll.
    Thanks in advance,Satish
    Thanks, Satish Bommideni "Success usually comes to those who are too busy to be looking for it."

    Hi,
    Thanks for the reply.
    I'm reading the COM assembly using the methods available in oleaut32.dll.
    Also I've imported the namespaces
    System.Runtime.InteropServices.ComTypes;
    System.Runtime.InteropServices;
    to use its respective methods and thus I'm able to read it's classes.But donot know what property to check for this class's interface.
    Kindly let me know if you need any further information.
    Thanks, Satish Bommideni "Success usually comes to those who are too busy to be looking for it."

  • Abstract Class that implements Comparable

    I am trying to understand how a comparable interface works with an abstract class. Any help is greatly appreciated.
    I have a class ClassA defined as follows:
    public abstract class ClassA implements Comparable I have a method, compareTo(..), within ClassA as follows:
    public int compareTo(Object o) I have a sub-class ClassB defined as follows:
    public class ClassB extends ClassAI am receiving a compile error:
    Class must implement the inherited abstract method packagename.ClassA.compareTo(Object)
    Should or can the compareTo be abstract in ClassA and executed in ClassB? Just not sure how this works.

    ???? if you are inheriting from an abstract class your subclass must implement methods that were declared in the parent (abstract) class but not implemented
    When in doubt, refer to the Java Language Specification..

  • Concrete classes implement abstract class and implements the interface

    I have one query..
    In java collection framework, concrete classes extend the abstract classes and implement the interface. What is the reason behind extending the class and implementing the interface when the abstract class actually claims to implement that interface?
    For example :
    Class Vector extends AbstractList and implements List ,....
    But the abstract class AbstractList implements List.. So the class Vector need not explicitly implement interface List.
    So, what is the reason behind this explicit definition...?
    If anybody knows please let me know..
    Thanx
    Rajendra.

    Why do you post this question again? You already asked this once in another thread and it has been extensively debated in that thread: http://forum.java.sun.com/thread.jsp?forum=31&thread=347682

  • Internal class implementing interface extending abstract interface :P

    Confused ha? Yeah me too. RIght here it goes.
    Theres an abstract interface (abstractIFace) that has for example method1() method2() and method3(). There are two other interfaces iFace1 and iFace2 that extend abstractIFace. Still with me? :P iFace1 only uses method2() whereas iFace2 uses method1(), method2() and method3(). Internal classes implementing these are then used. The reason is so that when returning an object one method can be used that will return different types of objects. But this doesnt work. It says that all the classes in the abstractIFace must be used/implemented but I only want method2() in iFace1 and all in iFace2.
    Just say what the f*ck if this is too confusing cos i think it is and i did a crap job explaining!! :P

    public interface IFace {
        void method1();
        void method2();
        void method3();
    public class Test {
        private static class Class1 implements IFace {
            public void method1() {
                System.out.println("method1");
            public void method2() {
                System.out.println("method2");
            public void method3() {
                System.out.println("method3");
        private static class Class2 implements IFace {
            public void method1() {
                throw new UnsupportedOperationException();
            public void method2() {
                System.out.println("method2");
            public void method3() {
                throw new UnsupportedOperationException();
        public static IFace createObject(boolean flag) {
            return flag ? (IFace) new Class1() : new Class2();
    }

  • A Bean must implement the java.io.Serializable interface? What makes the di

    Hi, I have took an example from sun notes on JavaBeans (you can find the example here http://java.sun.com/developer/onlineTraining/Beans/beans02/page2.html). The code is like this.....
    import java.awt.*;
    import java.io.Serializable;
    public class SimpleBean extends Canvas
                     implements Serializable {
      private Color color = Color.green;
      //getter method
      public Color getColor() {
         return color;
      //setter method
      public void setColor(Color newColor) {
         color = newColor;
         repaint();
      //override paint method
      public void paint (Graphics g) {
         g.setColor(color);
         g.fillRect(20,5,20,30);
      //Constructor: sets inherited properties
      public SimpleBean() {
         setSize(60,40);
         setBackground(Color.red);
    }I didn't find any difference in executing the program by implementing the Serializable interface and without implementing. On choosing serialize component in the File Menu, I serialized the component after changing its color (property), and saved as .ser file. And created the .Jar file including .ser file. when I load the jar file and place the bean in the beanbox, it is showing the bean that is updated. This can be done by implemeting Serializable interface and without implementing Serializable interface also. And I have a statement that has been given in the notes provided by SUN. That is ' Bean must implement the Serializable interface. Objects that support this interface can save and restore their state from disk '. I couldnot come up with the summation of this statement.
    Anyone who has an idea... please give an explanation.
    Thank you.

    Maybe you should show us your coding how you saved your beans state.
    Are you serious that you save the special object? Or do you save the values of the object into a file and load those values into a new object?

  • Design question about when to use inner classes for models

    This is a general design question about when to use inner classes or separate classes when dealing with table models and such. Typically I'd want to have everything related to a table within one classes, but looking at some tutorials that teach how to add a button to a table I'm finding that you have to implement quite a sophisticated tablemodel which, if nothing else, is somewhat unweildy to put as an inner class.
    The tutorial I'm following in particular is this one:
    http://www.devx.com/getHelpOn/10MinuteSolution/20425
    I was just wondering if somebody can give me their personal opinion as to when they would place that abstracttablemodel into a separate class and when they would just have it as an inner class. I guess re-usability is one consideration, but just wanted to get some good design suggestions.

    It's funny that you mention that because I was comparing how the example I linked to above creates a usable button in the table and how you implemented it in another thread where you used a ButtonColumn object. I was trying to compare both implementations, but being a newbie at this, they seemed entirely different from each other. The way I understand it with the example above is that it creates a TableRenderer which should be able to render any component object, then it sets the defaultRenderer to the default and JButton.Class' renderer to that custom renderer. I don't totally understand your design in the thread
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=680674
    quite yet, but it's implemented in quite a bit different way. Like I was saying the buttonClass that you created seem to be creating an object of which function I don't quite see. It looks more like a method, but I'm still trying to see how you did it, since it obviously worked.
    Man adding a button to a table is much more difficult than I imagined.
    Message was edited by:
    deadseasquirrels

  • Public class implements interface

    I am taking my first crack at interfaces: I have superclass A which is a parent of class B, which implements interface C. I need to use class B to make 3 variable instances within class A. I think I will use interface C to make calculations based on the 3 variables. Where do you recommend that I declare and set values for the 3 variables if I need to output the values at the top, in superclass A?
    I'm just a little unclear on pulling these objcts together... thanks in advance.

    I am taking my first crack at interfaces: I have
    superclass A which is a parent of class B, which
    implements interface C. I need to use class B to make
    3 variable instances within class A. I think I will
    use interface C to make calculations based on the 3
    variables. Where do you recommend that I declare and
    set values for the 3 variables if I need to output the
    values at the top, in superclass A?
    I'm just a little unclear on pulling these objcts
    together... thanks in advance. If your variables are going to be used by your superclass A then they had better be declared there. You can work with them whereever you want.
    I'm not sure what you are saying about "...use interface C to make calculations based on the 3 variables." You can't do calculations inside an interface. Furthermore, if B extends A and implements C then A and C are going to be completely separate entities. Any reference to C, even if it is actually an object of type B, will not be able to use anything in A--unless you cast it to B, in which case there is no use in making an interface at all.
    I probably just confused you, but oh well...
    Jeff

  • The XElement class explicitly implements the IXmlISerializable interface?

    I see a sentence on a training book.
    "The XElement class explicitly implements the IXmlSerializable
    interface, which contains the GetSchema, ReadXml, and
    WriteXml methods so this object can be serialized."
    I don't understand it. From
    the example, explicitly implements the IXmlSerializable interface is from a custom class rather than XElement class. Is
    MSDN wrong?

    I mean in the stackoverflow example,the class is a customized one "MyCalendar:IXmlSerializable"
    public class MyCalendar : IXmlSerializable
    private string _name;
    private bool _enabled;
    private Color _color;
    private List<MyEvent> _events = new List<MyEvent>();
    public XmlSchema GetSchema() { return null; }
    public void ReadXml(XmlReader reader)
    If XElement is a class that implements IXmlSerializable, what is the detail then?
    public class XElement : IXmlSerializable
    public XmlSchema GetSchema() { *detail*?; }
    public void ReadXml(XmlReader reader){*detail*?}
    Any source code of XElement class?

  • How to find out in program which all classes have implemented an interface

    Hello,
    I have created an interface and few classes are implementing the interface.
    I want to know in a program which all class have implemented the interface.
    Is it possible to find it out and how?
    Regards,
    Bikash.

    Hi Bikash,
    Read the Database view VSEOIMPLEM with where condition REFCLSNAME = Interface Name and version = 1.
    This would give you all the classes which have implemented the interface and are active...
    If you want to look at the values that the field version can have then see Type Group SEOC ans search for version....
    Hope this help...
    Regards,
    Sitakant

  • How to get classes which implement the interface in program

    Hi,
    I created an interface and some classes are implementing it. I want to know in which classes the interface is implemented through program. I mean in which table the interface implemented details stores.
    please helps regarding this.
    Thanks,
    Regards,
    Priya

    Hi.,
    Read the  database view VSEOIMPLEM with where condition.,  REFCLSNAME =  <Interface Name> and Version = 1.
    This gives the class names which implement the interface.,
    hope this helps u.,
    Thanks & Regards,
    Kiran

Maybe you are looking for

  • GW 6.5 - A suggestion for a good book

    Hello people ! I'm CNE in Brazil and I would like to know a good book to implement GroupWise 6.5.1 im my server that it will work with Border Manager 6.5 SP3 (Small Business Suite Starter Pack). Thanks in advance.

  • Server settings are not saved on client

    The client has a new workstation (Vista) where the server settings are not saved. The client is able to login but have to setup the server settings overtime she logs on to SAP B1. Client: Vista SBO: 2007A SP01 what is causing this and how can this be

  • How to activate fields "Start Reason" and "End Reason" in "Contact" form?

    Hello all, We recently migrated HRMS from version 11.5.7 to *12.1.3*. In the previous version users filled the fields Start Reason and End Reason in the Contact form (PERWSDPC), section Contact Relationship. In our 12.1.3 version these fields are rea

  • Memory notification in Alert Log

    I'm seeing the following in my alert log. Does this mean i am running out of SGA memory? if so, How do i increase it? Wed Oct 22 10:10:29 2008 Memory Notification: Library Cache Object loaded into SGA Heap size 2507K exceeds notification threshold (2

  • 8.0 beta download

    Hi, Is 8.0 beta Server available for download in zip format