<< 28-August-2008 : bevinbot on ##java at freenode [download] [back] >>
 
 
time nick message

00:03

<joedj>

heya folks, trying to install jdk with "sh jdk-6u7-linux-i586.bin", i get "jdk-6u7-linux-i586.bin: line 480: ./install.sfx.26481: No such file or directory" .... any ideas? google was not helpful

00:03

<eidolon>

sounds like a trashed download.

00:04

<joedj>

hrm, i will try again. though i had 2 copies of the file with the exact same size

00:04

<joedj>

no wait, that was the x64 one....*tries again*

00:05

<m0>

Hi, when I have "HashMap<GameMap,Integer> votedMaps", and I want to search for a key, votedMaps.containsKey(myGameMap), it doesn't find the key, but it does exist

00:06

<m0>

I overrided the equals method in GameMap, and placed a break point inside of it, but it never reaches that when it does containskey

00:08

<eidolon>

this totally doesn't make sense. why would even getString() throw that as an error.

00:09

<Levia>

dmlloyd:

00:09

<Levia>

~be dmlloyd

00:09

<javabot>

JDK5+ or piss off!

00:11

<dmlloyd>

that's so old

00:14

<Levia>

hehe

00:15

<eidolon>

BLEAH. well it's working, but all i'm doing is not touching the timestamp column if another condition is set. I'll hax0r on that later.

00:16

<joedj>

nope, wasn't a corrupt download

00:17

<ojacobson>

/me touches eidolon's timestamp.

00:17

<eidolon>

aieee!

00:17

<eidolon>

eidolon is updated to now()

00:17

<eidolon>

'sup owen, how goes the fight?

00:18

<ojacobson>

Kill me now. Then hire my corpse.

00:18

<eidolon>

mm, productivity in the afterlife.

00:35

<joedj>

FWIW, my 'No such file or directory' installation error was due to missing ia32-libs package

01:01

<jedir0x>

is there a way in a generic class to determine what type(s) someone inheriting from your class has specified for type variables?

01:04

<b0nn>

why?

01:04

<backtracker>

is there any Java Spanish Channel?

01:24

<TheLorax>

why is that EVERYTHING feels like a global in java? am I using it wrong? Everything is a pointer and there is no const: so how are you supposed to expose class internals without letting a user edit them in bad ways?

01:25

<cheeser>

getter/setter methods.

01:25

<cheeser>

not everything is a pointer.

01:25

<cheeser>

and, yes, it sounds like you're doing it wrong.

01:25

<TheLorax>

I know about built in types...but that's a different story

01:26

<TheLorax>

what if a class you make is small but includes many huge classes? do you have to write getter/setter for all?

01:26

<TheLorax>

is it the only way?

01:26

<adante>

hm

01:26

<cheeser>

it depends on what you want to expose

01:27

<TheLorax>

I'm trying to think of a concrete example...

01:27

<adante>

if i define an anonymous object -- Object foo = new Object() { public void bar() { } } - i get a compile warning saying the method bar() is never used locally... just out of curiousity, how would one use it locally?

01:27

<dmlloyd>

you can't

01:27

<TheLorax>

cheeser, ok, say you have a class with a data array, you want to expose that array but not let people edit it.

01:27

<dmlloyd>

that's the point of the warning :)

01:27

<cheeser>

that doesn't really make sense to do that adante

01:28

<dmlloyd>

unless you use bar() from inside a method that was specified on Object and overridden in your anon subclass

01:28

<cheeser>

right

01:28

<dmlloyd>

or use reflection

01:28

<adante>

right, just figured that out, cheers

01:28

<cheeser>

otherwise you're declaring a method that'll never get used

01:29

<adante>

thanks.. been messing with groovy the past few days, i probably have a bit of an evil/dirty mindset at the moment

01:30

<Algonquian>

TheLorax: you would restrict the access of that array using just methods (ie: getAtIndex(int index)), or to be fancier, make your own immutable List

01:31

<TheLorax>

Algonquian, if you use getAtIndex and your array is non-built-in then you return pointers that can be changed anyway

01:31

<TheLorax>

not to mention, you add a function call

01:32

<dmlloyd>

your notion of "can be changed" is hazy

01:33

<dmlloyd>

whether or not an object is mutable is part of the contract of that object

01:33

<dmlloyd>

e.g. String, BigInteger, etc are immutable

01:33

<dmlloyd>

so returning copies of the reference is no big deal

01:33

<dmlloyd>

if you don't want someone changing an object, you should not make that object changeable in the first place

01:34

<dmlloyd>

failing that, use a wrapper object (Collections.unmodifiableList() and friends are a good example)

01:34

<IronJan>

can anyone tell me the correct channel to ask a question about the SWT? Got an problem designing a GUI.

01:35

<dmlloyd>

~swt

01:35

<javabot>

dmlloyd, swt is the Standard Widget Toolkit - see http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/.../main.html

01:35

<dmlloyd>

no idea

01:36

<cheeser>

well, String is *almost* immuatable

