subclass

Rails single table inheritance/subclass find condition in parent

Hi all, I have a table called Users (class User < ActiveRecord::Base) and a subclass/STI of it for Clients (class Client < User). Client "filtering" works as expected, in other words Client.find(:all) works to find all the clients. However, for users I need to filter the result to only find users that are NOT clients (where type is nu...

Java - For a given function foo(X i); in Interface X, why can't implementing class Y change it to foo(Y i)??

For example public interface X{ public void foo(X i); } public class Y implements X{//error: doesn't implement foo(X i)... public void foo(Y i){ fooBar(foo); } .... } Why can't I do that? And how can I change it so this is possible? What can I do to declare foo in X with a parameter, and then be able to use Y ...

iPhone: Override UIButton buttonWithType to return subclass

I want to be able to create a UIButton with an oversized responsive area. I know that one way to do that is to override the hitTest method in a subclass, but how do I instantiate my custom button object in the first place? [OversizedButton buttonWithType: UIButtonTypeDetailDisclosure]; doesn't work out of the box because buttonWithTy...

UIScrollView strange zoom behavior when content is a UIView subclass

Hi, I'm experiencing the following: I created a UIView subclass with a CATiledLayer as backing layer by overriding the layerClass method. The layer properties (delegate, tileSize, etc) are set in the initWithFrame: method of the subclass. +(Class)layerClass { return [CATiledLayer class]; } -(id)initWithFrame:(CGRect)frame { i...

Methods in super that will be subclassed anyway (Cocoa)

Sorry if this is a repost but I couldn't quite search for it because I can't explain it in a few words. I have a super class with lots of methods but they will always (not all of them) be subclassed. From the super I need to run those methods. I could either leave the methods in super empty or I could just not type them in super but call...

Can I avoid explicitly casting objects with a common subclass?

I have an iPodLibraryGroup object and Artist and Album both inherit from it. When it comes to my view controllers though I find that I'm duplicating lots of code, for example I have an ArtistListViewController and and AlbumListViewController even though they're both doing basically the same thing. The reason I've ended up duplicating t...

Is it possible to access variable of subclass using object of superclass in polymorphism

how can i access state varibale of class keyboard with object of class kalaplayer /** * An abstract class representing a player in Kala. Extend this class * to make your own players (e.g. human players entering moves at the keyboard * or computer players with programmed strategies for making moves). ...

C# visually subclass datagridview control VS2005

Maybe its something stupid, but I'm having a problem with a subclass of a DataGridView Control in VS2005 C#. I know I can subclass from almost anything by doing public class MyDataGridView : DataGridView {} no problem, and I put in some things / elements I want applicable globally. Now, I take this gridview and put into a custom use...

Nhibernate one-to-many with table per subclass

I am customizing N2CMS's database structure, and met with an issue. The two classes are listed below. public class Customer : ContentItem { public IList<License> Licenses { get; set; } } public class License : ContentItem { public Customer Customer { get; set; } } The nhibernate mapping are as follows. <class name="N2.ContentI...

Intercept paste event on HtmlEditor WinForms

Hi I'm using a HtmlEditor control inside a Windows Form. I got the control from this page: http://windowsclient.net/articles/htmleditor.aspx I want to extend the controls functionality by allowing the user to paste images from the clipboard. Right now you can paste plain and formatted text, but when trying to paste an image it does n...

Java: Initializing a public static field in superclass that needs a different value in every subclass instance

Good evening, I am developing a set of Java classes so that a container class Box contains a List of a contained class Widget. A Widget needs to be able to specify relationships with other Widgets. I figured a good way to do this would be to do something like this: public abstract class Widget { public static class WidgetID { ...

Subclass of UIView with Xib file.

Hey guys, Although I've searched the Board and used google, I didn't get any useful results. I've trying to make a subclass of UIView loading its view from a xib file. My approach is the following: 1. Creating a subclass (named mySubclass): @interface mySubclass : UIView { } @end Creating a view through: Add New File... User Inte...

Why does initWithFrame have the wrong frame value?

I have a subclass of UIButton called INMenuCard and I am overriding the initWithFrame to include an activity indicator. The menuCard places correctly but any internal reference to "frame" give me "inf,inf,0,0" which means my activityIndicator subview is not placed correctly. What might I be missing? @implementation INMenuCard - (id)ini...

Why Can't I import a UITableViewCell subclass ? That's weird....

It's like this, I created a UITableViewCell subclass called NewsItemCell, then I wanna use it in my FirstViewController.m, then I tried to import it, but the compiler keeps telling me this Below is my code, it is driving me mad, thank you if you can help. #import "NewsItemCell.h" #import "FirstViewController.h" @implementation Firs...

How can I share variables between a base class and subclass in Perl?

I have a base class like this: package MyClass; use vars qw/$ME list of vars/; use Exporter; @ISA = qw/Exporter/; @EXPORT_OK = qw/ many variables & functions/; %EXPORT_TAGS = (all => \@EXPORT_OK ); sub my_method { } sub other_methods etc { } --- more code--- I want to subclass MyClass, but only for one method. package MySubclass...

Using Sub-Types And Return Types in Scala to Process a Generic Object Into a Specific One

I think this is about covariance but I'm weak on the topic... I have a generic Event class used for things like database persistance, let's say like this: class Event( subject: Long, verb: String, directobject: Option[Long], indirectobject: Option[Long], timestamp: Long) { def getSubject = subject def getVerb = verb def...

Java - abstract class, equals(), and two subclasses

Hello, I have an abstract class named Xpto and two subclasses that extend it named Person and Car. I have also a class named Test with main() and a method foo() that verifies if two persons or cars (or any object of a class that extends Xpto) are equals. Thus, I redefined equals() in both Person and Car classes. Two persons are equal wh...

Java - is there a "subclassof" like instanceof?

Hello, Im overriding an equals() method and I need to know if the object is an instance of a Event's subclass (Event is the superclass). I want something like "obj subclassof Event". How can this be made? Thanks in advance! ...

Fluent NHibernate Repository with subclasses

Having some difficulty understanding the best way to implement subclasses with a generic repository using Fluent NHibernate. I have a base class and two subclasses, say: public abstract class Person { public virtual int PersonId { get; set; } public virtual string FirstName { get; set; } public virtual string LastName { get...

Hibernate: How do I link a subclass to its superclass?

Hey there! I'm having a little problem setting up my webshop project. Thing is, I have a User() superclass and two subclasses, PrivateUser and BusinessUser. Now, I'm not quite sure how to get my head around storing this relationship via hibernate. For the purpose of this question, the User() class contains only one field: String addre...