|
You mean like an image showing the machine is idle?
How about an dialog saying "wait"?
Why does it take so long to load the data?
regards Torsten
I never finish anyth...
|
|
|
|
|
The proper way to do this is with some form of progress bar[^].
The best things in life are not things.
|
|
|
|
|
Hello,
I would like to fully understand the concept of 'unchecked casting'.
I get an 'unchecked cast' warning when I try to do this:
<br />
List<Element> freq1;<br />
pfreq1 = XPath.newInstance("/values/val[@freq<10]");<br />
freq1 = (List<Element>) pfreq1.selectNodes(doc);
What I am doing on line 3 is converting a List (pfreq1) to a List<Element> (freq1).
After googling, I have taken over the following 'cure', which worked:
<br />
private void makeValid(List li) {<br />
freq1 = new ArrayList();<br />
for (Object o : li) {<br />
freq1.add((Element) o);<br />
}<br />
}<br />
<br />
makeValid(pfreq1.selectNodes(doc));<br />
This works, but I do not know why. I do not know why the 'unchecked cast' warning disappears then.
I am explicitly converting each element of the generic List pfreq1 to an Element, thus making all elements in that generic List turn into real Element objects, which would make it a List<Element>. Now the compiler is sure that every object inside that List is now of type Element and thus can convert it safely to a List<Element>. That's how I see it.
However, what I would like to know is how and why unchecked casting works.
Thank you
|
|
|
|
|
The return type of the selectNodes method on XPath is a plain List, not a List<Element>.
In line 3 you are telling the compiler that you want to cast the List returned from selectNodes to a List<Element>.
The problem comes when you think about what is inside that list. selectNodes has returned you a plain List, which could in theory contain any type of Object. So although you can tell the compiler to cast the List to a List<Element> there is no guarantee that the contents of the List will actually be of type Element when the thing runs.
So the unchecked cast warning is the compiler telling you to be careful: you want to cast this to a List of Elements, but you may not get a List of Elements at this point at runtime. There is no way the compiler can check that for you, so it is prompting you to say "Are you sure this is right?"
In the second case, you are taking a plain List from selectNodes, and then iterating over the contents and casting each entry in turn into an Element before adding it into the list. That makes sure that the entries being added into freq1 are the correct type (Element). So the compiler doesn't need to warn you that the entries may be the wrong type because you have taken care of that yourself.
Hopefully that helps to make things a bit clearer.
|
|
|
|
|
Hi guyz,
i had developed a chat server in java for my website and now i wish to use it for my wesbite for live chatting with customers,please help me on that(all i know is that it would require jsp\servlets and tomcat server )
thnx.
I THINK THE INFO GIVEN BY ME WAS INSUFFICIENT,
so lemme put it this way:
i was supposed to make a chat server which could be used for live chatting(to connect operator and client) on the website,
i modified one of the chat servers(which i took from this website) and now the chat server is ready(with both the server part and the client part),i have converted them into jar files and now i have to link that program to my website so that people who visit the website can chat directly with the operator on a single click).
for that i guess i need to make jsp and servlets..for that i need guidance that how to do that..
in short:I WAS SUPPOSED TO ENABLE LIVE CHAT IN A WEBSITE AS A PART OF MY PROJECT AND FOR THAT I HAVE MADE UP THE CHAT SERVER PROGRAM AND NOW I NEED HELP REGARDING HOW TO USE(LINK) IT ON MY WEBSITE
i hope i made myself clear..please ignore any typing mistakes,
thanx
modified on Wednesday, July 6, 2011 8:49 AM
|
|
|
|
|
There are lots of samples of this type of website around the internet. I'm sure a Google search for "java chat website" will yield some useful results.
The best things in life are not things.
|
|
|
|
|
sir,thankyou for your reply..please read the modified message once again
|
|
|
|
|
Member 8011053 wrote: i guess i need to make jsp and servlets..for that i need guidance that how to do that.
There is no simple one line answer to this question. If you do not have any experience in these technologies then you are not going to be able to complete this project easily. There are many samples around the internet and, once again, I suggest you go and research some of them.
The best things in life are not things.
|
|
|
|
|
ok thankyou for your advices , i have 1 month with me so i will try my best.
|
|
|
|
|
so you have developed a chat server, eh?
smells like homework.
What part of the client do you've got yet?
regards Torsten
I never finish anyth...
|
|
|
|
|
i have modified the information and stated more clearly that i want..please have a look and reply ,
thankyou
|
|
|
|
|
sir/mam
i want to know if i can put the try block directly in a class... as
class a
{
try
{
methods;
}
catch()
{ }
}
|
|
|
|
|
No, a try/catch block has to be inside a method.
What are you trying to achieve exactly ?
|
|
|
|
|
thanks cedric for your reply.
If you don't mind can you please explain why we can't put the try/catch block directly in a class.
why it is required to put it in a method.
|
|
|
|
|
For the same reason why you can't put code directly in a class: it is by design. If you would be able to put code directly in your class (not in a method), what would that mean ?
A try/catch block is meant to surround code that could potentially fail. If you put it directly in a class, it doesn't surround any code.
|
|
|
|
|
Cedric Moonen wrote: If you would be able to put code directly in your class (not in a method), what would that mean ?
That it was static.
class MyClass {
{
System.out.println("This is a static code block");
}
}
Hopefully no-one will actually write a class like that minimalist example, but static code blocks are there for a reason and can be useful under certain circumstances.
|
|
|
|
|
David Skelly wrote: under certain circumstances.
...under very certain circumstances.
I've just cleaned out that stuff out of one of my projects here. A former student used to make (like?) such crucial stuff.
regards Torsten
I never finish anyth...
|
|
|
|
|
I once saw world war III break out over the rights and wrongs of static code blocks between an ex-Smalltalk OO purist and an ex-C++ hacker. No quarter asked or given on either side.
It's like anything: give someone a hammer and they will find a way to hit themselves on the head with it.
|
|
|
|
|
The try{}catch{} mechanism is specifically for catching exceptions thrown within a block of code, i.e inside a method. Putting such a mechanism in a class has no meaning as it includes things like variable definitions, overloaded methods etc.
The best things in life are not things.
|
|
|
|
|
Thanks cedric and richrd.
you solve my problem.
thanks a lot....
|
|
|
|
|
The code you write inside a class are NOT "executable", they're just declarations like variables and methods. The try {} catch {} block is designed to trap errors in executable code. Since only methods contain executable code, try {} catch {} can be placed inside methods only.
|
|
|
|
|
Hello,
My application needs to directly read cookies data from cookies4.dat file that is a cookies firl for Opera browser.
When I load the cookies file of opera it gives me a lot of noise. Here's the <a href="http://img840.imageshack.us/img840/7509/63274022.png">screenshot</a>.
How can I extract(/parse) values for each cookie from that .dat file?
Thanks.
|
|
|
|
|
Just a brief guess - the file ends on *.dat.
For some strange circumstances a *.dat file is a binary file without any specific associated format.
so you've got to give that data some meaning.
You should take a look in the documentation. There you'll find some info on Opera Cookie File Format[^].
regards Torsten
I never finish anyth...
|
|
|
|
|
Thank you. Actually, the problem is that I don't know how to read(/parse/extract values from) that Opera Cookie File Format.
|
|
|
|
|