01:36

<cheeser>

P^)=

01:36

<IronJan>

that'S the problem. i'm the only on in there ;)

01:36

<TheLorax>

dmlloyd, the question is about creating objects of existing changeable objects but not letting the use of your new object edit the internals of your new object in a bad way. IE myobject.getinternal.unlockmutex.

01:36

<TheLorax>

the user*

01:37

<dmlloyd>

creating objects of objects?

01:37

<cheeser>

~tell TheLorax about google law of demeter

01:37

<javabot>

TheLorax, http://www.google.com/search?q=law+of+demeter

01:37

<SJrX>

How can you change a string cheeser?

01:37

<TheLorax>

dmead, as in an object that has members of other objects

01:37

<dmlloyd>

your sentence completely did not parse

01:37

<TheLorax>

dmlloyd, ^

01:37

<dmlloyd>

like a collection you mean?

01:37

<dmlloyd>

because java already has those

01:37

<cheeser>

SJrX: myString.hashCode()

01:38

<dmlloyd>

Collection, List, Set, etc

01:38

<TheLorax>

class myNewObject {private otherObject;};

01:38

<svm_invictvs>

SJrX: STrings are immutable.

01:38

<cheeser>

svm_invictvs: almost

01:38

<cheeser>

but for what most people care about, yes, it is.

01:38

<SJrX>

You mean override the hashCode method on a string?

01:38

<dmlloyd>

they are immutable in concept

01:38

<cheeser>

SJrX: no, i mean call it.

01:38

<svm_invictvs>

cheeser: how arent' they? With reflections?

01:38

<SJrX>

What will happen?

01:38

<dmlloyd>

no, he means that hashCode can change the state of the object

01:39

<svm_invictvs>

oh

01:39

<SJrX>

Really?

01:39

<dmlloyd>

iow, it updates the cached hashCode field

01:39

<svm_invictvs>

Why can hashcode change the state of an object?

01:39

<cheeser>

the hash code is lazy init'd

01:39

<SJrX>

Ah

01:39

<svm_invictvs>

Oh

01:39

<SJrX>

I see

01:39

<cheeser>

8^)=

01:39

<dmlloyd>

Ee

01:39

<SJrX>

It only generates it and then caches it when is called

01:39

<SJrX>

neat-o

01:39

<svm_invictvs>

cheeser: so it's like the mutable keyword in C++. There for "innoculous changes"

01:39

<dmlloyd>

no

01:39

<dmlloyd>

there's no compile time assertion of mutability or lack thereof in java

01:40

<cheeser>

or runtime

01:40

<svm_invictvs>

But it's along those lines.

01:40

<dmlloyd>

not really

01:40

<SJrX>

Hmmmmm I have a ServerSocket and get a connection, when I look at the connection RemoteAddr() the address is always 0.0.0.0 I don't understand

01:41

<dmlloyd>

the existence of "mutable" in C++ should give you an idea of how good an idea it is :)

01:41

<SJrX>

how I can get the RemoteAddr()

01:41

<svm_invictvs>

class String { int hashCode = 0; ... public int hashCode() { if (!hashCode) { hashCode = calculateHashCode(); } return hashCode; } }

01:41

<dmlloyd>

SJrX: you get it on the connected Socket, not the ServerSocket

01:41

<svm_invictvs>

Calculating and caching the hash code of the String would be an "innoculous change"

01:41

<SJrX>

dmlloyd that's what it is on

01:41

<dmlloyd>

what does "innoculous" mean

01:41

<SJrX>

actually let me check that

01:41

<dmlloyd>

protects you against polio?

01:42

<SJrX>

I think it means small

01:42

<svm_invictvs>

innocuous

01:42

<SJrX>

and inconsequential

01:42

<svm_invictvs>

Sorry

01:42

<dmlloyd>

anyway an innocuous change is totally subjective

01:42

<svm_invictvs>

I can't spell. But the word, "innocuous" means, "not harmful or injurious"

01:42

<TheLorax>

dmlloyd, yes, and the programmer should be able to define what an innocuous change is.

01:42

<dmlloyd>

I know what the word means, I was just needling you for your typo :)

01:43

<svm_invictvs>

thanks dmlloyd

01:43

<dmlloyd>

~~svm_invictvs dmlloyd

01:43

<javabot>

svm_invictvs, dmlloyd is here to help. Well, not really.

01:43

<svm_invictvs>

~svm_invictvs

01:43

<javabot>

svm_invictvs, I have no idea what svm_invictvs is.

01:43

<dmlloyd>

TheLorax: fine for them. There's still no such keyword in java.

01:43

<dmlloyd>

you can, however, declare a field to be unchangable

01:43

<dmlloyd>

using "final"

01:44

<TheLorax>

dmlloyd, will look up. thanks

01:44

<cheeser>

dmlloyd: as long as that field is a primitive

01:44

<SJrX>

dmlloyd you are correct thanks

01:44

<svm_invictvs>

the field itself is unchangable, not what it may point to :)

