| Infinite loops in hashCode() and equals() |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- MI5-Persecution: MI5 Waste Taxpayer Millions on Pointless Hate-Campaign (18598)I don't know what the hell this is. But he/she/it asked for a respond. I
sent a 19 MB picture of my middle toe. I hope they liked it, and I have no
message saying the message did not go through. Say they must like it. I am
working on 100 MB pictures
--
AZ
<email***@***.com> wrote in message news:email***@***.com...
>
> MI5 Persecution Update: Friday 30 April, 1999
>
> If You Intend To Reply, Please Read This
> Please.... keep your response to one page!. Faxes over a page or two will
> be deleted without being read.
>
> Somewhere between 0 and 100%
>
> The last few days there have been no clear recordable instances of
> abuse. However, while travelling on the Underground, while walking around
> near my home and going to friends homes, I am constantly troubled by
> thoughts that those people over there might be about to get at me; that
> the couple sitting in the opposite seats laughing are in fact laughing at
> me; et cetera, et cetera.
>
> A comment by a scientist to the BSE inquiry sticks in my mind. He
> described the possible scale of the epidemic as "between 0% and 100%". It
> might not be happening, it might not happen at all, to any discernable
> degree.... or it might be total. Without clear recording, which seems to
> have become impossible the last couple of weeks, there is no way of
> knowing whether the harassment really is continuing, whether we have
> entered a temporary hiatus, or whether perhaps it has perhaps stopped for
> now.
>
> But for the time being I think there arent any reasons to dicontinue these
> faxes. I only re-started them six weeks ago in response to a resumption of
> MI5 harassment; and I think I will need to be more convinced of absence of
> persecution before I discontinue my complaints.
>
> The Newscasters are still watching
>
> In the last few weeks there have been at least a couple of fairly overt
> instances of "interactive watching" by newscasters. I reported this in a
> previous "MI5 Persecution Update".
>
> These instances are really very rare compared to 1990-91, when there were
> many dozens of such occurrences. Undoubtedly the reduction is due to my
> practice of videotaping everything I see. Recently I had the opportunity
> of showing this years "happenings" (Jon Snow/Nicholas Witchell) to my
> psychiatrist, and he agreed that in both cases the newscasters were
> expressing merriment without visible cause, and that objectively it might
> be possible for my claims to be true - although of course other people
> reported similar thoughts to him, and this thinking is usually a symptom
> of illness.
>
> Read About the MI5 Persecution on the World Wide Web
>
> The March 1998 issue (number 42) of .net Magazine reviews the website
> describing it as an "excellent site". Since August 11, 1996 over 50,000
> people have browsed this website.
>
> You are encouraged to read the web pages which include
>
> a FAQ (frequently asked questions) section outlining the nature of the
> persecutors, their methods of harassment through the media, people at work
> and among the general public
>
> an evidence section, which carries audio and video clips of media and
> workplace harassment, rated according to how directly I think they refer
> to me
>
> objective descriptions of the state security agencies involved
>
> scanned texts of the complaints I have made to media and state security
> agencies involved
>
> posts which have been made to netnews over the last four years on this
> topic
>
> Keith Hill MP (Labour - Streatham), my elected representative, as ever
> refuses to help.
>
> MI5 Waste Taxpayer Millions on Pointless Hate-Campaign
>
> Recently I was talking to an independent observer about the nature and
> purpose of the perceived campaign of persecution against me. The person I
> spoke to, a highly intelligent man, said he was struck by the utter
> pointlessness of the perceived campaign against me. He also said that, if
> my theories were in fact true, many people would have to be involved, in
> the surveillance itself, and in the technical side of the delivery of
> information from my home to TV studios for example, if the "interactive
> watching" were happening as described. He voiced these thoughts without
> any prompting from me; but both I and other observers had arrived at
> pretty much the same conclusions, some years ago.
>
> I saw a team of four men at Toronto Airport in 1993
>
> To carry out the surveillance alone, full-time, would employ four or five
> men, or their equivalent in terms of man-hours. Each man would "work" an
> eight-hour shift, so you would need at least three men doing the
> surveillance, plus a connecting link / manager. An indicator that this
> estimate is correct arrived in 1993, when I was accosted by one of a group
> of four men at Toronto Airport; he said, laughing, "if he tries to run
> away well find him". Plainly these were the men who had been involved in
> the intrusive surveillance of me for the preceding three years.
>
> On other occasions, I have seen the same man on two or three occasions. On
> one such occasion, at Ottawas Civic Hospital in November 1996; he gave his
> name to the doctor as "Alan Holdsworth" or some such; my hearing is not
> very good sometimes and I am not sure of the surname, although I am sure
> "Alan" was his first name. I saw exactly the same man again in Ottawa, at
> the airport, in July 1998. Obviously, other people must be "working" with
> this person; he would not be the sole agent employed in this case.
>
> Usenet readers views on the Cost to MI5 of Running the Campaign
>
> Here's what a couple of other people on internet newsgroups / Usenet
> (uk.misc) had to say regarding the cost of running such an operation...
>
> PO: >Have some sense, grow up and smell reality. What you are talking
> about
> PO: >would take loads of planning, tens of thousands of pounds and lots of
> PO: >people involved in the planning, execution and maintenance of it. You
> PO: >must have a very high opinion of yourself to think you are worth it.
>
> and......
>
> PM: >But why? And why you? Do you realize how much it would cost to keep
> PM: >one person under continuous surveillance for five years? Think about
> PM: >all the man/hours. Say they _just_ allocated a two man team and a
> PM: >supervisor. OK., Supervisor's salary, say, #30,000 a year. Two men,
> PM: >#20,000 a year each. But they'd need to work in shifts -- so it would
> PM: >be six men at #20,000 (which with on-costs would work out at more
> like
> PM: >#30,000 to the employer.)
> PM: >
> PM: >So, we're talking #30,000 x 6. #180,000. plus say, #40,000 for the
> PM: >supervisor. #220,000. Then you've got the hardware involved. And
> PM: >any transcription that needs doing. You don't think the 'Big Boss'
> PM: >would listen to hours and hours of tapes, do you.
> PM: >
> PM: >So, all in all, you couldn't actually do the job for much less than
> PM: >a quarter million a year. Over five years. What are you doing that
> makes
> PM: >it worth the while of the state to spend over one and a quarter
> million
> PM: >on you?
>
> Those are pretty much the sort of calculations that went through my head
> once I stopped to consider what it must be costing them to run this
> operation. At the very least, a quarter million a year - and probably much
> more, given the intrusive and human-resource-intensive methods
> employed. Times nine years. Equals well over two million pounds - and
> probably much, much more.
>
> Its wasteful for someone with my skills to be unemployed
>
> The wastefulness of the MI5 campaign against me is not just that of futile
> expenditure on their side. It is also extremely wasteful for someone with
> my talents to be unemployed and on a disability pension. I am highly
> qualified in numerate disciplines, yet am unable to work, specifically
> because of the MI5 hate-campaign against me. It is a terrible waste of
> resources for a supposedly efficient economy like that of the UK to be
> squandering the talents of a skilled and capable worker.
>
> I made every effort to remain in employment for as long as I could, but
> ultimately I was defeated by MI5s employment of massive resources
> specifically targeted on my workplaces with the sole aim of seeing me
> evicted from those workplaces. You might expect this sort of behaviour
> from the Stasi or some other secret police force in a communist country
> where labour is cheap, and the governments aim on seeing its citizens
> confined; but for a supposedly free and efficient economy like Britains,
> the wastefulness resulting both directly and indirectly from the Security
> Services activities is simply criminal, and should never be allowed.
>
> The international dimension means the costs are multiplied many times
> overoer had any sense, then they have surely taken leave of them over the
> last nine years.
>
> Four years of persecution in Canada
>
> The persecution re-started within less than five minutes of my arrival in
> Canada, as documented above, and in the "frequently asked
> questions" article on the website. The words, "if he tries to run away
> well find him" spoken by one of the harassers at Toronto Airport are now
> imprinted on my mind.
>
> A year later I emigrated to Canada, intending to find a job and settle
> there, hoping that MI5s interest in me might dim with time. I did manage
> to find work there, but my hopes of avoiding Security Service interest
> were ground into dust. As detailed above, I saw the same man in November
> 1996 and July 1998, both times in Ottawa. Apart from these encounters,
> there were numerous incidents between 1994 and 1998 of harassment, of an
> identical nature and in most cases using identical words to what had
> occurred in the UK. It became quite clear to me that the permanent
> surveillance and harassment operation which MI5 had subjected me to in
> England was being continued.
>
> For a team of four or five men to be employed overseas must cost a lot
> more than if they operate in their home country. And for MI5 to continue
> the operation for a period of over four years, continuously, must cost
> many hundreds of thousands of pounds. This confirms my belief that the
> state is funding the campaign against mehat the Security Service receives
> current annual funding of #160M. Divided by 1850 staff, works out at
> #86,000. But the unit annual cost of each "watcher" must be much higher
> than this, especially given the frequently mobile and overseas nature of
> their actions of the last few years. A very conservative figure might be a
> little over #100,000 pa for each of a team of five people, or half a
> million pounds per year. For nine years, so far. So the most conservative
> estimate of the surveillance element alone is perhaps four or five million
> pounds since 1990.
>
> This guesstimate is of course theoretical - I am not privy to inside
> details of how MI5 split their funding. But to take some other examples,
> the cost of a US counter-surveillance specialist per day is USD
> 5,000. Even if the agents permanently assigned to me are not of this
> calibre - even if they employ specialists when difficult work planting
> bugs etc is encountered - their salary and support costs must still be
> very high. The individual agents are doing well for themselves as they are
> well-paid to exercise psychopathic instincts which in any sane society
> would see them in prison; but the taxpayers who must fund this terribly
> wasteful exercise are being "done" out of hundreds of thousands of pounds
> each year.
>
> It must be emphasised that the above estimates are highly
> conservative. Besides the surveillance operation, it must carry a high
> cost in man-hours to propagate covert slanders through the population; to
> setup and maintain the "interactive watching" links to TV and radio
> stations, which these organisations continue desparately to "lie and
> deny"; and to induce antipathy in co-workers which would not otherwise
> exist.
>
> Why they are wasting Millions of Pounds on a "Nobody from South London"
>
> As remarked in the prologue to this article, it is really most
> extraordinary that the Security Service spends a chunk of its budget,
> every year for nine years so far, on a meaningless campaign against a
> "nobody from South London". That they are spending such a large amount of
> money has been confirmed to me on several occasions, usually by oblique
> references to "its costing this country millions". The supposed
> "logic" behind the persecution is that MI5 wish to avoid their harassment
> of me, and the involvement of the UK media, to be made public; yet as the
> reader will appreciate that is a circular argument, "theyre doing it
> because they want to keep it secret and avoid humiliation for themselves
> and their country" begs the question, "why did they start doing it in the
> first place?", to which in truth I myself do not know the answer.
>
> Plainly MI5 with its rich budget can afford half a million pounds a year
> to waste on a "nobody from South London". Some time ago I was talking to a
> British surveillance professional on Compuserve who told me "this work
> costs a lot of money and is usally because the person I am following has
> done something (usually criminal) to warrant all this money and time being
> spent." Yet in this particular case it is plainly not the "victims
> fault" that the harassment is taking place. The hate-campaign against me
> is completely the creation of the obsessive psychologies of the MI5 agents
> who have made themselves my persecutors; it is obviously a
> "personal" campaign for them, and for years they misuse taxpayer funding
> to feed their insane, unnatural and fixated fantasies.
>
> 18598
>
>
> --
> Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
> ------->>>>>>http://www.NewsDemon.com<<<<<<------
> Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
- 4
- Useless Google Holding (was Re: Jewke Hatekass)"Luke Tulkas" <email***@***.com> wrote in message news:<email***@***.com>...
> "JTK" <email***@***.com> wrote in message
> news:p0ned.749845$email***@***.com...
>
> >> 2. I don't know if he speaks Yiddish or not. Perhaps you'd provide
> >> information either way. Moreover, speaking various languages makes people
> >> multilingual but not necessarily multinational. I speak English (well,
>
> [snip]
Way back, Google's purchase of old Usenet bulletin boards was probably
a good thing (through purchase, I believe, of Deja News). Now with
the continuing evolution of the Internet - with Blogs and associated
RSS feeds, etc. - this type of forum is becoming largely irrelevant
and should be done away with. I would like to thank all of you
nimrods posting this kind of crap on this board for opening my eyes
completely to this fact. Do you actually regard yourself so highly
that you think that people actually CARE to read your constant
blatherings on this and that nonsense?
Every now and then I return to c.l.j.a. just to see if anything of
interest has been posted - kind of like how I leaf through JDJ to see
if they've managed to write a decent article. This will hopefully be
my last visit unless I end up here by mistake or by habit. Thanks
again.
- 4
- Process.waitFor(): a strange behaviourI have a strange behaviour with the Process.waitFor() method under
linux mdk 10.1 and java 1.4.2.
my jar archive reacha.jar launches an external programm via
Runtime.getRuntime().exec,
as done bellow,
proc = Runtime.getRuntime().exec("rv toto.rvqe");
proc.waitFor();
where rv is a shell that lauches a command eprover as shown bellow
gess 28182 0.2 1.6 218592 12532 pts/2 S<l+ 11:03 0:00 java
-jar reacha.jar test.mch
gess 29561 0.0 0.7 7424 6044 pts/2 S<+ 11:05 0:00
/usr/bin//rv toto.rvqe
gess 29727 0.0 0.1 2880 1424 pts/2 S<+ 11:05 0:00 sh -c
eprover ....
gess 29728 99.6 3.3 27376 26300 pts/2 R<+ 11:05 3:03 eprover
...
Sometime, when the eprover command spends a lot of time, and ends after
some minutes,
the method waitFor() does not seem to catch the end of the programm
and does not stop to wait...
gess 28182 0.2 1.6 218592 12532 pts/2 S<l+ 11:03 0:00 java
-jar reacha.jar test.mch
gess 29561 0.0 0.7 7424 6044 pts/2 S<+ 11:05 0:00
/usr/bin//rv toto.rvqe
When I launch by hand the programm rv, it stops alone after the end of
the eprover as shown bellow
gess 522 0.0 0.7 7424 6044 pts/2 S<+ 12:02 0:00 rv
toto.rvqe
gess 688 0.0 0.1 2876 1420 pts/2 S<+ 12:02 0:00 sh -c
eprover ...
gess 689 99.6 2.6 21436 20340 pts/2 R<+ 12:02 1:06 eprover
...
And next no more reference to rv by the ps aux command
Thank a lot for your help.
- 7
- portal library needed ?Hi all ,
I am trying to build a portal which will consist of functions like log
in , user management and some cms stuff and will probably develop more in
the future. So I am trying to search for some portal building library. Has
anyone try one of these portal library like jetspeed, jPorta, liferay ... ?
Is it really that useful ? On what basis should I use one ? As i think the
learning curve maybe quite large that I am sure i can build faster without
it. But I am not sure if I would need it when I further develop the site.
And can anyone share some pros and cons of the library.
Thanks.
Perseus
- 7
- 9
- Child question + illegal start of expression errorI have a form with a question and child questions
eg q1 program - Yes/no
q2 web; desktop
q3 java; .net; #C
My form is:
Q6a: Waterproblem (yes/NO)
Q6b: Current - radiobutton (curent, 1-5 years)
Q6c: Location Home (yes/No); Garden (Yes/No); common (yes/no)
If user selects Q6a = Yes (1)
....
Q6c Home (0/1); Garden (0/1); common (0/1)
I want to check, if user selects Yes for Q6a, then they need
select 1 from Q6c.
If they don't select one choice, want to have a simple error warning.
Yes = 1 No = 0
The code shows an illegal start of expression error????
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
if( page8.getWasteWaterProblem() == 1 ) ||
(getWasteWaterLocationProblemHome() == 0) ||
(getWasteWaterLocationProblemGarden() == 0) ||
(getWasteWaterLocationProblemCommonArea() ==0){
validationResultPage8.addWarning("WasteWaterProlemHome", "warning for
WasteWaterProlemHome from type 6c");
}
- 9
- Disappearing JVM - strange errorHello,
I'm having a very strange problem in one of my applications. This is
what's happening:
A few JVMs crash without giving any clues as to what is happening. No
error messages, no stack traces, no core dumps. Nothing. Nada. They
just disappear.
I'm running on Windows 2000 and I had the same problem using JDKs
1.3.1_07 and 1.3.1_08. Sometimes I also notice a Windows error dialog
say that the "Application log is full" but I'm not sure it is related
(because when the problem happens and the dialog is NOT there we can't
see any entries in the application log).
The application is a JBoss server process which is part of a cluster.
In the process we have a RMI application running. The nodes that crash
are the nodes where this RMI client/server is deployed. When the app
server process starts we bind the RMI server stub in to the JNDI tree
and this server object communicates with a number of different
applications.
I suspect that this could be related to RMI (distributed gc, maybe?)
or the fact that this service running within the JBoss process is
multi-threaded (relies heavily on waits and notifies). But I don't
really know. The process simply disappears.
We have deployed the RMI service in different machines to rule out the
possibility of hardware failure but the crash happened anyway.
We have a memory monitor that checks the memory usage every 30
seconds. The logs show that the memory usage should not be a problem.
It is possible, though, that we have a memory spike that takes less
than 30 seconds to show up and crash the system in such a dramatic
way.
Has anyone here ever experienced or seen anything like this?
Thanks in advance for any help.
JS
- 11
- NoClassDefFound puzzleNoClassDefFound is my least favourite error message. This one has me
stumped. I have been very sick the last few days and my brain in not
yet fully engaged, so I hope it is something simple.
I compile this fine, but when I run it, it says class
com.mindprod.example.TestProgessFilter is not defined.
The program seems too simple to have a NoClassDefFound problem.
package com.mindprod.example;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* @author Roedy Green, Canadian Mind Products
* @version 1.0, 2007-08-03 Created with IntelliJ IDEA.
*/
public class TestProgessFilter extends FilterInputStream {
/**
* tracks how many bytes we have read so far
*/
long progress;
// -------------------------- PUBLIC INSTANCE METHODS
--------------------------
/**
* Constructor
*
* @param in input stream to progress monitor
*/
public TestProgessFilter( InputStream in )
{
super( in );
}
/**
* Reads the next byte of data from this input stream.
*/
public int read() throws IOException
{
int ret = super.read();
progress++;
reportProgress();
return ret;
}
/**
* Reads up to byte.length bytes of data from this input stream
into an
* array of bytes.
*/
public int read( byte[] b ) throws IOException
{
int ret = super.read( b );
progress += b.length;
reportProgress();
return ret;
}
/**
* Reads up to len bytes of data from this input stream into an
array of
* bytes.
*/
public int read( byte[] b, int off, int len ) throws IOException
{
int ret = super.read( b, off, len );
progress += len;
reportProgress();
return ret;
}
/**
* Skips over and discards n bytes of data from this input stream.
*
*/
public long skip( long n ) throws IOException
{
long ret = super.skip( n );
progress += n;
reportProgress();
return ret;
}
// -------------------------- OTHER METHODS
--------------------------
/**
* report the progress to the user
*/
private void reportProgress()
{
// this is a dummy routine. A real version would send an event
// to a progress meter.
System.out.println( progress );
}
// --------------------------- main() method
---------------------------
/**
* test driver
*
* @param args arg[0] is UTF-8 filename to read
*/
public static void main( String args[] )
{
try
{
// O P E N
FileInputStream fis = new FileInputStream( new File( args[
0 ] ) );
TestProgessFilter tpfis = new TestProgessFilter( fis );
InputStreamReader eisr = new InputStreamReader( tpfis,
"UTF-8" );
BufferedReader br = new BufferedReader( eisr, 400/*
buffsize */ );
// R E A D
while ( true )
{
if ( br.readLine() == null )
{
// line == null means EOF
break;
}
}
// C L O S E
br.close();
}
catch ( Exception e )
{
System.err.println( e );
e.printStackTrace( System.err );
}
}
}
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
- 11
- A strange linux command execution problem from ProcessHi All,
I am using Process class to run scripts on a Fedora Core Linux
bash shell
All of my scripts are running except tho one in which i am using diff
command.
I am using simple diff command. My script is
-------------------------------------------------------------------------------------
#/bin/sh
if [ $# -eq 0 ];
then
echo "Usage: newFile oldFile outputFile"
exit
fi
FILE1=$1
FILE2=$2
OUTPUT_FILE=$3
echo "diff -c $FILE1 $FILE2 > $OUTPUT_FILE"
#diff -c $FILE1 $FILE2 > $OUTPUT_FILE
diff -c $FILE1 $FILE2 > $OUTPUT_FILE
------------------------------------------------------------------------------------------------
And I am also consuming the error and output streams so not blocking
the process.
the process returns with exit value > 0.
It would be a great help to me. If you help me solve this problem.
-Thanks,
Ratnesh.
- 11
- default value of data member.Hi
I have a problem about default value of data member!
+++++++ cut here++++++
class CComputer
{
private double cpu=3.0;
private double memory=1.0;
public void set(double c)
{
if(c<0)
System.out.println("Input cpu error, cpu is default value");
else
this.cpu=c;
}
public void set_memory(double m)
{
if(m<0)
System.out.println("Input memory error, memory is default
value");
else
{
memory=m;
show_memory();
}
}
public void set(double c,double m)
{
set(c);
set_memory(m);
}
void show_cpu()
{
System.out.println("cpu="+this.cpu);
}
void show_memory()
{
System.out.println("memory="+this.memory);
}
void show_all()
{
this.show_cpu();
this.show_memory();
}
}
public class bbb
{
public static void main(String args[])
{
CComputer c1=new CComputer();
c1.set(-3.5,1.5);
c1.show_all();
c1.set(-3.5,-2.0);
c1.show_all();
c1.set(-3.5);
c1.show_all();
}
}
+++++++
The output of "c1.set(-3.5,-2.0);" shows memory=1.5.
The output of " c1.set(-3.5);" also shows memory=1.5;
Why? I thought memory should be default value, i.e. 1.0.
Thank you in advance.
Mike
- 11
- R: JTable and db connectionThere is a good example in JTable example ad www.sun.com. By the way, it is
based on the idea of copying all the records in a Vector array, and then
send all to the JTable...
IMHO this isn't a good approach, but it is a good example to understand the
JTable
Bye
Giuseppe
Liguori Ferdinando <email***@***.com> wrote in message
bhl1va$55u$email***@***.com...
>
> Could you help me to definy a trouble.
> I wish see data retring db connection in a JTable.
> Could you mailing an example.
> Thanks.
>
>
- 11
- Ussgin JUnit add ons to get the superclass
Hi, I am using J-UNIT to test my code. I have some instances where
the class heirarchy is makeing my shake my head as to how to test.
Hope I can explain this so that someone can help...
Here Goes . I have a class 'A', with a private attribute 'attrib', and a
public accessor 'getAttrib'.
Now there is another class, 'B' which is derived from 'A', however, it
also has it's own private attribute 'attrib', and a public accessor
'getAttrib'.
We have software that loads A & B from XML Files, and i am trying to
verify that they are working correctly (later on these classes will be
persisted in a database, so I want to make sure that I can save and load
them correctly).
What i am trying to do is find out what is stored in 'A's attrib.
Sort of like this :
// The XML files holds teh data for both the super class and the sub
class
// The returned object is of Class 'B'
A myA = B.loadFromXMLFile ( "FileName.xml" ) ;
// Works Great, But how do i get to the getAttrib of the A object
(super class) ?
assertEquals ( "attrib", 123, myA.getAttrib () ) ;
Now is there a way to get the attribute for the attrib of 'A' ?
Using the NetBeans debugger I can se the value for attrib= 5
is there a way to do something like the following ?
// This does not work, but is there any way to acheive the
// Same results ?
A theRealA = PrivateAccessor.getField( myA, "super" ) ; // ??
// and then
assertEquals ( "attrib", 5, theRealA.getAttrib () ) ;
Thanks in Advance !
Joe
- 15
- Java to C++ converterHi,
I am looking for Java to C++ converter tool. Any existing tool available?
Thanks for your help in advance.
- 16
- How to Escape a Single Quote in Java 1.5 javax.xml.xpath.* ?Hi everybody,
How to escape a single quote in java 1.5 javax.xml.xpath XPath queries?
Eg. meta[@name='Tom Jastrzebski's question']
I have tried numerous approaches that typically work but none of them did.
Does anybody KNOW how to do it?
Thanks in advance.
Tom
- 16
- I write Tic-Tac-Toe in JavaThis is the most sophisticated game known to mankind and I'm not sure
if Java is good enough for it, but I'm trying anyway.
|
| Author |
Message |
Mike Schilling

|
Posted: 2004-6-10 7:14:00 |
Top |
java-programmer, Infinite loops in hashCode() and equals()
What do you think the following fragment prints?:
List l = new ArrayList();
l.add(l);
System.out.println(l.hashCode());
Trick question. The result is an infinite recursion (i.e. a stack
overflow), since the hash code for a List is calculated from the hash codes
of its members.
Likewise, the following causes an infinite recursion, since lists are
defined to be equal when they have the same members.
List l1 = new ArrayList();
List l2 = new ArrayList();
l1.add(l2);
l2.add(l1);
System.out.println(l1.equals(l2));
These cases are simple to spot, but the same situation could occur with any
cyclic graph of objects that compute hash code and/or equality based on the
values of their members. Also, equals() and hashCode() are often called
implicitly, for instance when adding an object to a HashSet or HashMap.
I don't see any way this could be addressed other than by keeping track of
which objects have already been processed by the current hashCode() or
equals() call, and there's no way to do that without changing the method
signatures, to, say, add a Set:
in Object:
public final int hashCode() {
return hashCode(new HashSet());
}
public final int hashCode(Set processed)
{
if (processed.contains(this)) {
return System.identityHashCode(this);
}
else {
processed.add(this);
return this.calculateHashCode(processed);
}
}
public int calculateHashCode(processed) {
return return System.identityHashCode(this);
}
with calculateHashCode(Set) being the method that classes can override and
hashCode(Set) the method List et al. call on their members. And that is a
pipe dream, since it isn't possible to make this sort of incompatible change
at this late date.
|
| |
|
| |
 |
megagurka

|
Posted: 2004-6-10 16:23:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Mike Schilling" <email***@***.com> wrote in message news:<gRMxc.68838$email***@***.com>...
> What do you think the following fragment prints?:
>
> List l = new ArrayList();
> l.add(l);
> System.out.println(l.hashCode());
>
> Trick question. The result is an infinite recursion (i.e. a stack
> overflow), since the hash code for a List is calculated from the hash codes
> of its members.
>
> Likewise, the following causes an infinite recursion, since lists are
> defined to be equal when they have the same members.
>
> List l1 = new ArrayList();
> List l2 = new ArrayList();
>
> l1.add(l2);
> l2.add(l1);
>
> System.out.println(l1.equals(l2));
>
> These cases are simple to spot, but the same situation could occur with any
> cyclic graph of objects that compute hash code and/or equality based on the
> values of their members. Also, equals() and hashCode() are often called
> implicitly, for instance when adding an object to a HashSet or HashMap.
Hmmm, I can't think of a case where this problem would occur, so I
don't think there is a need for a solution. If object A reference
another object B you don't include B in A.equals() (or A.hashCode()),
unless B is part of A (composition). And in that case B is clearly not
a part of A, so there is no cycle. Can you provide a real world
example where this problem occurs?
/Jesper Nordenberg
|
| |
|
| |
 |
Andy Fish

|
Posted: 2004-6-10 18:39:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Jesper Nordenberg" <email***@***.com> wrote in message
news:email***@***.com...
> "Mike Schilling" <email***@***.com> wrote in message
news:<gRMxc.68838$email***@***.com>...
> > What do you think the following fragment prints?:
> >
> > List l = new ArrayList();
> > l.add(l);
> > System.out.println(l.hashCode());
> >
> > Trick question. The result is an infinite recursion (i.e. a stack
> > overflow), since the hash code for a List is calculated from the hash
codes
> > of its members.
> >
> > Likewise, the following causes an infinite recursion, since lists are
> > defined to be equal when they have the same members.
> >
> > List l1 = new ArrayList();
> > List l2 = new ArrayList();
> >
> > l1.add(l2);
> > l2.add(l1);
> >
> > System.out.println(l1.equals(l2));
> >
> > These cases are simple to spot, but the same situation could occur with
any
> > cyclic graph of objects that compute hash code and/or equality based on
the
> > values of their members. Also, equals() and hashCode() are often called
> > implicitly, for instance when adding an object to a HashSet or HashMap.
>
> Hmmm, I can't think of a case where this problem would occur, so I
> don't think there is a need for a solution. If object A reference
> another object B you don't include B in A.equals() (or A.hashCode()),
> unless B is part of A (composition). And in that case B is clearly not
> a part of A, so there is no cycle. Can you provide a real world
> example where this problem occurs?
Although mike's examples aren't necessarily real-world ones, I don't see any
reason they couldn't appear in real life
having an arrayList contain itself seems a perfectly reasonable thing to do
when manipulating complex data structures (though the only example I can
think of off hand is trying to compute an empirical solution to russell's
paradox ;-). And computing the hashcode of an ArrayList also seems entirely
reasonable.
I would say it's a bug in the implementation of ArrayList.HashCode()
>
> /Jesper Nordenberg
|
| |
|
| |
 |
IkRhcmlvIChkcmlua2luZyBjb++sgGVlIGluIHRoZSBv76yDY2XigKYpIg

|
Posted: 2004-6-11 0:26:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
Andy Fish wrote:
> I would say it's a bug in the implementation of ArrayList.HashCode()
The Java List specification says:
Note: While it is permissible for lists to contain
themselves as elements, extreme caution is advised:
the equals and hashCode methods are no longer
well defined on a such a list.
- Dario
|
| |
|
| |
 |
John C. Bollinger

|
Posted: 2004-6-11 0:48:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
Andy Fish wrote:
> Although mike's examples aren't necessarily real-world ones, I don't see any
> reason they couldn't appear in real life
>
> having an arrayList contain itself seems a perfectly reasonable thing to do
> when manipulating complex data structures (though the only example I can
> think of off hand is trying to compute an empirical solution to russell's
> paradox ;-). And computing the hashcode of an ArrayList also seems entirely
> reasonable.
>
> I would say it's a bug in the implementation of ArrayList.HashCode()
I would say that the following excerpt from List's class-level Javadocs
is precisely to the point:
====
Note: While it is permissible for lists to contain themselves as
elements, extreme caution is advised: the equals and hashCode methods
are no longer well defined on a such a list.
====
List defines the algorithms for List implementations' hashCode() and
equals() methods in terms of their elements, which significantly eases
some applications. This is purposeful. I think it is in general _not_
a very reasonable thing to do to add a List to itself, and I would be
very interested in even a hypothetical scenario where it would make
sense. I would be especially interested in such a scenario where in
addition there is no good workaround. Until I see such I'll agree with
Jesper that this looks like a theoretical problem that need not occur in
practice.
John Bollinger
email***@***.com
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2004-6-11 3:43:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"John C. Bollinger" <email***@***.com> wrote in message
news:caa3bs$b9r$email***@***.com...
>
> List defines the algorithms for List implementations' hashCode() and
> equals() methods in terms of their elements, which significantly eases
> some applications. This is purposeful. I think it is in general _not_
> a very reasonable thing to do to add a List to itself, and I would be
> very interested in even a hypothetical scenario where it would make
> sense. I would be especially interested in such a scenario where in
> addition there is no good workaround. Until I see such I'll agree with
> Jesper that this looks like a theoretical problem that need not occur in
> practice.
First, note that this behavior doesn't depend upon a List being a member of
itself. Create a graph of objects that have value-like semantics for
equality (and thus for hash code). This includes all Lists, Sets and Maps.
If there are any cycles in the graph, the result of hashCode() is an
infinite loop. Arguing that there will never be cycles in a well-designed
application is a bit like arguing that reference counting works as well as a
true GC, since cycles, which is where reference counting breaks down, should
be avoided.
Anyway, this came up while investigating automated generation of classes to
represent types in SOAP messages. These classes would have no notion of
identity, so value semantics are indicated: two objects received in
different messages are equal if all of their values are equal. hashcode()
and equals() should be generated in the obvious way, by iterating over the
members of the class. But what happens if there's a cycle (which is
possible in encoded SOAP messages, though not in literal ones)? How do you
avoid the infinite loop? Well, let's see how containers avoid it...
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2004-6-11 3:44:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Dario (drinking co铿?ee in the o铿fce??" <email***@***.com> wrote in
message news:caa29s$pkt$email***@***.com...
> Andy Fish wrote:
>
> > I would say it's a bug in the implementation of ArrayList.HashCode()
>
> The Java List specification says:
> Note: While it is permissible for lists to contain
> themselves as elements, extreme caution is advised:
> the equals and hashCode methods are no longer
> well defined on a such a list.
Less weaselly wording would have been: "Doing so can lead to unavaoidable
infinite recursion."
|
| |
|
| |
 |
John C. Bollinger

|
Posted: 2004-6-11 7:10:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
Mike Schilling wrote:
> "John C. Bollinger" <email***@***.com> wrote in message
> news:caa3bs$b9r$email***@***.com...
>
>
>>List defines the algorithms for List implementations' hashCode() and
>>equals() methods in terms of their elements, which significantly eases
>>some applications. This is purposeful. I think it is in general _not_
>>a very reasonable thing to do to add a List to itself, and I would be
>>very interested in even a hypothetical scenario where it would make
>>sense. I would be especially interested in such a scenario where in
>>addition there is no good workaround. Until I see such I'll agree with
>>Jesper that this looks like a theoretical problem that need not occur in
>>practice.
>
>
> First, note that this behavior doesn't depend upon a List being a member of
> itself. Create a graph of objects that have value-like semantics for
> equality (and thus for hash code). This includes all Lists, Sets and Maps.
> If there are any cycles in the graph, the result of hashCode() is an
> infinite loop.
Acknowledged.
> Arguing that there will never be cycles in a well-designed
> application is a bit like arguing that reference counting works as well as a
> true GC, since cycles, which is where reference counting breaks down, should
> be avoided.
Hold on a moment there. I certainly wouldn't argue for a minute that a
well-designed application wouldn't have cycles of references. I would,
however, claim that I currently see no use for such a cycle in which all
members have the kind of value-like semantics that we're discussing.
Whether a List is directly or indirectly a member of itself makes little
difference -- neither makes sense in any practical application as far as
I can see.
> Anyway, this came up while investigating automated generation of classes to
> represent types in SOAP messages. These classes would have no notion of
> identity, so value semantics are indicated: two objects received in
> different messages are equal if all of their values are equal. hashcode()
> and equals() should be generated in the obvious way, by iterating over the
> members of the class. But what happens if there's a cycle (which is
> possible in encoded SOAP messages, though not in literal ones)?
I know enough about SOAP to find that confusing, but not enough to be
certain whether I really ought to be confused. Are you talking about
types defined via XML Schema, to be used in schemas for SOAP message
bodies? IIRC, type _definitions_ can be recursive. Type
_implementations_, on the other hand, cannot be recursive because XML
documents are flat. (Or they're tree-shaped, if you prefer; you still
can't get recursion.)
> How do you
> avoid the infinite loop?
If I understand correctly (and quite possibly I don't) then you don't
need to worry about it.
> Well, let's see how containers avoid it...
Gotcha. The point that we have now beaten to death being that they
don't. My further point being that they probably don't need to do for
any sensible application I can imagine. The same applies to your
analogous XML type classes as far as I can tell from your brief description.
John Bollinger
email***@***.com
|
| |
|
| |
 |
xarax

|
Posted: 2004-6-11 8:54:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Mike Schilling" <email***@***.com> wrote in message
news:gRMxc.68838$email***@***.com...
> What do you think the following fragment prints?:
>
> List l = new ArrayList();
> l.add(l);
> System.out.println(l.hashCode());
>
> Trick question. The result is an infinite recursion (i.e. a stack
> overflow), since the hash code for a List is calculated from the hash codes
> of its members.
>
> Likewise, the following causes an infinite recursion, since lists are
> defined to be equal when they have the same members.
>
> List l1 = new ArrayList();
> List l2 = new ArrayList();
>
> l1.add(l2);
> l2.add(l1);
>
> System.out.println(l1.equals(l2));
>
> These cases are simple to spot, but the same situation could occur with any
> cyclic graph of objects that compute hash code and/or equality based on the
> values of their members. Also, equals() and hashCode() are often called
> implicitly, for instance when adding an object to a HashSet or HashMap.
>
> I don't see any way this could be addressed other than by keeping track of
> which objects have already been processed by the current hashCode() or
> equals() call, and there's no way to do that without changing the method
> signatures, to, say, add a Set:
>
> in Object:
>
> public final int hashCode() {
> return hashCode(new HashSet());
> }
>
> public final int hashCode(Set processed)
> {
> if (processed.contains(this)) {
> return System.identityHashCode(this);
> }
> else {
> processed.add(this);
> return this.calculateHashCode(processed);
> }
> }
>
> public int calculateHashCode(processed) {
> return return System.identityHashCode(this);
> }
>
> with calculateHashCode(Set) being the method that classes can override and
> hashCode(Set) the method List et al. call on their members. And that is a
> pipe dream, since it isn't possible to make this sort of incompatible change
> at this late date.
>
Not infinite recursion, because you don't have
infinite memory. You will elicit a stack overflow
exception.
|
| |
|
| |
 |
megagurka

|
Posted: 2004-6-11 16:14:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Andy Fish" <email***@***.com> wrote in message news:<QSWxc.543$email***@***.com>...
> Although mike's examples aren't necessarily real-world ones, I don't see any
> reason they couldn't appear in real life
>
> having an arrayList contain itself seems a perfectly reasonable thing to do
> when manipulating complex data structures (though the only example I can
> think of off hand is trying to compute an empirical solution to russell's
> paradox ;-). And computing the hashcode of an ArrayList also seems entirely
> reasonable.
>
> I would say it's a bug in the implementation of ArrayList.HashCode()
Although ArrayList could be designed to solve this problem by using
thread local variables and sets, it's not worth the effort (and
performance hit) because I can't think of, and you haven't presented,
a case where cyclic hash code calculation would be useful. It's better
to document that object cycles are not supported in the current
implementation.
/Jesper Nordenberg
|
| |
|
| |
 |
megagurka

|
Posted: 2004-6-11 16:27:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"Mike Schilling" <email***@***.com> wrote in message news:<8R2yc.69301$email***@***.com>...
> "John C. Bollinger" <email***@***.com> wrote in message
> news:caa3bs$b9r$email***@***.com...
>
> >
> > List defines the algorithms for List implementations' hashCode() and
> > equals() methods in terms of their elements, which significantly eases
> > some applications. This is purposeful. I think it is in general _not_
> > a very reasonable thing to do to add a List to itself, and I would be
> > very interested in even a hypothetical scenario where it would make
> > sense. I would be especially interested in such a scenario where in
> > addition there is no good workaround. Until I see such I'll agree with
> > Jesper that this looks like a theoretical problem that need not occur in
> > practice.
>
> First, note that this behavior doesn't depend upon a List being a member of
> itself. Create a graph of objects that have value-like semantics for
> equality (and thus for hash code). This includes all Lists, Sets and Maps.
> If there are any cycles in the graph, the result of hashCode() is an
> infinite loop. Arguing that there will never be cycles in a well-designed
> application is a bit like arguing that reference counting works as well as a
> true GC, since cycles, which is where reference counting breaks down, should
> be avoided.
That is not a valid comparison, I can easily give an example in which
a object reference cycle occurs naturally (parent-child) and a
reference counting GC would fail. Can you give an example where a
cyclic hash code calculation would occur?
> Anyway, this came up while investigating automated generation of classes to
> represent types in SOAP messages. These classes would have no notion of
> identity, so value semantics are indicated: two objects received in
> different messages are equal if all of their values are equal. hashcode()
> and equals() should be generated in the obvious way, by iterating over the
> members of the class.
Not all class members should be included in the calculation of a hash
code, some "weak" references are created for traversal and
optimization (for example a parent reference in a child). Your cycle
can probably be broken by removing some member that shouldn't be
included in your hash code calculation. You should ask yourself if the
members you include in your hash code calculation for an object really
is a part of the object.
/Jesper Nordenberg
|
| |
|
| |
 |
Mike Schilling

|
Posted: 2004-6-12 12:47:00 |
Top |
java-programmer >> Infinite loops in hashCode() and equals()
"John C. Bollinger" <email***@***.com> wrote in message
news:caapo4$k7l$email***@***.com...
> Mike Schilling wrote:
>
> > "John C. Bollinger" <email***@***.com> wrote in message
> > news:caa3bs$b9r$email***@***.com...
> >
> >
> >>List defines the algorithms for List implementations' hashCode() and
> >>equals() methods in terms of their elements, which significantly eases
> >>some applications. This is purposeful. I think it is in general _not_
> >>a very reasonable thing to do to add a List to itself, and I would be
> >>very interested in even a hypothetical scenario where it would make
> >>sense. I would be especially interested in such a scenario where in
> >>addition there is no good workaround. Until I see such I'll agree with
> >>Jesper that this looks like a theoretical problem that need not occur in
> >>practice.
> >
> >
> > First, note that this behavior doesn't depend upon a List being a member
of
> > itself. Create a graph of objects that have value-like semantics for
> > equality (and thus for hash code). This includes all Lists, Sets and
Maps.
> > If there are any cycles in the graph, the result of hashCode() is an
> > infinite loop.
>
> Acknowledged.
>
> > Arguing that there will never be cycles in a
well-designed
> > application is a bit like arguing that reference counting works as well
as a
> > true GC, since cycles, which is where reference counting breaks down,
should
> > be avoided.
>
> Hold on a moment there. I certainly wouldn't argue for a minute that a
> well-designed application wouldn't have cycles of references. I would,
> however, claim that I currently see no use for such a cycle in which all
> members have the kind of value-like semantics that we're discussing.
> Whether a List is directly or indirectly a member of itself makes little
> difference -- neither makes sense in any practical application as far as
> I can see.
>
> > Anyway, this came up while investigating automated generation of classes
to
> > represent types in SOAP messages. These classes would have no notion of
> > identity, so value semantics are indicated: two objects received in
> > different messages are equal if all of their values are equal.
hashcode()
> > and equals() should be generated in the obvious way, by iterating over
the
> > members of the class. But what happens if there's a cycle (which is
> > possible in encoded SOAP messages, though not in literal ones)?
>
> I know enough about SOAP to find that confusing, but not enough to be
> certain whether I really ought to be confused. Are you talking about
> types defined via XML Schema, to be used in schemas for SOAP message
> bodies? IIRC, type _definitions_ can be recursive. Type
> _implementations_, on the other hand, cannot be recursive because XML
> documents are flat. (Or they're tree-shaped, if you prefer; you still
> can't get recursion.)
No, encoded SOAP messages can express graphs with cycles. Attributes are
used to express directed references from one object to another, and the
graph can be arbitrarily complex.
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- jtreetabledear java professional,
i want to create a grid using jtreetable. i find the sample code in
the java.sun.com. but it is trickly to understand for me. do you
have any code
(simple code) for using the jtreetable ? i want to simple jtreetable
example program with sample data. do you have the code please send me
to my mail id
email***@***.com.
i also search in the net. but i only very less no. sample code related
to jtreetable. that code also so tricky. do you know any link that
contains simple
jtreetable program?
with regards,
balamurugan se
- 2
- Just a Great Big Scrollable LineHello,
I am a bit new to java and the java swing GUI.
I am writing a JApplet.
What I am trying to do is draw a line (say from (0, 0) to (1000, 1000)) and
have the applet supply automatic scrollbars so that the user can see the
whole line (sounds stupid - I know, but its a step in my direction).
Anyway, I tried to inherit from a JLabel, change the inherited comopnent's
paintComponent method to draw a line and put the inherited component in a
JScrollPane. However, this only resulted in a Line which was only partially
seen and no scrollbars. Moreover, I discovered that if I just add text to
my label with the setText method then I get auto scrollbars if I make the
applet smaller than the text size. This means that the setText method is
doing something that defines it's boundaries for the JScrollPane to react
to. So, my question is: How do I tell the JScrollPane that my inherited
JLabel is 1000x1000 (and not just the size of the text)?
Thanks,
Aviv.
- 3
- How to get current jar pathHi! I'm working on an application that should run on an usb pen using
an embedded Derby DB. I need the DB to be on the USB pendrive with the
application.
Pen filesystem should look like this:
/
- application/
- application.jar
- lib/
- embeddedDB
using "user.dir" system property i get the path from where the jar has
been launched, while I need the path where the jar is. How can I do?
- 4
- extract numbers from picture?is this called pattern matching or AI in java? how can you extract a number
that is on a jpeg or bmp/gif/tiff ? is there any java package doing this?
thanks
- 5
- How do i do if-else condition in Struts ?How do i do if-else condition in Struts ?
logic:equal does not do it . how struts tag could be used in the JSP
page for an if-else condition ?
how to do it ?
Can anybody provide an example ?
- 6
- Simple question for those who understand recursion well. Please help.I have a tree represented as a linked list of simple objects
(nodeId/parentId pairs) where the root node is the 1st element in the
list. The other nodes are in somewhat random order. The parentId refers
to the parent node.
I want to convert it into a list where the values are in pre-order.
I.e., I want to get this list as follows: ABCDEFGHIJ (see graph below).
I.e., get the 1st node, put in in the list. If it has children, go
through them one by one, get their child nodes, then put the parent in
the list, then the leftmost first, and go from there. I.e., so that
it's ordered in my linked list like this by (letters represent nodeId):
A
/ \
B J
/ | \
C H I
|
D
/|\
E F G
I created the following recursive method but it does not work
correctly. For example, it places the nodes A then B and then J into
the list first, rather than getting to J after adding all the child
nodes. "isOnTheList" checkes whether the item is already in the list.
"getImmediateChildren" returns the list of immediate child nodes
ordered by nodeId
Note: the empty list is passed to the method and is populated with the
result:
public static void orderTree(List list, List treeList) {
if(treeList == null || treeList.size() == 0)
return;
Node child = null; List children = null;
for(int i = 0; i < treeList.size(); i++) {
node = (Node) treeList.get(i);
// get list of children for this node
children = getImmediateChildren(node, treeList);
// if the node is not yet on the list, add it
if(! isOnTheList(node, list) )
list.add(cat);
// if it has children, recurse to add all other nodes
if(children.size() > 0) {
orderTree(list, children);
}
}
}
Any idea what the problem is?
Thanks.
- 7
- Re:Correct use of exceptionsWhen we talk about exception, it means that in some situation which we think
that it should works this way, but it isn't. For example, when we write
something to connect to remote SMTP server, we assume that the remote server
should be available but actually it is down... In this case, the exception
happened... So we need the exception handling to show our error message to
user and log the error.
Hope this helps!
Guoqi Zheng
http://www.big8reader.com
- 8
- package and jar filesHi,
I am new to Java. I hope someone can give me a hint.
What is the difference between package and jar files and do you use them ?
thanks
John
- 9
- ToolTip for Graphical ItemsHello,
I'm trying to make a tool tip pop up whenever the user does a
mouse-over on a filled rectangle that I've drawn on the screen. I have
no trouble creating the rectangle
Rectangle test = new Rectangle();
And it seems like there should be something like
test.setToolTipText("rectangle"), but as far as I can tell, there's
nothing like that. Is there some way to do this?
Thanks,
Ben
- 10
- Ant Javadoc failure when building help.I'm getting this error when trying to compile javadoc in ant from my
buildxml:
Any ideas?
C:\umg\java\web\dbtest\WEB-INF\src\build.xml:64: Javadoc failed:
java.io.IOException: CreateProcess: javadoc.exe -d
C:\umg\java\web\dbtest\WEB-INF\doc\api -classpath
C:\umg\java\web\lib\servlet-api.jar;C:\umg\java\web\lib\struts.jar;C:\umg\ja
va\lib\umg-db.jar -sourcepath
C:\umg\java\web\dbtest\WEB-INF\src -version -author
java.com.umusic.ecrm.web.test error=2
what's error=2????
this is in my build.xml:
<!-- Build Javadoc documentation -->
<target name="javadoc"
description="Generate JavaDoc API docs">
<delete dir="./doc"/>
<mkdir dir="./doc"/>
<javadoc sourcepath="./src"
destdir="./doc/api"
packagenames="*"
author="true"
private="true"
useexternalfile="yes"
version="true"
windowtitle="${project.title} API Documentation"
doctitle="<h1>${project.title} Documentation (Version
${project.version})</h1>"
bottom="Copyright © 2003">
<classpath refid="compile.classpath"/>
</javadoc>
</target>
- 11
- My bean doesn't APPEAR on my JSP page!Hi, All!
I have this simple bean (below), and i make the .class using JBuilder 7.0.
I tryed to insert this bean into my JSP page:
<%@ page contentType="text/html; charset=windows-1251" %>
<html>
<head>
<title>
Jsp1
</title>
</head>
<jsp:useBean id="bean0" scope="session" class="bean1.KivaHanTester" />
<jsp:setProperty name="bean0" property="*" />
<body>
<h1>
JBuilder Generated JSP
</h1>
</body>
</html>
BUT I CAN't see this bean, when i open my JSP (IExplorer + Apache).
May be i need to init this bean, like init() or show() i don't know.
Thanks.
SOURCE CODE:
package bean1;
import java.awt.*;
public class KivaHan extends Canvas {
private String msg;
private int width, height;
public KivaHan () {
this ("Coffee: 10 lira");
}
public KivaHan (String s) {
this (s, 200, 200);
}
public KivaHan (String s, int width, int height) {
msg = s;
this.width = width;
this.height = height;
setForeground (Color.cyan);
setFont (new Font ("Serif", Font.ITALIC, 24));
setSize (getPreferredSize());
}
public void paint (Graphics g) {
Dimension d = getSize();
FontMetrics fm = g.getFontMetrics();
int len = fm.stringWidth (msg);
int x = Math.max (((d.width - len) / 2), 0);
int y = d.height / 2;
g.drawString (msg, x, y);
}
public Dimension getPreferredSize () {
return new Dimension (width, height);
}
}
package bean1;
public class KivaHanTester extends java.applet.Applet {
public void init () {
add (new KivaHan());
}
}
- 12
- batch update as a single transactionHi,
I'm doing a JDBC batch update, writing several thousand rows to a single
table. As I understand it a batch update can partially succeed, so some of
my rows might get written and some not. I'd like the batch update to either
fully succeed or completely fail, commit or rollback in other words. Is that
easy to do? I'm pretty new at this.
Thanks,
John
- 13
- Reset button cannot clear fields after displaying error messagesHello
my form extends from ValidatorForm
and making use of validator.xml and validator-rules.xml,
The reset button can clear fields within form
if the submit is not pressed.
If I pressed the submit button and
error messages display on the top of the form.
And then now I click the reset button again,
fields cannot be cleared.
Why is it so?
- 14
- struts form population from an object model...flangelli wrote:
<snip>
> I have a business object model with attributes throughout that are
> mapped to different form beans. Every time that a form bean (jsp) is
> returned to the user's browser, I need to have a place to access my
> object model to retrieve the data from and populate the bean before it
> is displayed. So far it seems that the only time an action class is
> given "command" is AFTER the form submission, I need control on a page
> by page basis to retrieve the values from the object model into the
> bean so the jsp can render the beans values.....anyone had a problem
> similar to this? Thanks in advance - Flangelli
There's nothing which "requires" you to forward to a JSP; you could
just as easily forward to an action. The hitch here is that the
ActionForm will be populated according to the request parameters if
you just perform a forward. The solution is simply to specify
redirect="true" in the forwarding action so that the request
parameters get lost.
Just be careful in your validate method when using this mechanism:
you're users will be irked if the first time they see a page it
contains all manner of error messages. Since you often provide a
reset button on a form, the smart way to approach the situation is
to hold off generating errors if all form fields are blank (or
have the default value).
If this doesn't make perfect sense then repost and I'll dig up
some sample code. Or contact me off-line.
- 15
- UTF 16 (byte[]) <--> String?Hi,
is there a convenient way to convert unicode that's stored in byte array to
java String?
and vice-versa?
e.g. for a single single unicode,
the higher byte would be in byte[0],
lower byte[1]
and byte[2], byte[3] = 0. null terminated
the byte array of unicode is generated from a C program and transfered over
the network ..
looking over the String API doesn't reveal much ... or am I overlooking
something?
Thanks in advance.
|
|
|