subclass

How do I force a Java subclass to define an Annotation?

If a class defined an annotation, is it somehow possible to force its subclass to define the same annotation? For instance, we have a simple class/subclass pair that share the @Author @interface. What I'd like to do is force each further subclass to define the same @Author annotation, preventing a RuntimeException somewhere down the roa...

How do you use the ellipsis slicing syntax in Python?

This came up in Hidden features of Python, but I can't see good documentation or examples that explain how the feature works. ...

Subclassing DropDownList in ASP.NET

Hi, I want to subclass the built-in DropDownList in ASP.NET so that I can add functionality to it and use it in my pages. I tried doing this with a UserControl but found that it doesn't expose the internal DropDownList (logically, I guess). I've googled for the answer but can't find anything. I've come as far as writing the actual clas...

What is your convention to distinguish between object methods to be called by the outside, and object methods to be called by a subclass ?

I know most of the ins and outs of Python's approach to private variables/members/functions/... However, I can't make my mind up on how to distinguish between methods for external use or subclassing use. Consider the following example: class EventMixin(object): def subscribe(self, **kwargs): '''kwargs should be a dict of e...

What is a good way to check if an object's type is a particular subclass?

I was thinking along the lines of using typeid() but I don't know how to ask if that type is a subclass of another class (which, by the way, is abstract) Edit: I should definitely mention the language, C++ ...

NHibernate Inheritance mapping when sub class in Separate Assemblly

Hi, Assume that core project have a base entity and every plugin maybe extend the base entity Solution structure : Application.Core.BaseClass Application.Module.SubClass (it's plug in, maybe not available) Is any way to implement this mapping with nhibernate subclass? Thanks and sorry for my bad english ...

Using subclassing to replace a Java class that doesn't implement an interface

For example, java.io.File is just a concrete class. My replacement for it supports resolving Windows shortcuts. I need to preprocess constructor parameters to resolve possible .lnk files because the FileSystem object that does normalizing/canonicalision/resolving on the abstract paths is not accessible. The need for preprocessing rules o...

C# calling overridden subclass methods without knowledge that it's a subclass instance

I have a base class with a virtual method, and multiple subclasses that override that method. When I encounter one of those subclasses, I would like to call the overridden method, but without knowledge of the subclass. I can think of ugly ways to do this (check a value and cast it), but it seems like there should be an in-language way t...

Why can't I subclass datetime.date?

Why doesn't the following work (Python 2.5.2)? >>> import datetime >>> class D(datetime.date): def __init__(self, year): datetime.date.__init__(self, year, 1, 1) >>> D(2008) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: function takes exactly 3 arguments (1 given) I wanted to c...

gtk.Builder, container subclass and binding child widgets

I'm trying to use custom container widgets in gtk.Builder definition files. As far as instantiating those widgets, it works great: #!/usr/bin/env python import sys import gtk class MyDialog(gtk.Dialog): __gtype_name__ = "MyDialog" if __name__ == "__main__": builder = gtk.Builder() builder.add_from_file("mydialog.glade"...

Inheritance in Java - creating an object of the subclass invokes also the constructor of the superclass. Why exactly?

Hallo, I have a question about inheritance in Java. I have two classes A and B, and class B, inherits from A: public class A { public A() { System.out.println("Hi!"); } } public class B extends A { public B() { System.out.println("Bye!"); } public static void main(String[] args) { ...

How do you find all subclasses of a given class in Java?

How does one go about and try to find all subclasses of a given class (or all implementors of a given interface) in Java? As of now, I have a method to do this, but I find it quite inefficient (to say the least). The method is: Get a list of all class names that exist on the class path Load each class and test to see if it is a subcla...

Windows Subclassing in Borland C++ Builder

We're trying to convert a piece of C++ code written in MFC which uses the CWnd.SubclassWindow method, into Borland C++ Builder code. Does anyone know how to do subclassing (subclass with a TForm object) - we're completely stuck. Any pointers will be much appreciated! TIA! Specifics: We have an existing base class written in Borland C++...

java swing : custom everything - subclass jcomponent or jpanel or ... ?

Hiya - quick one - is there any harm / value in subclassing JComponent as compared to JPanel ? To me they pretty much look to be the same thing if I'm doing my own drawing & the object won't have any children, however there seems to be a pref for subclassing JPanel over JComponent - just looking for opinions on why this might be ... T...

How to initialize an NSObject's subclass on iPhone?

I want to write some methods in a class so that other classes can call these methods using [instance methodName:Parameter]. If the class is a subclass of UIViewController, I can use initWithNibName to initialize it. But I want to write the methods in an NSObject's subclass, how can I initialize it? ...

C# Subclass with same method

I have a superclass with two subclasses. The two subclasses both have a method with checks whether a chapter has content. For subclass 1 this method is HasContent(int chapterID) and for subclass 2 this is HasContent(int chapterID, int institution). As you can see subclass 2 has an extra parameter. The purpose of both methods is the same....

How can "default" values in overridden WinForm controls be prevented?

I'm trying to learn and grasp what and how C# does things. I'm historically a Visual Foxpro (VFP) developer, and somewhat spoiled at the years of visual inheritance by creating my own baseline of user controls to be used application wide. In trying to learn the parallels in C#, I am stuck on something. Say I derive my own label contro...

Subclass of subclass of Form shows up empty

I am writing an application where I have indeterminate amount of Forms that require a certain popup-functionality (similar to MSN, a little window at the bottom right of the screen). I wrote the first form, then thought that I could copy the file to make a new one. So far so good. A bit later I realized that I could have subclassed Form,...

Why is wx.SingleChoiceDialog not subclassing properly

I'm trying to subclass the wxpython SingleChoiceDialog class. I have a TableChoiceDialog class that inherits from SingleChoiceDialog adding generic functionality, and I have 2 sub classes for that add more refined functionality. Basically I'm O.O.P'ing In my TableChoiceDialog class I have a line which calls the superclass's __init__, ...

Intercepting changes of attributes in classes within a class - Python

I have been messing around with pygame and python and I want to be able to call a function when an attribute of my class has changed. My current solution being: class ExampleClass(parentClass): def __init__(self): self.rect = pygame.rect.Rect(0,0,100,100) def __setattr__(self, name, value): parentClass.__setattr__(sel...