01:44

<dmlloyd>

cheeser: er

01:44

<dmlloyd>

what svm_invictvs said

01:44

<svm_invictvs>

final ConstInterfaceOfObject foo;

01:45

<svm_invictvs>

like the difference between const char* and const char* const.

01:45

<svm_invictvs>

;)

01:45

<dmlloyd>

again let's not confuse references and objects

01:45

<dmlloyd>

objects cannot be declared immutable

01:45

<dmlloyd>

period

01:45

<SJrX>

Next question, In my TCP/IP application, I have a Scanner on an input Stream. I need to implement timeouts. Do I a) (Have the master thread every so often see if the thread hasn't done anything, and if so interrupt it?, or is there a way, and if so how, to have my call to .nextLine() block only for a certain amount of time then have a timeout.

01:45

<dmlloyd>

you can make them act that way, and final fields are a handy tool for that

01:45

<svm_invictvs>

dmlloyd: not as a compile time assertion. But certainly through an interface.

01:45

<cheeser>

svm_invictvs: not really

01:46

<cheeser>

at best, you'd have a convention for your project.

01:46

<svm_invictvs>

cheeser: How so?

01:46

<dmlloyd>

SJrX: you can set the socket timeout

01:46

<svm_invictvs>

cheeser: What about the const interface idiom

01:46

<cheeser>

what about it?

01:46

<svm_invictvs>

final ConstInterface foo...

01:46

<cheeser>

i could still cast the reference to the underlying impl and call a setter.

01:46

<svm_invictvs>

Pretty much makes that object immutable.

01:46

<cheeser>

nope

01:46

<SJrX>

dmlloyd in theory I'm responsible for still sending traffic to the client, if it is not responding.

01:46

<svm_invictvs>

cheeser: As you could const_cast in c++

01:47

<svm_invictvs>

cheeser: or use reflection

01:47

<SJrX>

If I detect a timeout I need an open socket connection

01:47

<cheeser>

this isn't c++ so ...

01:47

<dmlloyd>

SJrX: then you'll have to use another thread, or use non-blocking I/O

01:47

<svm_invictvs>

cheeser: but doing so would be an obvious abuse of the interface.

01:47

<dmlloyd>

you could also look at xnio

01:47

<dmlloyd>

~~SJrX xnio

01:47

<javabot>

SJrX, xnio is an NIO replacement framework, which keeps Channels but does away with Selectors, developed by ##java's very own dmlloyd. The project can be found at http://www.jboss.org/xnio - have fun!

01:47

<svm_invictvs>

cheeser: just like using a const_cast.

01:47

<Cow_woC>

hi

01:48

<Cow_woC>

Does anyone know where to get Logback support on IRC? #logback is empty for some reason (the authors used to wait there)

01:48

<r0bby>

Cow_woC: google?

01:48

<SJrX>

dmlloyd is this a drop in replacement for the existing stuff, or something seperate. This project is a learning project for the Java API's, etc... So I'm hesitant on trying non standard stuff.

01:49

<dmlloyd>

it's standard to me :)

01:49

<SJrX>

fair enough

01:49

<dmlloyd>

you could use NIO directly

01:49

<SJrX>

Hmmmmm

01:49

<dmlloyd>

write your own wrapper InputStream for example, which throws an IOException if Selector.select() times out

01:49

<dmlloyd>

but I guarantee you it will be a lot of work

01:50

<dmlloyd>

otherwise, Thread.interrupt() is it

01:50

<SJrX>

Hmmmmm

01:50

<dmlloyd>

and that's a bit hairy too

01:50

<SJrX>

Why is that hairy?

01:50

<dmlloyd>

because now you've got multiple threads

01:50

<SJrX>

Oh no I already had multiple threads

01:50

<dmlloyd>

and if you think that concurrency is a simple thing, you don't understand concurrency :)

01:50

<SJrX>

I think in this application it is fairly simple :P

01:51

<svm_invictvs>

dmlloyd: eh?

01:51

<SJrX>

It's an SMTP server :P

01:51

<Cow_woC>

dmlloyd: it's not as hard as people make it out to be *if* you code it properly

01:51

<svm_invictvs>

dmlloyd: You just have to be leet with concurrency :)

01:51

<Cow_woC>

dmlloyd: the keyword there being *if*

01:51

<dmlloyd>

um, an SMTP server probably wants XNIO or at least NIO if you care at all about scalability

01:51

<svm_invictvs>

Perhaps the worst thing is trying to retrofit multithreaded code into code that wasn't designed for it.

01:51

<SJrX>

I don't care about scalability

01:52

<SJrX>

No buffered input streams, and reading lines off of them from Sockets?

01:52

<SJrX>

~~SJrX nio

01:52

<javabot>

SJrX, nio is http://java.sun.com/javase/6/docs/technotes/guides/io/example/index.html and http://gee.cs.oswego.edu/dl/cpjslides/nio.pdf

01:52

<dmlloyd>

I stand by my statement

01:53

<SJrX>

