Hello, I'm trying to find a way to flexibly filter a column in a row
of data read from a file. I will have data type of that column, the
operation to be performed on it (like >, <, <= etc.) and the value to
compare it to stored in a database. If I'm to write it in a
procedural language it would be a big case statement like this: case
int
case <=
return (value <= compare value)
Can you think of a better way of doing it?
I was thinking about writing a separate class for each datatype with
methods for each operation. But then again I have to use case to
figure out the datatype and the operation to use. I could put
operators in a hash table with the method name as the value which
leads me to a next question. Can I invoke a method where method name
is a variable? For example myClass.varMeth odName where varMethodName
would contain a string with a real method name? And can I instantiate
a class with a variable, like instanceof(varc lassname) where
varclassname will hold the name of the real class?
I'd appreciate if you could suggest a way to implement my filtering
mechanism.
Thanks for your help.
N.K. 1 2027
Thank you so much. At least I see how to implement one solution now.
Can you think of a totally differnt way to implement this filtering?
I'm not sure my solution (even if it works ) is a great one.
Thanks for your tips though, I do appreciate your help.
N.K.
"Eric Olander" <eo************ *@earthlink.net > wrote in message news:<rA******* **************@ newsread1.prod. itd.earthlink.n et>... Hi, Your proposed solution is possible using the Class class (defined in java.lang) and classes from the Reflection API (java.lang.refl ect). For example, your instanceof(varc lassname) would look something like this:
instanceof(Clas s.forName(varcl assname)) where varclassname is a String.
To call a method whose name is in a String var, you'd do something like this:
note: myObj is an instance of myClass
Method myMethod = myClass.getDecl aredMethod(varM ethodName, argTypes[]); myMethod.invoke (myObj, args[]);
I don't know if this is the best solution to your problem, but it can be done this way. Good Luck!
-Eric
"N.K." <na****@parkerg lobal.com> wrote in message news:2d******** *************** ***@posting.goo gle.com... Hello, I'm trying to find a way to flexibly filter a column in a row of data read from a file. I will have data type of that column, the operation to be performed on it (like >, <, <= etc.) and the value to compare it to stored in a database. If I'm to write it in a procedural language it would be a big case statement like this: case int case <= return (value <= compare value) Can you think of a better way of doing it? I was thinking about writing a separate class for each datatype with methods for each operation. But then again I have to use case to figure out the datatype and the operation to use. I could put operators in a hash table with the method name as the value which leads me to a next question. Can I invoke a method where method name is a variable? For example myClass.varMeth odName where varMethodName would contain a string with a real method name? And can I instantiate a class with a variable, like instanceof(varc lassname) where varclassname will hold the name of the real class? I'd appreciate if you could suggest a way to implement my filtering mechanism. Thanks for your help. N.K. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Omer van Kloeten |
last post by:
The Top Level Design:
The class Base is a factory class with a twist. It uses the Assembly/Type
classes to extract all types that inherit from it and add them to the list
of types that inherit from it. During run time, using a static method, the
class creates an instance of the derived class using the Activator class and
returns it. This...
|
by: Patrick |
last post by:
Hi all,
New to .NET, I'm working on an Winforms client application using VS
2005 beta2. My needs considering data storage are the followings:
(1) Small files (0 < length < 10 mb), containing lots of small
'objects' that need to be loaded into memory at runtime, in order to
garantee small access time to each 'object'. Each of these...
|
by: rodchar |
last post by:
Hey all,
I'm trying to understand Master/Detail concepts in VB.NET. If I do a data
adapter fill for both customer and orders from Northwind where should that
dataset live?
What client is responsible for instantiating the orders class? Would it be
the ui layer or the master class in the business layer?
thanks,
|
by: tshad |
last post by:
Many (if not most) have said that code-behind is best if working in teams -
which does seem logical.
How do you deal with the flow of the work?
I have someone who is good at designing, but know nothing about ASP. He can
build the design of the pages in HTML with tables, labels, textboxes etc.
But then I would need to change them to...
|
by: gabe |
last post by:
I have a general design question.
What's a 'Best Practice' for middle tier component design?
I'm thinking of a web form that contains data from multiple tables. The
data is supplied from one or more muti-table joins. Is it better to
populate a form by binding to dataset tables or load the data in
collection classes? How are the updates...
| |
by: Christoph Zwerschke |
last post by:
Sometimes I find myself stumbling over Python issues which have to do
with what I perceive as a lack of orthogonality.
For instance, I just wanted to use the index() method on a tuple which
does not work. It only works on lists and strings, for no obvious
reason. Why not on all sequence types?
Or, another example, the index() method has...
|
by: A_M_IS |
last post by:
Dear valuable experts,
I truly hope than You can suggest for me Your ideas how to resolve
design.
I developing relative small Access VB tool, for single user use only.
Access version 2003, but db saved for compatibility as ver. 2000.
Basic structure of this tool is dependent from my house departments
structure.
Each department owes their...
|
by: Sjaakie |
last post by:
Hi,
I'm, what it turns out to be, fooling around with 3-tier design.
At several websites people get really enthusiastic about using custom
dataobjects instead of datasets/-tables.
While trying to write such layers myself I got stuck on how to get
filtered or sorted data from the data-layer.
This is what I got:
Objects
|
by: |
last post by:
I have a question about spawning and displaying subordinate list controls
within a list control. I'm also interested in feedback about the design of
my search application. Lots of code is at the end of this message, but I
will start with an overview of the problem.
I've made a content management solution for my work with a decently...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |