class

Java: can I require a child class to define a property value?

I have an abstract base class that many classes extend. I'd like all these classes to define a unique value for a specific property that is originally defined in the base class (similar to the serialVersionUID property that causes a warning when not defined in classes that inherit from Serializable). Is there a way for me, within my ab...

JavaScript getting an elements class without any libraries

I would like to get the value of the class attribute for an element using JavaScript. However in this particular situation I don't have the luxury of library such as YUI, jQuery, etc. and need to stick to the basics. Specifically, I am looping over a table and want to check the class of the cell. I tried: var colClass = el.getAttribu...

To bless or not to bless, that is my question!

Hello everyone, first post from a newbie-user. Every question I google seems to bring me here and I always get a great answer to what I'm looking for; so naturally this was my first stop when I began pondering the usage of blessing in Perl. I've just gotten into Perl's OOP and just today read the post asking what bless does. I now under...

Python: object as an argument of another object

I have a module including definitions for two different classes in Python. How do I use objects of one class as an argument of the other? Say, I have class definitions for Driver and Car, and tuen want to have a Driver object as an argument for a Car object. ...

Disable rails class_caching mechanism for Time.now?

Hey there, I'm currently fighting with the rails class_caching mechanism as I need to return a file path that changes discrete over time. It is used to constantly change a log file path after the amount of GRAIN seconds and returns a fully working timestamp: GRAIN = 30 def self.file_path timestamp = (Time.now.to_i / GRAIN) * GRAI...

Can't read file in__init__

Hello all. I am a newbe to Python. I have tried to create a class, named ic0File. Here is what I get when I use it (Python 3.1) >>> import sys >>> sys.path.append('/remote/us01home15/ldagan/python/') >>> import ic0File >>> a=ic0File.ic0File('as_client/nohpp.ic0') Traceback (most recent call last): File "<stdin>", line 1, in <module> ...

Using Flash Builder to create a collection of AS3 classes

How can I set up a project in Flash Builder for creating a collection of classes that is not an application by itself? When creating an Actionscript project it forces having a main application file, as well as sets up the whole bin-debug folder and such. For instance, if you wanted to start coding something like Tweener, Papervision, or...

Change div background image with jQuery

Hey guys, I'm trying to change the background image of multiple divs with the class .innerpreview when a drop down selection is made. Any idea why the following isn't working? $('#txtMontage').change(function(event) { if (this.value == "example") { $('.innerpreview').css('background-image', 'img/img-bkg.jpg)'); } }); T...

Is there a better way to get ‘class’ semantics in Powershell (defining custom types)?

I am building an automation system using Powershell and I would like to define custom .Net types so that I can structure my application in a similar way to the other code I write. At first, I tried using ‘Add-Type’ to import types from c# files into my application but I found this to be extremely painful to debug as a .net type can only...

Java; Accessing Member Instance Variables From Another Class

I have the following structure: public class A { private javax.swing.JLabel fullName; public class B { public B() { fullName.setText("Martha Stewart"); } } ... ... ... } My goal is to have B (currently the sub class of A) to be in a separate class. The pro...

How does one launch android version dependent alarm clock?

I have a widget that displays the time and if one taps on it, it launches the com.android.alarmclock/.AlarmClock activity with an PendingIntent. This works great before-Froyo, but with Froyo, I have to launch the com.android.deskclock/.AlarmClock. So I want to put in code that checks for the class existence and launch the appropriate a...

Python: coerce new-style class

I want this code to "just work": def main(): c = Castable() print c/3 print 2-c print c%7 print c**2 print "%s" % c print "%i" % c print "%f" % c Of course, the easy way out is to write int(c)/3, but I'd like to enable a simpler perl-ish syntax for a configuration mini-language. It's notable that if I ...

JNI Header file generating class

Hi, I'm currently using the JNI to generate C headers for native methods being used in a Java class ABC. However, I'd like to use these methods elsewhere, in another class XYZ, so hence I made a class called cLib which basically just had the prototypes of the native methods, and which when generated gave me the header file for the meth...

How to pass method from class A to class B

There are 3 files: 1. Annuuity.java 2. AnnuityDueGUI.java // GUI for Annuity Due 2. AnnuityDueResultGUI.java //GUI for the result Under AnnuityDueGUI.java: public double calculateFADGUI(){ //FVA = A{[(1+i)^n – 1] / i} (1+i) String amountStr = amount.getText() ; //convert string to double dAmount = Double.pa...

What is the difference between the concept of 'class' and 'type'?

Hi all, i know this question has been already asked, but i didnt get it quite right, i would like to know, which is the base one, class or the type. I have few questions, please clear those for me, Is type the base of a programing data type? type is hard coded into the language itself. Class is something we can define ourselves? What i...

nHibernate - Complicated many-to-many class mapping

Hi All I'm new to nhibernate, and I'm sorry if this is answered elsewhere, but I've been looking for the last couple of hours, and can't find a solution that works. A bit of background: I'm trying to write an Admin area where there are users and sites, and a user can have access to multiple sites - but at various permission levels for ...

How to know if a Java class is initialized

How is it possible to know whether a class has been initialized? Class cl = Class.forName("com.example.MyClass", false, getClass().getClassLoader()); // the false argument above indicates that the class should not be initialized // but how can I check whether it already was? cl.isInitialized(); // this does not exist, how can I know ins...

Check if class exists in Java classpath without running its static initializer?

If I use try { Class.forName("my.package.Foo"); // it exists on the classpath } catch(ClassNotFoundException e) { // it does not exist on the classpath } the static initializer block of "Foo" is kicked off. Is there a way to determine whether a class "my.package.Foo" is on the classpath without kicking off i...

In a tree structure, how to name the tree, the nodes, the leaves?

Hello, this question is about best practices. I'm implementing a 3D interval Kd-Tree and, because of the recursive structure of the tree I would be tempted to create a unique class, KdTree to represent the tree itself, the nodes and the leaves. However: elements are contained only at leaves, some general tree parameters (such as the ma...

Need to confirm my thinking on Modules vs Classes in VB.net

I'm working on a project with a contractor we hired to do some VB.Net programming. I used to program for this project, but I have more recently become primarily the project manager so I can work on other issues I have. His method of programming differs greatly from what I was taught in school. The only time he uses classes is basically i...