which statement?

01:53

<dmlloyd>

<dmlloyd> and if you think that concurrency is a simple thing, you don't understand concurrency :)

01:53

<SJrX>

Hmmmmm this is a learning project to replace my own personal mail server

01:54

<dmlloyd>

well, make sure you've read this first:

01:54

<SJrX>

It handles one user maybe 200 messages a day on a system with a load average of 0,0,0. Any complex concurrency stuff will be handled by MySQL

01:54

<dmlloyd>

~~SJrX jcip

01:54

<javabot>

SJrX, jcip is Java Concurrency In Practice, a book focused on implementing threaded and concurrent applications in Java. http://jcip.net/

01:54

<dmlloyd>

and/or this:

01:54

<dmlloyd>

~jmm

01:54

<javabot>

dmlloyd, jmm is the Java Memory Model. See http://tinyurl.com/65v87y (JSR 133), http://tinyurl.com/5k6x27 (FAQ), http://tinyurl.com/ccx52 (Bill Pugh's JMM page), and http://tinyurl.com/26md5p (Implementation Guide for the extra-curious)

01:54

<svm_invictvs>

That's actually an excellent book. And if you can learn from that book, you can take the techniques in that book to other languages.

01:54

<dmlloyd>

the FAQ in particular

01:55

<SJrX>

Do you really think that that is necessary for this project?

01:55

<SJrX>

I just read an RFC and about to read another

01:55

<dmlloyd>

best to learn the right way first

01:55

<svm_invictvs>

><

01:55

<svm_invictvs>

my god damned Xbox keeps red-ringing ><

01:56

<SJrX>

Fair enough, but I learn by doing, and no matter what I do for this project there will almost always be a book to read that will tell me how to do things better.

01:56

<svm_invictvs>

I wish I could figure out what causes that ><

01:56

<dmlloyd>

well I hope your mail server doesn't have multiple CPUs in that case :)

01:57

<dmlloyd>

at least read that FAQ

01:57

<SJrX>

No it doesn't and if your refering to the fact that the locks have to be gained and released for information between threads to be syncronized. I know that.

01:57

<SJrX>

This faq: http://tinyurl.com/5k6x27 ?

01:57

<dmlloyd>

yes

01:58

<SJrX>

was that what you were referring to with the multi-core thing?

01:58

<dmlloyd>

yes, memory visibility is the #1 problem that appears on SMP when running a program that "works" on 1 CPU

01:59

<dmlloyd>

but there are others as well, like race conditions due to assumptions about scheduling and so forth

01:59

<SJrX>

Yeah but all that is done in MySQL

01:59

<svm_invictvs>

barriers!

01:59

<dmlloyd>

all what is done in MySQL?

01:59

<dmlloyd>

you said your app has multiple threads

01:59

<SJrX>

Yeah

02:00

<cheeser>

svm_invictvs: sorry for the delay, but that's a project convention and not enforceable by the VM

02:00

<dmlloyd>

so... you have to arbitrate between them, regardless of the DB

02:00

<SJrX>

It does and each thread really just reads in a piece of mail, and throws it into the DB.

02:00

<dmlloyd>

also, that type of job is very well-suited to Executors as well

02:00

<svm_invictvs>

cheeser: barriers?

02:00

<SJrX>

A connection comes in, the connection is completetly indepodent from the rest of the system at that point, no shared objects or memory, except possibly the socket in the master thread, but even that can be removed.

02:00

<dmlloyd>

~javadoc Executor

02:00

<javabot>

dmlloyd, please see java.util.concurrent.Executor: http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executor.html

02:00

<cheeser>

svm_invictvs: your const interface bit

02:01

<svm_invictvs>

cheeser: oh, yeah.

02:01

<dmlloyd>

~javadoc Executors

02:01

<javabot>

dmlloyd, please see java.util.concurrent.Executors: http://java.sun.com/javase/6/docs/api/java/util/concurrent/Executors.html

02:01

<dmlloyd>

both of those you'll find handy

02:03

<SJrX>

Thanks

02:03

<svm_invictvs>

~wiki

02:03

<javabot>

the ##java channel wiki lives at: http://www.javachannel.net

02:08

<svm_invictvs>

more red rings.

02:08

<svm_invictvs>

><

02:23

<antwaungomez>

If I am writing an object that I want to make multiple instances of, can it have static variables in it?

02:24

<Algonquian>

~~antwaungomez static

02:24

<javabot>

antwaungomez, static is http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html and also see http://mindprod.com/jgloss/static.html

02:24

<Algonquian>

sure

02:28

<antwaungomez>

Algonquian: Ok, I have run into a problem, I just tested it out and realized that, if I have multiple instances of it, the static variables are the same for all of them. I don't want that. Unfortunately, I cannot call the paintComponents function from awt when accessing dynamic variables. What do I do?

02:30

<Algonquian>

fix your code to work with instance variables... it sounds like you're accessing them directly too, you should look at setter/getter methods

02:30

<Algonquian>

