|
Ok I'm not disagreeing or something like that, but, well. Why do you use a custom "type" thing when Java already provides the means to see which class an object is an instance of?
|
|
|
|
|
Thanks again,
I am experienced C/C# programmer but will try that in Java.
Kujtim
|
|
|
|
|
The operator is in C# is called instanceof in Java (saves you some googling)
|
|
|
|
|
Hello,
I just solved the problem. It was because the instance was not created with ObjectType ot[] = new ObjectType[3]; so I had to add also the lines ot[0]=new ObjectType(); , ot[1]=new ObjectType(); and ot[2]=new ObjectType(); after that.
The working code looks as follows:
class DiffObjectClasses{
public static void main(String [] args)
{
SerialObject so;
IPObject iob;
ObjectType ot[] = new ObjectType[3];
ot[0]=new ObjectType();
ot[0].objectID=1;
ot[0].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[0].objectContent=so;
ot[1]=new ObjectType();
ot[1].objectID=2;
ot[1].objectType=1;
so=new SerialObject();
so.serialPortNo=21;
ot[1].objectContent=so;
ot[2]=new ObjectType();
ot[2].objectID=3;
ot[2].objectType=2;
iob=new IPObject();
iob.host="localhost";
iob.port=2200;
ot[2].objectContent=iob;
System.out.println("----------------------------");
for(int indx=0; indx<ot.length;indx++)
{
System.out.println("ObjID:"+ot[indx].objectID);
System.out.println("ObjType:"+ot[indx].objectType);
switch(ot[indx].objectType)
{
case 1:
so=(SerialObject)ot[indx].objectContent;
System.out.println("Serial port no:"+so.serialPortNo);
break;
case 2:
iob=(IPObject)ot[indx].objectContent;
System.out.println("IP host:"+iob.host);
System.out.println("IP port:"+iob.port);
break;
}
}
}
}
class ObjectType extends Object{
int objectID;
int objectType;
Object objectContent;
}
class SerialObject extends Object{
int serialPortNo;
}
class IPObject extends Object{
String host="";
int port;
}
Thanks for other suggestions!
|
|
|
|
|
|
ana_ochia wrote: we have this project at school
0. Look at the top message, we are adamantly against doing homework. In the long run it does not help you and it syre as hell does not help the profession.
1. Do not try and get your message to stand out with big text. When used for a whole message, it gives the hamsters at codeproject HQ a hernia.
2. Now, work out what you want to do. Write [on paper] how your program shall work and try out something. If you get stuck, come back and ask a programming question.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
thanks...but FYI I'm not looking for other people to do my homework. I was just asking if it were possible that I can program the game. I wasn't asking for people to send me codes and stuff. I also want to learn and solve it on my own. I thought people here would help, but I guess not.
I think this will be the last time I'll post something here.
I don't want to attract attention especially with "people like you", so very close-minded, thinking that we're asking codes for homework..
thanks anyway.
PS: I did not make the text big on purpose. I can't barely see the text on my screen because my browser is Safari. Sorry if you thought I was doing that on purpose to get a coders attention. This is my first time joining in a forum like this. And I'm still new to the rules...I'll just delete my account if that makes you happy..
|
|
|
|
|
Hello,
Don't take it so badly. The problem is that there are really a lot of people who post and are just asking for finished code. I didn't see your original message but it was probably not clear and was understood as "please do the job for me" (because this is what a lot of people are asking these days). I suggest you read the posting guidelines ("How to get an answer to your question"), this will guide you a bit in formatting your question properly.
As long as you do not expect people to do the job for you and are willing to learn and work by yourself, people here will be ready to help you I'm sure.
|
|
|
|
|
There are guidlines posted at the top of all the forums here, please read them.
As Cedric said, we get too many people saking for 'da codz' and 'my homework is...' that any such question is bound to get a flipent reply. Don't take it to heart, try something out, do a little research and please come back when you are stuck.
We do WANT to help.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Not sure if this is the right place to ask the question, but here goes.
I am fairly new to working with J2EE, about a year now. I work on an existing J2EE app deployed to WL 10. At a very high level we have an enhancement project in which a back end mainframe process is going to create a dataset that is in essence a .csv file. These datasets will be created during a mainframe batch process run during certain time windows. These resulting data sets will also need to be zipped, encrypted and put onto a secure file storage mount where they can be downloaded via the web. As part of out deployment we have a server running that handles non-transactional, non-user invoked processing. It will fall to this J2EE application to handle the zip, encrypt and movement of these files to the file storage mount.
There is an option on the table to look at using MQ Series to transfer these resulting dataset (.csv) files from the mainframe to a place where the J2EE app can process (zip, encrypt, and place on file storage) the files.
So, finally to the question. As I understand MQ Series (Now MQ WebSphere or something like that), in essence it is a FIFO queue that can also provide triggering logic.
Is it possible to implement something that could monitor the MQ queue to just pull the files off the queue and process them? Or be triggered to check the MQ queue? Is this something already in the J2EE? Is this done via an api of some type? If this is possible, where is a good place to find some resources on doing something like this?
This is still in requirements and design so I don’t really have more detail at this point.
Thanks in advance for the help.
Troy
|
|
|
|
|
What you are looking for are Message Driven Beans or MDBs. Basically, they are container-managed components that sit waiting for messages to arrive on a JMS queue or topic, then they grab that message and process it and then go back to wait for the next message.
There is plenty of documentation around explaining how they work. Just Google for MDB. There are also plenty of books which cover JMS and MDBs.
WebLogic has its own JMS implementation but it is possible to use it with MQ Series. The WebLogic documentation used to include full instructions on how to do this, but I haven't used it since WL 9.2 so I don't know whether the documentation for 10 still includes this. If not, I'm sure a google search will pull up lots of examples.
|
|
|
|
|
Hi all, i downloaded the sortTable.js file from codeproject and it's working really fine. i am using an HTML table to display a MySQL data. But I need two additional things:
1) how to ignore some columns headers (the user can't click on column header to sort its values)
2) how to provide a default sort (sortTable.js sort by default the first column) but what if i need to sort the 2nd one? i tried "ORDER BY" but it's not working with our JS script.
Thanks for your help
|
|
|
|
|
This is a Java forum, not a JavaScript forum.
Try posting your question on the Web Development forum[^] instead. You are more likely to get an answer there.
|
|
|
|
|
how to print using LPD protocol from command prompt or in java???????
|
|
|
|
|
hi every1,
can sumbody help me by sending some code for my project "loadbalancing in p2p network" in any programming language.
i need this at urgent.
thnx in advance.
|
|
|
|
|
Oo oo! Can I do your homework for you?
Marking backwards - i.e. you loose a mark for each mistake:
Capital for Hi as it starts a sentence -1
everyone -1
Capital for Can; see above -1
somebody -1
'load balancing' is two words -1
Capital for I; see above -1
not 'at urgent' but 'urgently' -1
thanks -1
2/10 is under 40% so:
YOU FAIL!
And I didn't even consider the content.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
I want to built a simple search engine. For do that i want to ignore adverbs, proposition, conjunction from User entered search term. To do that i follow the following steps.
1. Have the list of words you need to remove from search term store in a text file.
2. Get the user input string of words(search term).
3. Then Split and Put it into a string array.
4. Iterate the string array and see if each string is equal to any of the words in the file.(Traverse through the file and match words)
5. If they are not put the words into another string array.
i have done only step 1,2,3. I don't know how to traverse through the file and match words in file and step 5.
please help me.
dharshani
..........
|
|
|
|
|
Hello Friends,
Can i embbed a password protected Excel file which is to uploaded to the wep.Any solution related .jar file .I'm new comer for jsp. Thanks in advance.
With Regards,
MAHESH.K
|
|
|
|
|
Hi,
I am trying to pass a vector of integers through JNI TO VC dll.How will i access the elements in that vector from my Visual C program?
Any help on this is really appreciated.
-Indhu
|
|
|
|
|
I am going to start this project soon so i need different ideas to design my project flow i mean like how would u like this management system to be? so that i can shape my project well
|
|
|
|
|
This reads so much like a homework question / school project. Am I right or just bang on the button?
[BTW, have you visited Hawaii?]
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
hi,
m trying to redirect the output of the binary log file of mysql into some other text file.
the code i've written is ..
Process runtimeProcess = Runtime.getRuntime().exec("cmd /C mysqlbinlog " + fileName + " > c:\\ logDump");
int processComplete = runtimeProcess.waitFor();
this redirects the output, but the "logDump" file formed does not contain the queries, only the general things which are in the binary log file.
if i do the process manually on the command prompt, it works fine.
wots the problem ??? somebody help !!!
|
|
|
|
|
Try changing /C to /K ...
It's not enough to be the best, when you have capability to be great....
|
|
|
|
|
it din't work ...
anybody has any solution ?
|
|
|
|
|
Your code works fine for me as is.
The only thing I can imagine is that perhaps you have spaces in the file name and Window's command processor is not dealing with them appropriately.
Note that the output of mysqlbinlog is a fairly complicated format that includes much more than just the queries run, but you should be able to find them in the output.
Cheers,
-- Scott
|
|
|
|