you can pastebin example code

02:30

<Algonquian>

~pastebin

02:30

<javabot>

http://pastebin.stonekeep.com

02:38

<lilwik>

I've got a keylistener and I want it to pick up key events no matter where they happen. What's the best way to make that happen?

02:39

<antwaungomez>

Algonquian, thank you so much. You inspired me. I think I have it under control now.

02:48

<DirtyD>

sheesh

03:03

<lard-Vader>

in LinkedBlockingQueue, is there any way to do a peek() which waits if the list is empty :)

03:06

<lilwik>

It doesn't do that already?

03:06

<lilwik>

Why is it called a "blocking" queue, then?

03:10

<s0x>

hey guys, is there a possibility to calculate the width of a string if it is been printed by drawString(...) ?

03:10

<lilwik>

Oh yes, there is. You use FontMetrics.

03:11

<s0x>

lilwik: ahh .. nice thx :)

03:39

<s0x>

another short question .. do anyone knows how to reduce the used characters for a double number i.e. using scientific notation and rounding the coeffizient

03:39

<s0x>

?

03:40

<s0x>

aehh .. of course if i want to print the double value as a strring :)

03:40

<whaley>

~~sox javadoc DecimalFormat

03:40

<javabot>

The user sox is not on ##java

03:40

<whaley>

~~s0x javadoc DecimalFormat

03:40

<javabot>

s0x, please see java.text.DecimalFormat: http://java.sun.com/javase/6/docs/api/java/text/DecimalFormat.html

03:42

<s0x>

ups ... forget my question ^^

03:49

<SJrX>

Anyone have a handy Email Address Validation Class for Java, I have been poring over google but the ones I have found are EE.

03:50

<Xeese>

Ive got one somewhere I wrote validates the mx server as well

03:51

<Xeese>

Or were you just looking for a regex to validate the email?

03:51

<Junior>

mornin`

03:52

<r0bby>

~email regex

03:52

<javabot>

r0bby, email regex is http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html

03:53

<SJrX>

Both would be cool

03:53

<SJrX>

Xeese

03:53

<r0bby>

SJrX: rip that regex :)

03:53

<SJrX>

afaik the actual official RFC 822, is actually not followed and allows things like comments in email addresses etc...

03:54

<r0bby>

Doesn't commons have something

03:54

<SJrX>

Doesn't commons?

03:54

<SJrX>

errr commons?

03:54

<SJrX>

No I mean in email addresses you can have comments

03:55

<r0bby>

~commons

03:55

<javabot>

Apache Commons is a set of libraries built for reusability and filling the gaps in the standard library. It can be found at http://commons.apache.org/

03:55

<SJrX>

I don't have my book here, but I think it's in PHP Security, that it talks about validating email addresses, and that the actual specification isn't really real world usage

03:55

<r0bby>

SJrX: so weed out what you dont need from that regex

03:55

<r0bby>

:)

03:55

<SJrX>

Amazingly Regexp is a skill I have been able to avoid learning for 4 years now :P

03:56

<r0bby>

http://www.white-hat-web-design.co.uk/articles/js-validation.php

03:56

<r0bby>

steal the regex

03:56

<r0bby>

~next

03:56

<javabot>

Another satisfied customer. Next!

03:56

<pgib>

Hehe.. regexp is fairly straight forward until capturing groups

03:57

<r0bby>

pgib: pfft if you know what you're parsing it's piss easy

03:58

<pgib>

I mean in a brain-warping sense. since regexs are such shorthand

03:58

<SJrX>

I hate string parsing :P

03:58

<r0bby>

oh god

03:58

<SJrX>

I think probably everyone does, but I will learn it eventually

03:58

<r0bby>

http://forums.sun.com/thread.jspa?threadID=5165170&messageID=9631380

03:59

<r0bby>

pgib: it was at first

03:59

<SJrX>

r0bby so just take the other link you just posted, and that link and replace the lowered.matches with the other regexp and that's it?

03:59

<r0bby>

but once i learned what they were I figured out how to read them :)

03:59

<r0bby>

SJrX: just take that regex, better yet do email.matches(yourEmailRegex)

04:00

<r0bby>

it's as easy as that

04:00

<pgib>

Yeah, I guess. I don't really use them _too_ often, so, there is usually some relearning required, for me, when I want to do something complex

04:00

<SJrX>

the one in the js-validation one right

04:00

<r0bby>

yes

04:00

<r0bby>

i also found this http://www.codetoad.com/asp_email_reg_exp.asp

04:01

<r0bby>

http://saloon.javaranch.com/.../ultimatebb.cgi?ubb=get_topic&f=1&t=020629

04:01

<r0bby>

you didnt look hard enough they gave you solutions

04:02

<SJrX>

Sorry I saw some regexp ones but didn't know how to use them.

04:02

<pgib>

heh. I wonder how much all this stuff is gonna change since IANAL is opening up every possible top-level domain

04:02

<pgib>

I mean: how many apps will break

04:02

<pgib>

lol, not IANAL

04:03

<r0bby>

SJrX: pussy

04:03

<r0bby>

regex is powerful

04:03

<r0bby>

:)

04:03

<r0bby>

and useful for this exact case :_

04:03

<r0bby>

:)

04:03

<pgib>

ICANN

04:03

<SJrX>

Yeah I know it is

04:03

<SJrX>

hmmmm even after I escape the javascript one, my own email address fails the check

04:03

<SJrX>

do I have to escape more than just the \ to \\

04:04

<pgib>

I don't think, unless it is in a string. The \ is the delimiter

04:04

<SJrX>

return address.matches("/^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,4})$/");

04:04

<r0bby>

you have to double escape regex in java

04:04

<SJrX>

So

04:04

<pgib>

yeah, but he said jscript?

04:04

<joed>

Which is not java...

04:04

<SJrX>

return address.matches("/^([A-Za-z0-9_\\\\-\\\\.])+\\\\@([A-Za-z0-9_\\\\-\\\\.])+\\\\.([A-Za-z]{2,4})$/");

04:04

<r0bby>

you shouldn't rely on JS dude

04:04

<r0bby>

I can disable js and you'd be screwed

04:05

<SJrX>

um

04:05

<SJrX>

<r0bby> http://www.white-hat-web-design.co.uk/articles/js-validation.php

04:05

<SJrX>

<r0bby> steal the regex

04:05

<pgib>

I agree, always need SS validation as well

04:05

<r0bby>

steal the _REGEX_

04:05

<pgib>

I thought he was testing the regex in JS

04:05

<r0bby>

not the code itself...

04:05

<pgib>

my misunderstanding

04:05

<SJrX>

I am stealing the REGEX

04:05

<SJrX>

and it's not working

04:06

<Algonquian>

take out the starting and trailing "/"

04:06

<SJrX>

hmmmm well that worked for my email address, was that a guess or did you know that

04:06

<SJrX>

SJrX just wants to know if he should test if other things pass/fail

04:07

<r0bby>

SJrX: grab beanshell

04:07

<SJrX>

hmmmm it's working

04:07

<SJrX>

what's beanshell?

04:07

<r0bby>

~beanshell

04:07

<javabot>

r0bby, beanshell is a small, free, embeddable, Java source interpreter with object scripting language features, written in Java. It can be found at http://www.beanshell.org.

04:08

<r0bby>

i use groovyConsole for testing regexps

04:08

<pgib>

ah. I use python

04:08

<SJrX>

thanks

04:09

<r0bby>

SJrX

04:09

<r0bby>

use javamail

04:09

<r0bby>

http://java.sun.com/products/javamail/javadocs/.../InternetAddress.html#validate()

04:09

<r0bby>

:>

04:10

<r0bby>

http://java.sun.com/products/javamail/

04:10

<SJrX>

Isn't that EE?

04:10

<joed>

fubar!harvard!uunet.uu.net!overload!user

04:10

<r0bby>

SJrX: it's an api..

04:10

<r0bby>

you can use it in desktop

04:10

<SJrX>

Isn't that API only available in EE?

04:11

<r0bby>

joed: mail.jar is the javamail api correct?

04:11

<lilwik>

When I hold down a key, why do I get an endless stream of KeyEvents for pressing it? Shouldn't I get just one until I let go?

04:11

<joed>

It is only that jar yeah

04:12

<r0bby>

SJrX: include that in your classpath

04:12

<r0bby>

use the method i gave you

04:12

<r0bby>

~next

04:12

<javabot>

Another satisfied customer. Next!

04:12

<lilwik>

I'm trying to create a class that records which keys are being pressed, but it's not working.

04:12

<r0bby>

oh god

04:12

<SJrX>

Ah

04:12

<Xeese>

lol

04:12

<SJrX>

thanks r0bby

04:12

<r0bby>

this smells of malice

04:13

<SJrX>

should I use the JavaMail API or the connections API you gave earlier for SMTP sending?

04:13

<r0bby>

JavaMail

04:13

<lilwik>

I don't mean something that keeps a long-term record, I just want to be able to look up if a certain key is down or up at the moment.

04:13

<r0bby>

so?

04:14

<lilwik>

Java's event-based system is fighting me. I'm getting an endless stream of key events when I hold down a key.

04:14

<r0bby>

no shit sherlock

04:14

<r0bby>

:P

04:15

<lilwik>

Well, that's wrong isn't it?

04:15

<Xeese>

btw of 11605 emails 11436 passed with that regex

04:15

<r0bby>

no, it's probably catching your events

04:15

<Xeese>

by the way*

04:15

<r0bby>

keydown

04:15

<joed>

keyListner?

04:16

<lilwik>

Oh whoa, I think it just started working! I guess I was doing it right after all.

04:52

<SJrX>

When I stop my program from executing via the STOP button in eclipse or the OS requests that it shutsdown does my application throw a InterruptedException where this happens?

04:52

<SJrX>

or is that just internal for threads

05:07

<trend>

sup guys

05:09

<trend>

what am I doing wrong here? System.out.println((1-(investHist.getVolume()/storageUnit.getAvgVol()))*100); investHist.getVolume() is double = 236000 .... and storageUnit.getAvgVol() is double = 400120

05:09

<SJrX>

A lock object just has to reference the same place in all locations correct, it doesn't have to be a member of the object?

05:09

<trend>

but I get result = 0

05:09

<SJrX>

i.e. I'd like to have a concurrency lock on a Set, there

05:09

<SJrX>

Do I need to extend the Set class and have a lock object or can I put any ol' lock object there

05:09

<ernimril>

trend: you are not doing anything wrong, you get the expected results

05:09

<ernimril>

trend: int division

05:10

<trend>

i'm sorry , what do you meanby that?

05:10

<ernimril>

trend: convert some of the values to double

05:10

<amnesiac>

SJrX, there's no such thing as a lock object.

05:10

<SJrX>

ReentrantLock

05:10

<trend>

ohhh, ok.. thank you :)

05:10

<SJrX>

trend 4/3 is 0

05:10

<ernimril>

SJrX: no, it is 1

05:10

<trend>

1.333333

05:10

<trend>

heh

05:10

<amnesiac>

SJrX, different thing. So, you want to hold a lock in a compound action of a Set?

05:10

<SJrX>

errr whoops

05:10

<SJrX>

Yeah

05:10

<amnesiac>

SJrX, or a single operation on the set?

05:10

<trend>

:) heh

05:10

<SJrX>

Hmmmmm

05:11

<ernimril>

trend: 1/2 = 0, 1.0/2 = 0.5

05:11

<SJrX>

well not sure, I've been away for 3 months.

05:11

<SJrX>

I have one thread that is adding stuff to the set, every so often the other thread will wake up and iterate over members of the set.

05:11

<trend>

ohhh, I see what you are saying now

05:11

<SJrX>

Adding and removing stuff to the set, happens randomly

05:12

<amnesiac>

SJrX, use any use a CopyOnWriteArraySet

05:12

<amnesiac>

SJrX, Concurrent collections doesn't have fail-fast iterators anymore

05:12

<SJrX>

fail-fast?

05:13

<SJrX>

hmmm

05:13

<amnesiac>

SJrX, have you read the documentation on iterations and iteration over a collection while shared on different threads>

05:13

<trend>

double avgVolP = (1.00000 - (investHist.getVolume()/storageUnit.getAvgVol()))*100.0000; should work?

05:13

<trend>

actually .. both of the vars are int s

05:13

<SJrX>

no I haven't

05:13

<amnesiac>

SJrX, if you're not using a concurrent collection, then you have to hold a lock before you enter to the iteration.

05:13

<SJrX>

Yeah that's what I was thinking

05:14

<amnesiac>

SJrX, you make sure you lock that region and that only one thread a time does that.

05:14

<SJrX>

but I think this CopyOnWriteArraySet() may do what I want

05:14

<amnesiac>

SJrX, but seriously you want a CopyOnWriteArraySet

05:14

<SJrX>

So with this, I don't have to do anything special really

05:15

<amnesiac>

SJrX, define "anything special".

05:15

<amnesiac>

SJrX, if that's the only thin you wanna do, that's it. But read the docs, make sure the implementation doeos what you need.

05:16

<SJrX>

Hmmmmm

05:16

<SJrX>

The sample code there is of no help

05:16

<amnesiac>

SJrX, huh?

05:16

<SJrX>

the basic operations seem to imply it does what I want.

05:16

<SJrX>

http://java.sun.com/j2se/1.5.0/docs/api/java/util/.../CopyOnWriteArraySet.html

05:17

<SJrX>

So from what I can tell, whenever one thread adds something to the set it will be slow (ok), all instances will be updated. When I grab an iterator off of it, it will then have a copy at the time it was created.

05:17

<trend>

crap.. no go w/: double avgVolP = (1.00000 - (investHist.getVolume()/storageUnit.getAvgVol()))*100.0000; I get 0.0 as the result

05:18

<SJrX>

Even if the other thread removes an element from the set, it will still be in the iterated version, and hence will always exist

05:18

<amnesiac>

it will be slow?

05:19

<SJrX>

that's what it says, well expensive

05:19

<SJrX>

hmmmm

05:19

<amnesiac>

it's cheaper than doing a Collections.synchronizedSet(set)

05:19

<amnesiac>

since it doesn't work with synchronized, it uses a CAS algorithm.

05:19

<amnesiac>

SJrX if that's not your solution, then rely on what I posted above

05:20

<amnesiac>

SJrX, and synchronize over the collection before you iterate

05:20

<SJrX>

Hmmmmm yeah I think that works

05:20

<SJrX>

I'm just trying to get it in my head

05:20

<amnesiac>

SJrX, it's easy, thinkg about "serial access"

05:21

<amnesiac>

just as a sequence :)

05:21

<SJrX>

My previous question that no one asked, when my program terminates from CTRL+C, hitting STOP or the OS, is that just an IterruptedException getting tossed in my program somewhere, or is that just for threads.

05:21

<SJrX>

I'd like to do some shutdown cleanup

05:22

<trend>

anyone know what's up w/ my math problem?

05:22

<trend>

System.out.println((1.0000-(investHist.getVolume()/storageUnit.getAvgVol()))*100.00000); gets 0.0

05:22

<amnesiac>

SJrX, InterruptedException is just that, whenever a Thread is interrupted by either... (thread termination, thread abort, a timer)

05:23

<amnesiac>

SJrX, Java doesn't support signaling at all.

05:23

<SJrX>

amnesiac but is that true for the 'main' portion of my app

05:23

<amnesiac>

SJrX, you can do shutdown cleanup, take a look at ExecutorService

05:23

<amnesiac>

SJrX, instead of using plain threads use an Executor.

05:23

<amnesiac>

SJrX, that will allow you to have a lifecycle for your multithreaded application. and do cleanup at shutdown.

05:23

<SJrX>

No I mean for the application itself

05:23

<amnesiac>

SJrX, yes, for the application itself.

05:23

<SJrX>

Okay

05:24

<trend>

java.math.BigInteger( << is that what I need?

05:25

<SJrX>

hmmmmm

05:25

<SJrX>

what are the actual values for getVolume() and getAvgVol()

05:25

<joed>

Signal and SignalHandler....

05:25

<amnesiac>

trend, what type is getVolume and getAvgVol?

05:26

<amnesiac>

joed, is more like a shutdown hook.

05:26

<trend>

it was whole numbers.. 234000 or so and 420000

05:26

<trend>

I can get the exact ones.. will have to run the prog for a bit

05:26

<amnesiac>

trend, on integers, Java promotes arithmetic operations to that type...

05:27

<trend>

I need to do this? System.out.println((1.0000-((double)investHist.getVolume()/(double)storageUnit.getAvgVol()))*100.00000);

05:27

<amnesiac>

trend, make sure that... whle doing arithmetic operations, you operate over values from the same type.

05:28

<joed>

amnesiac: To catch clean vs unclean exits, yes, I'm saying you can get at signal handling.

05:28

<trend>

:? ok

05:29

<ultravi01>

can I add to an int[]

05:30

<amnesiac>

ultravi01, eh?

05:30

<trend>

i thought you could expand it

05:30

<joed>

Can you resize an array - no.

05:30

<ultravi01>

i created a new int[] and I want to iterate through one array and put the values in my new int[]

05:31

<amnesiac>

ultravi01, do it by their index, considering that they're both of the same size.

05:31

<joed>

Use collections.

05:31

<amnesiac>

or your new one is as big as possible to hodl all the values from the other array.

05:32

<ultravi01>

ok, thank you

05:33

<joed>

/mode +b *!*arrays

05:33

<trend>

double avgVolP = (((double)investHist.getVolume()/(double)storageUnit.getAvgVol())-1.00000)*100.0000; did the trick :)

05:33

<trend>

thanks for the input

05:33

<trend>

heh

05:34

<trend>

E> arrays

05:34

<Xeese>

~~ultravi01 javadoc System.arraycopy(*)

05:34

<javabot>

ultravi01, please see http://java.sun.com/javase/6/docs/api/java/lang/System.html#arraycopy(java.lang.Object,%20int,%20java.lang.Object,%20int,%20int)

05:35

<ultravi01>

thanks xeese

05:38

<trend>

how can I cast 54.001230123 into 54.00 ?

05:38

<amnesiac>

that's not a cast

05:38

<trend>

sorry, bad verbage

05:39

<trend>

?

05:39

<amnesiac>

trend, just use a formatter\

05:39

<trend>

ahh, yeah.. couldn't remember

05:39

<trend>

nice :)

05:46

<seraph>

hey all

05:46

<seraph>

is there any way to loop over all the public fields in a class?

05:48

<dangertools>

yes

05:55

<SJrX>

lol I just spent the past two hours having a thread master, when it turns out I can't leave my thread in a blocking state anyway for timeouts since I have to sleep to interrupt, argh.

05:55

<seraph>

dangertools, how?

05:55

<amnesiac>

SJrX, what?

05:56

<seraph>

been googling but can't seem to achieve this simple task :(

05:56

<Xeese>

look at myObj.getClass().getFields()...

05:56

<SJrX>

I have thread A sitting in in.nextLine(), it's blocking. I needed to have it timeout after 5 minutes. So I set about having another thread interrupt it. However that won't work since an interrupt only ever happens during sleep(), so I need to just check if there is a new line first and sleep if not

05:57

<xjrn>

seraph i use that to rewrite source code from its compiled form :)

05:57

<xjrn>

seraph: Object.getClass().getDeclared*()

05:58

<seraph>

xjrn, ooer

05:58

<seraph>

I'll try that out

06:01

<dangertools>

~tell seraph about reflection

06:02

<javabot>

seraph,