comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * 2 for-loops in JSP or Struts? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8bbeaccb4877f012 * modifying methods of a class with XDoclet - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e631c1b42032d8f3 * Map that takes a pair of keys? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8bfed67959eb893 * Distributed Transaction Driver - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c8fe437fa1eba9bf * jdeveloper project file structure - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f23ff9ae612cd6b5 * singleton pattern - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2df0080c97ed1370 * Enums in inner classes - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ecb6f0754c4b0df * Is there a unix-like select in Java - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e44542f7c53cca5c * common problem without explanation - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97f039cd80ea21bf * Problem in XJC with recognizing jaxb: prefix - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9f1c47a74f32a804 * Best references for buidling a webcrawler - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/794947bf20d69623 * Can someone use invokeLater() to call a public method from a JPanel? - 4 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70ac1bf0cc54a090 * subset algo, hash table - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/960129e92dc26798 * Interface design question - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a07ca46c4217868 * How use java.util.logging.config.class? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f086cadd5f41a7 * development tools - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/92585bb2efd8fce7 * What's the best way to acess the model from the view in a MFC approach? - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e891af3d3a7da1d * NetBeans Properties - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37c774d59dccb413 * Is there a Java HTMLEncoder - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f3585a6b57cf98c * Floats become decimals when read from a resultset. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e54b4c8e235131b * sorting an ArrayList by int - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127ea15b32732f1 ========================================================================== TOPIC: 2 for-loops in JSP or Struts? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8bbeaccb4877f012 ========================================================================== == 1 of 2 == Date: Tues, Oct 26 2004 9:21 am From: [EMAIL PROTECTED] (peter10) Hi there, can anybody help to translate the following Java-code into JSP or Struts syntax, so that the JSP-page doesnt contain Java code? I experimented with Strut's <iterate> tag but that didn't seem to help with the second for-loop ... Any help would be greatly appreciated! Best wishes, Peter ArrayList array = new ArrayList(collection1); ArrayList array2 = new ArrayList(collection2); for(int i = 0; i < array.size(); i++){ out.println(array.get(i)); if(array.get(i) == value_from_request){ for(int j = 0; j < array2.size(); j++){ out.println(array2.get(j)); } } } == 2 of 2 == Date: Tues, Oct 26 2004 10:16 am From: Rogue Chameleon <[EMAIL PROTECTED]> peter10 wrote: > Hi there, > > can anybody help to translate the following Java-code into JSP or > Struts syntax, so that the JSP-page doesnt contain Java code? I > experimented with Strut's <iterate> tag but that didn't seem to help > with the second for-loop ... > Why don't you start with showing us your "experimentation" and we'll go from there. No one here is going to give you the answer. However, we will all help you get to the answer. ========================================================================== TOPIC: modifying methods of a class with XDoclet http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e631c1b42032d8f3 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 9:36 am From: [EMAIL PROTECTED] (denis) Hi, I've got series of classes (EJBs) which their home & remote interface are generated by XDoclet1.2.1. And, I'd like to modifiy the ejbCreate of the EJB method if a specific argument is passed to the ant instruction. So I've decided to use : <template destinationFile="{0}.java" templateFile="transform-ejb-cmp.xdt" mergeDir="${merge.dir}"/> My question : is it possible to have the transform-ejb-cmp.xdt file like that --> <XDtEjbComment:comment> As there is a lot of different file in the project, I only need to modify the one which are of a CMP entity type </XDtEjbComment:comment> <XDtEjbCmp:ifEntity> [here I need to recopy all the stuff from the original file to the last line of ejbCreate()] // several specific java instruction System.out.println("test"); [here I need to recopy all the stuff from the original file to the last line of ejbCreate() to the last line of file] </XDtEjbCmp:ifEntity> Another solution was to take original entity-cmp.xdt files and modify then but it doesn't fit my needs cause the process for this subtask is treating only files ending with CMP moreover I only need to modify the ejbCreate method and the original entity-cmp.xdt file modify a lot of other things like methods signature, extension of class and so on. Have you got any clues wich could help me in resolving this issue ? Thanks a lot for all you can do. Regards, blured. The following EJB class is originally like that : package .... .... public abstract class Toto implements EntityBean { .... .... /** * * */ public abstract ejbCreate() { setId(1); setToto("3"); } .... } The result file I'd like to have is : package .... .... public abstract class Toto implements EntityBean { .... .... /** * * */ public abstract ejbCreate() { setId(1); setToto("3"); // several specific java instruction System.out.println("test"); } .... } ========================================================================== TOPIC: Map that takes a pair of keys? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b8bfed67959eb893 ========================================================================== == 1 of 2 == Date: Tues, Oct 26 2004 9:48 am From: Chris Riesbeck <[EMAIL PROTECTED]> In article <[EMAIL PROTECTED]>, bugbear <[EMAIL PROTECTED]> wrote: > marcus wrote: > > This is a tough one to google hehe > > Is there code available, or a coupla good hints, for a fast map that > > takes a pair of keys to produce a value? > > Yes. > > http://jakarta.apache.org/commons/collections/apidocs/org/apache/commons/collections/map/MultiKeyMap.html > > Java may or may not be a great language, But the library support > is kinda' handy. Learn to use it. The Jakata Commons packages are handy but not official Java, are they? No one mentioned using ArrayList's as the keys. They already implement equals() and hashCode() correctly. E.g., public class MultiKeyMap extends HashMap { List key = newKey(null, null); public Object get(Object k1, Object k2) { return get(setKey(k1, k2)); } public void put(Object k1, Object k2, Object v) { put(newKey(k1, k2), v); } private List newKey(Object k1, Object k2) { return Arrays.asList(new Object[]{k1 k2}); } private List setKey(Object k1, Object k2) { key.set(0, k1); key.set(1, k2); return key; } } The private key avoids constructing an ArrayList on every get() but of course this is not thread-safe. Am I missing an obvious flaw here, as usual? == 2 of 2 == Date: Tues, Oct 26 2004 12:05 pm From: [EMAIL PROTECTED] (Greg Smith) marcus <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>... > This is a tough one to google hehe > Is there code available, or a coupla good hints, for a fast map that > takes a pair of keys to produce a value? > > I have two keys that together map to a single (non-unique) value, but > not in a particularly logical manner. This is for a personal project > and doesn't have to look pretty, so I can hard-code loading the map. > Pulling the values out, though, I don't want a hundred or so nested if > statements. > > Hmm, can I set up a map of maps? the first key returns a value, which > itself is a map of possible second keys? *shudder* i have just concatenated two strings with a separator... String key=key1+","+key2; hashTable.put(key, data); greg ========================================================================== TOPIC: Distributed Transaction Driver http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c8fe437fa1eba9bf ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 9:41 am From: [EMAIL PROTECTED] (Paolo) I've written a driver which accesses a database like system. I'd like to enable the driver so that it can participate in a distributed transaction, but I'm a little overwhelmed by the complexity of the JTA specification. Are there any resources out there that aid in implementing this type of transactional driver? I don't think that I'll be running my code in any sort of application server. So, if anyone can point me to information about how the application server is involved in the process of executing a distributed transaction, that would be great too. Thanks, Paul ========================================================================== TOPIC: jdeveloper project file structure http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f23ff9ae612cd6b5 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 9:55 am From: [EMAIL PROTECTED] (shay) Try posting your question on the JDeveloper forum on OTN (linked on the right side of http://otn.oracle.com/products/jdev). Also try and look at the system navigator and see if it is a better view for you than the application navigator. ========================================================================== TOPIC: singleton pattern http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2df0080c97ed1370 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 9:58 am From: [EMAIL PROTECTED] (Doug Pardee) Babu Kalakrishnan <[EMAIL PROTECTED]> wrote: > Most JVMs don't load the class till some code makes a reference to > it, and the instance will be created only during classloading. Not "most"... *all*. This is required by section 12.4.1 of the Java 2 Language Specification. Also, to be pedantic: 1) it's not the JVM that's involved, it's the ClassLoader, and 2) the singleton instance is NOT created during classloading; it is created during class *initialization*. The ClassLoader is permitted to load (and possibly link) the class before it is needed, but the ClassLoader is *not* permitted to initialize the class, thus running the "new" statement, until the class is actually accessed. ========================================================================== TOPIC: Enums in inner classes http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7ecb6f0754c4b0df ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 9:58 am From: G Winstanley <[EMAIL PROTECTED]> On Tue, 26 Oct 2004 13:30:43 +0200, the cup of "Boudewijn Dijkstra" <[EMAIL PROTECTED]> overfloweth with the following: > "G Winstanley" <[EMAIL PROTECTED]> schreef in bericht > news:[EMAIL PROTECTED] > > Jus a quick one...now I've finally got hold of v1.5 I'm trying to use > > an enum in a private final inner class, but I get the following > > message from the compiler in NetBeans 4.0b2: > > > > init: > > deps-jar: > > Compiling 1 source file to P:\NetBeans Projects\ProjectX\build\classes > > P:\NetBeans Projects\ProjectX\src\Foo.java:7: modifier not allowed > > here private enum Status{ONE, TWO, THREE, FOUR} > > 1 error > > BUILD FAILED (total time: 0 seconds) > > > > > > The class is defined as: > > > > public class Foo > > { > > private final class Bar > > { > > private enum Status {ONE, TWO, THREE, FOUR} > > // ...etc... > > } > > } > > > > > > Any ideas which modifier it's got a problem with? > > How about the static modifier? > Same problem arises with any modifier as far as I can see. I've tried the obvious ones like static, final, and public to see if needs more scope, but nothing allows it to compile successfully. Stan ========================================================================== TOPIC: Is there a unix-like select in Java http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e44542f7c53cca5c ========================================================================== == 1 of 3 == Date: Tues, Oct 26 2004 10:06 am From: [EMAIL PROTECTED] (Amit) Hi all: I was wondering if Java took care of the classic problem that is used to introduce select in unix (as in Stevens book). The problem is of echo client and server. If suppose the server wants to close down, it sends a FIN to the client. However, the client may be busy-waiting for user to enter smth. When user enters smth, the client tries to write, only to find that the connection has been closed from server's side. So, we unnecessarily made the user to enter smth. What we want is that as soon as the FIN comes, we are notified. selects fits here. select is a fn that is used to listen to one or more descriptors. When there is data on any one of them, we are notified. This way, as soon as the server closes down, the client gets to know about it. Is there smth of this sort in java. Thanks Amit == 2 of 3 == Date: Tues, Oct 26 2004 10:21 am From: Grant Wagner <[EMAIL PROTECTED]> Amit wrote: > Hi all: > > I was wondering if Java took care of the classic problem that is used > to introduce select in unix (as in Stevens book). The problem is of > echo client and server. If suppose the server wants to close down, it > sends a FIN to the client. However, the client may be busy-waiting > for user to enter smth. When user enters smth, the client tries to > write, only to find that the connection has been closed from server's > side. So, we unnecessarily made the user to enter smth. What we want > is that as soon as the FIN comes, we are notified. selects fits here. > > select is a fn that is used to listen to one or more descriptors. When > there is data on any one of them, we are notified. This way, as soon > as the server closes down, the client gets to know about it. > > Is there smth of this sort in java. > > Thanks > > Amit Start a separate thread that always listens to the server, if it receives information from the server while another thread is doing something else, it can take the appropriate action (display a message, reconnect, connect to a different server, etc). And does typing "smth" instead of "something" save you that much time and effort? Personally I had to stop and _think_ about typing "smth", the word "something" actually results in a higher wpm rate. And I don't think anyone is going to chastise you for "wasting" 5 characters. -- Grant Wagner <[EMAIL PROTECTED]> == 3 of 3 == Date: Tues, Oct 26 2004 11:32 am From: [EMAIL PROTECTED] Have you checked out Java 1.4's NIO stuff, e.g. java.nio.channels.Selector (http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/Selector.html) ? Amit wrote: > Hi all: > > I was wondering if Java took care of the classic problem that is used > to introduce select in unix (as in Stevens book). The problem is of > echo client and server. If suppose the server wants to close down, it > sends a FIN to the client. However, the client may be busy-waiting > for user to enter smth. When user enters smth, the client tries to > write, only to find that the connection has been closed from server's > side. So, we unnecessarily made the user to enter smth. What we want > is that as soon as the FIN comes, we are notified. selects fits here. > > select is a fn that is used to listen to one or more descriptors. When > there is data on any one of them, we are notified. This way, as soon > as the server closes down, the client gets to know about it. > > Is there smth of this sort in java. > > Thanks > > Amit ========================================================================== TOPIC: common problem without explanation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/97f039cd80ea21bf ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 10:30 am From: [EMAIL PROTECTED] (gbs) Many people have posted my problem, but, I have not found any real solutions. Can you help? Problem: use gdb to debug a C/C++ program with an embedded JVM. Java allows SIGSEGV to happen as part of it's normal processing, e.g., for Garbage Collection. The JVM handles this signal and recovers without any problems. However, when running a C/C++ program that instantiates a JVM under gdb, gdb sees these JVM SIGSEGV's and terminates the program. So, how, or is it possible, to debug the C/C++ code with an embedded JVM? Thanks Greg Silverman Senior Software Engineer Northrop Grumman San Jose, CA ========================================================================== TOPIC: Problem in XJC with recognizing jaxb: prefix http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9f1c47a74f32a804 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 10:31 am From: [EMAIL PROTECTED] (Asra) Hello, I'm using xjc to compile XML Schema into JAXB objects and the compiling is fine unless I try to define jaxb bindings. For instance, if I try adding this code in the schema: <xs:annotation> <xs:appinfo> <jaxb:globalBindings generateIsSetMethod="true"> bindingStyle="modelGroupBinding" choiceContentProperty="true" > <xjc:serializable uid="12343"/> <jaxb:javaType name="short" xmlType="xs:long" printMethod="javax.xml.bind.DatatypeConverter.printShort" parseMethod="javax.xml.bind.DatatypeConverter.parseShort"/> </jaxb:globalBindings> </xs:appinfo> </xs:annotation> xjc complains with: [ERROR] The prefix "jaxb" for element "jaxb:globalBindings" is not bound. It says that wherever I use jaxb, whether in jaxb:property or anything. Can anybody point out what I'm missing? Thanks, Asra Baig ========================================================================== TOPIC: Best references for buidling a webcrawler http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/794947bf20d69623 ========================================================================== == 1 of 3 == Date: Tues, Oct 26 2004 10:55 am From: "Jay Liu" <[EMAIL PROTECTED]> Hey guys, I'm somewhat new to Java and I'm just looking for some reference ideas for building a html page getter. Basically a Wget in java. Can someone point in the right direction? Thanks, Jay. == 2 of 3 == Date: Tues, Oct 26 2004 11:07 am From: Paul Lutus <[EMAIL PROTECTED]> Jay Liu wrote: > Hey guys, > > I'm somewhat new to Java and I'm just looking for some reference ideas for > building a html page getter. > Basically a Wget in java. Can someone point in the right direction? Start by experimenting with class URLConnection and look at the many online examples. -- Paul Lutus http://www.arachnoid.com == 3 of 3 == Date: Tues, Oct 26 2004 11:42 am From: Alex Hunsley <[EMAIL PROTECTED]> Jay Liu wrote: > Hey guys, > > I'm somewhat new to Java and I'm just looking for some reference ideas for > building a html page getter. > Basically a Wget in java. Can someone point in the right direction? > > Thanks, Jay. Hi Jay You could look at URLConnection as Paul mentioned. I'd just like to throw in my hat here and say have a look at HTTPClient too (part of the Jakarta Commons project). There's a comparison of the two here: http://www.innovation.ch/java/HTTPClient/urlcon_vs_httpclient.html (generally, HTTPClient does more things that URLConnection and is better behaved) You can visit the home of HTTPClient here: http://jakarta.apache.org/commons/httpclient/ The Jakarta Commons project is good stuff. They have lots of other bits and pieces that are very useful: http://jakarta.apache.org/commons/ alex ========================================================================== TOPIC: Can someone use invokeLater() to call a public method from a JPanel? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/70ac1bf0cc54a090 ========================================================================== == 1 of 4 == Date: Tues, Oct 26 2004 11:07 am From: Alex Hunsley <[EMAIL PROTECTED]> steve wrote: > On Sat, 23 Oct 2004 17:28:00 +0800, Alex Hunsley wrote > (in article <[EMAIL PROTECTED]>): > > >>***C.Steamer*** wrote: >> >>>Basically I want the application to call invokeLater() to update the view >>>of >>>the gui. This is for a simple card game.I want to call a public method >>>called updateHand(Hand hand) which I pass in a hand then it clears the >>>items >>>in the JPanel and adds a Label representing each of the cards to the >>>Jpanel. >>>For some reason if I call this method from the constructor of the JPanel >>>but >>>the invoke method doesn't work. This is my code in the application layer. >>>Any suggestions why this isin't working? > > > I suspect it Is working, but that you GUI has not been fully rendered, so you > are updating something that cannot be seen yet,then the changes are being > over written. > > > >>For a start, post complete, compilable, working code that demonstrates >>the problem. Snippets aren't much use. >> >>Secondly - you are calling something from the constructor of JPanel, you >>say? How do you mean? Have you edited/recompiled the JPanel source; or >>overridden JPanel, or what? Anyway, sounds like you're suffering >>Constructoritis, the disease of doing far too much in constructors. >>Constructors should do very little - store passed in values, usually; >>constructors should *not* call non-final or non-private methods, and >>constructors shouldn't be doing GUI related things. Factor out that >>stuff into other method(s) that you call after the Constructor has done >>its stuff. Doing this may solve your problems. >> >>alex > > > so Alex , where should we draw the GUI? , because i am also extending the > JPanel deff, then calling the GUI setup stuff in the constructor. Btw, it's not good style to extend JPanel in most cases. If you genuinely *are* extending JPanel (I mean in the design of your software), then have a class extend JPanel; if, however, your application just *has* a JPanel and wants to use it, don't extend: just use a JPanel. Think of it as the difference between "is a" and "uses a". Another way of thinking about it: if you want to make a single String, you don't override the String class, do you? You just make a new string using existing methods/constructors. alex == 2 of 4 == Date: Tues, Oct 26 2004 11:09 am From: Alex Hunsley <[EMAIL PROTECTED]> Mark Thornton wrote: > Thomas G. Marshall wrote: > >> Mark Thornton coughed up: >> >>> defined. Yes it is true that some people have been surprised by the >>> fact that if a constructor uses a method which has been overridden in >>> a child class, then unlike in C++ it is the child's version which is >>> used. >> >> >> >> ....which is a disaster waiting to happen, because it can allow a >> superclass >> to access something that has not yet been initialized in the subclass. > > > Remember of course that Java's default initialisation (to zero/null) has > occurred, so the consequences are well defined. Consequences are irrelevent here; I'm concerned with well-written understandable code that doesn't rely of knowledge of surprising aspects of the system. And no matter how well *you* might understand, and cope with, oddities of the compiler/runtime, someone else may some day be looking at your code, and be less well versed in the ins and outs of the compiler/runtime. == 3 of 4 == Date: Tues, Oct 26 2004 11:38 am From: Alex Hunsley <[EMAIL PROTECTED]> Mark Thornton wrote: > Alex Hunsley wrote: > >> ***C.Steamer*** wrote: >> >> overridden JPanel, or what? Anyway, sounds like you're suffering >> Constructoritis, the disease of doing far too much in constructors. >> Constructors should do very little - store passed in values, usually; >> constructors should *not* call non-final or non-private methods, and >> constructors shouldn't be doing GUI related things. Factor out that >> stuff into other method(s) that you call after the Constructor has >> done its stuff. >> > > I agree with Thomas Marshall that your prescription is overly strict. > The style of doing almost nothing in constructors is necessary in C++ > where the consequences of throwing an exception during a constructor are > poorly defined. I think my erring on the side of not putting a lot in constructors stems from the amount of times I have seen too much in constructors, and the problems created therein. I am just very wary of what can happen. == 4 of 4 == Date: Tues, Oct 26 2004 11:34 am From: Alex Hunsley <[EMAIL PROTECTED]> Thomas G. Marshall wrote: > Alex Hunsley coughed up: > > ...[rip]... > > >>>Overly strict. I cannot /count/ the number of times I've seen >>>horribly convoluted code set out to avoid putting nearly /anything/ >>>into a constructor. >> >>"Constructors should *not* call non-final or >>non-private methods" is not overly strict > > > STOP RIGHT THERE. Please don't shout, it's considered rude. > You meant: should *not* call non-final or non-private methods of that same > object? Sorry, I misunderstood your intent. well, if I didn't mean that, then I would be talking about calling private methods of *other classes* which wouldn't make any sense. So yes, I meant of that same object, sorry if I wasn't clear on that. > Then I totally agree. > > Here's something else I see *all the time*: (pseudo-java, ignore scoping > rules): > > class A > { > A() { helper(); } > > helper() {....}; > } > > class B extends A > { > helper() {....}; // dangerous: overridden > } Yup, I see that too. I see dead people. ========================================================================== TOPIC: subset algo, hash table http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/960129e92dc26798 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 10:13 am From: Oscar kind <[EMAIL PROTECTED]> Carl Howells <[EMAIL PROTECTED]> wrote: > someguy wrote: >> I'm trying to write a method in Java that takes in a string and >> prints all the subsets (For example, if you are given "ABC", you would >> print: A B C AB AC BC ABC). Any suggestions? > > For the first, I like recursion. It's natural, clean, and very simple > conceptually. In this particular case, I disagree: a nested loop is just a tad easier. It's a close call though, so I'll implement your idea just for kicks. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: Interface design question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a07ca46c4217868 ========================================================================== == 1 of 2 == Date: Tues, Oct 26 2004 10:46 am From: Oscar kind <[EMAIL PROTECTED]> Martha Goys <[EMAIL PROTECTED]> wrote: > I'm debating on one of the following approaches: > > A) > SomeClassA getOutput(SomeClassB input) > > or > > B) > void setInput(SomeClassB input) > SomeClassA getOutput() > > The plus I see with approach A is its simplicity, and that the flow is > very obvious. > > The pluses I see with approach B is the use of bean syntax, which is > very useful in reflection, etc. [...] > > Any words of wisdom? I don't know about wisdom, but I prefer bean syntax only when getting/setting properties (that's what is was designed for, I believe). This is not the case here: it is a transformation. So for me, approach A is the clear winner. But I would make a small change to the method name: SomeClassA createOutput(SomeClassB input); Reason: I prefer names that don't resemble getter/setter names for methods that are not getters/setters. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 == 2 of 2 == Date: Tues, Oct 26 2004 11:46 am From: Alex Hunsley <[EMAIL PROTECTED]> Martha Goys wrote: > I may be over-thinking this, but had a question regarding best design of > a interface. The function of this interface is very simple: take an > object and produce another object from it (input and output are > different types, but this is not important here). > > I'm debating on one of the following approaches: > > A) > SomeClassA getOutput(SomeClassB input) > > or > > B) > void setInput(SomeClassB input) > SomeClassA getOutput() > > The plus I see with approach A is its simplicity, and that the flow is > very obvious. > > The pluses I see with approach B is the use of bean syntax, which is > very useful in reflection, etc. > > I suppose what's throwing me is that since this is currently just an > interface, it's hard to see if there's really much difference in the two > approaches above. > > Any words of wisdom? If you're not steering towards bean use currently, then I would definitely go for a). You may want to check out the Factory pattern - it might be applicable here. http://gsraj.tripod.com/design/creational/factory/factory.html (Functionally, making it a factory won't change much; but to others coming along and seeing the code, a SomethingFactory might be familiar and aid understanding.) alex ========================================================================== TOPIC: How use java.util.logging.config.class? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f086cadd5f41a7 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 11:06 am From: Oscar kind <[EMAIL PROTECTED]> Tobias Besch <[EMAIL PROTECTED]> wrote: > I want to use java.util.logging togehter with Web Start. > Since specifying a configuration file with the system property > java.util.logging.config.file does not work with Web Start > (because you cannot specify a file path) I'd like to try > java.util.logging.config.class and put that class into the classpath. > > As I searched the Internet I found examples for specification of > configuration files. > But I couldn't find any example on how to specify logging properties > in a class. IMHO, you've taken a wrong turn at the end: get the configuration file from your .jar file and initialize logging with that. An similar case can be found here (just one day old): http://groups.google.com/groups?threadm=u7sv42-j32.ln1%40odin.asgard Combine this with System#getResourceAsStream(String) and LogManager#readConfiguration(InputStream) to feed the configuration file into LogManager. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: development tools http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/92585bb2efd8fce7 ========================================================================== == 1 of 2 == Date: Tues, Oct 26 2004 10:39 am From: Oscar kind <[EMAIL PROTECTED]> Kiyu <[EMAIL PROTECTED]> wrote: > I am familiar > enough with the syntax of Java to code in it and have written some > simple stuff. I am now at the point that I want to do some serious > work in Java and don't want to slap myself in 5 years after I've been > using the wrong tools. Sounds like a smart idea. However, there are no "wrong" tools IMHO. But there are unsuitable tools: an IDE for a beginner, for example. In your case, it sounds like you're almost ready for an IDE. I say almost, because every IDE has different things with which it tries to help developers. Building projects is one of them, but every IDE does this differently. The first thing is to learn to use ant. It automates builds for you, and can even increase version numbers, commit version tags in cvs, create the database, or deploy your application. And that's plain out of the box. Then you want to look at several IDE's. The best three I've heard of are Eclipse, IntelliJ and BlueJ. But others like JBuilder are also quite good. A short overview (my limited knowledge/opinion only): - Eclipse is free but doesn't support Java (1.)5.0 yet (unless in beta) - IntelliJ does support Java (1.)5.0, but is expensive - BlueJ is simple, but free (I have no knowledge about support for 1.5.0) This IDE is good for beginners, but others find it nice as well. - JBuilder is quite good, not free, and IMHO less useful for it's price than both Eclipse and IntelliJ. Your mileage will vary, so I advise you to try a few different IDE's and see which one works best for you. -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 == 2 of 2 == Date: Tues, Oct 26 2004 11:54 am From: Alex Hunsley <[EMAIL PROTECTED]> Oscar kind wrote: > Kiyu <[EMAIL PROTECTED]> wrote: > >>I am familiar >>enough with the syntax of Java to code in it and have written some >>simple stuff. I am now at the point that I want to do some serious >>work in Java and don't want to slap myself in 5 years after I've been >>using the wrong tools. > > > Sounds like a smart idea. However, there are no "wrong" tools IMHO. > But there are unsuitable tools: an IDE for a beginner, for example. [snip] Just to add to Oscars post: if you do use an IDE, make a little effort and learn how to do things on the command line first (i.e. compiling and running your java programs). You will gain some understanding of what goes on behind the scenes, and later when you use an IDE and perhaps run into problems, the experience will prove useful. Good knowledge to have. ========================================================================== TOPIC: What's the best way to acess the model from the view in a MFC approach? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1e891af3d3a7da1d ========================================================================== == 1 of 2 == Date: Tues, Oct 26 2004 11:31 am From: Alex Hunsley <[EMAIL PROTECTED]> Jacob wrote: > ***C.Steamer*** wrote: > >> Say I got a class that extends JPanel and I want to update the model >> class from within the JPanel class, what is the best way to do that. >> I already implement an Observer pattern to update the GUI from the >> model but how do we go the other way. > > > Basically you do by direct access. The GUI modules should > have references to the model counterparts. Note also that > any events that should be produced should be invoked from > the GUI making the changes, and *not* from the model itself. [snip] Jacob - I'd wouldn't answer this buffoon if I were you. He isn't very grateful for help: http://makeashorterlink.com/?J1B114F99 == 2 of 2 == Date: Tues, Oct 26 2004 11:29 am From: Alex Hunsley <[EMAIL PROTECTED]> ***C.Steamer*** wrote: > Say I got a class that extends JPanel and I want to update the model class > from within the JPanel class, what is the best way to do that. I already > implement an Observer pattern to update the GUI from the model but how do we > go the other way. Basically I will be clicking on an area of the panel and > based on which object I select I want to change something in the model > class. Should I just pass in all the classes that the GUI will need? I don't > like this method cuz then you have to have the classes already instantiated > before you build the gui and it makes for intermixed code. Or should I make > the model class into Singleton so I can statically access the class from > anywhere? Thanks for your help? What makes you think you're going to get any help here after this disgraceful performance? http://makeashorterlink.com/?J1B114F99 (which was in response to helpful information from myself.) Now, go away. ========================================================================== TOPIC: NetBeans Properties http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/37c774d59dccb413 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 11:56 am From: [EMAIL PROTECTED] I had the same problem. All you have to do is call setPreferred(true) on PropertyDescriptors that you want to promote to "Properties" catagory. ========================================================================== TOPIC: Is there a Java HTMLEncoder http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3f3585a6b57cf98c ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 12:05 pm From: Shelly <[EMAIL PROTECTED]> Hi, Does anyone know if there is an HTMLEncoder class to produce web safe strings in Java? Something along the lines of URLEncoder. Thanks, Shelly ========================================================================== TOPIC: Floats become decimals when read from a resultset. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8e54b4c8e235131b ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 11:17 am From: Oscar kind <[EMAIL PROTECTED]> Koen <[EMAIL PROTECTED]> wrote: > first of all, the machine setup > server 1: > - UDB2 7.2.5; COUNTRY=1, location = US, IBM1250 codepage I happen to recognise this, as I worked with DB2 before. It might be nice to inform us you use a database. > - Locale: US English; Regional Settings: English; Keyboard: Dutch; > decimal separator: . > server 2: > - UDB2 7.2.5 Client Tools > - Websphere 4.0.5 > - Locale: US English; Regional Settings: English; Keyboard: Dutch; > decimal separator: . > db2cli.ini has PATCH2=15 on both servers. > > We run a webapplication. With a databases behind it... > For example, when reading contract data, the > following happens: > - the webinterface on server 2 requests the result of a stored > procedure on server 1 > --> when we run the Stored Procedure on server 1, we see that the > bookvalue from a car = 10000.21 (yes, with a dot) > --> when we do rs.getFloat or rs.getDouble to put the values in a > bizness object in the java code, we see 10000 ^^^^^^^-> business How do you retreive the value? As an Integer, Float, BigDecimal, ...? Actual code helps here. > We assume that the 10000.21 is placed in the resultset. It however > seems to be modified there. When we set 10000.21 in the bizness > object by ourself, it works. It is probably not changed by the driver. But there may be conversions you're not aware of. Again, nobody can see anything without the code. > ==> Data read on server 1 becomes a decimal when read or seen on > server 2. Yes: a database may not support floating point numbers, and store them as fixed point numbers instead. These are most accurately represented using a BigDecimal (not a "decimal"), which is what the driver returns. > Now, when we post 10000.22 as new bookvalue on server 2, we can write > 10000.22 in the database on server 1 without a problem!! This depends on what you put into the database, and how this differs from what you get out of it. Again, actual code helps here... > > We use a jdbc connection, jdbc2 is in use. > > We've searched more than 16 hours for a solution yesterday. I hope > someone here is smarter, or has a more original input then we can > produce at the moment. > Anything that could help will be grateful appreciated. > > Does the locale setting during installation matters? > > Thanks in advance, > > Koen -- Oscar Kind http://home.hccnet.nl/okind/ Software Developer for contact information, see website PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2 ========================================================================== TOPIC: sorting an ArrayList by int http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/127ea15b32732f1 ========================================================================== == 1 of 1 == Date: Tues, Oct 26 2004 11:48 am From: "zcraven" <[EMAIL PROTECTED]> "Bent C Dalager" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > In article <[EMAIL PROTECTED]>, > Steve Horsley <[EMAIL PROTECTED]> wrote: > > > >I suggest that you write an implementation of the Comparator class that > >goes something like (off the top of my head, not reading the docs): > > > >public class ClubPointsComparator implements Comparator { > > public int compare(Object o1, Object o2) { > > Club c1 = (Club) o1; > > Club c2 = (Club) o2; > > return c2.points - c1.points; > > This has the potential of running into an underflow problem. Not > particularly likely in this case, perhaps, but still. > > You could either do an if-sequence or you might write something like > return new Integer(c1.points).compareTo(new Integer(c2.points)); > > Unless the code is likely to become a performance bottleneck, I prefer > this way since it more clearly spells out exactly what you're trying > to do and why. It's also less error prone. > Interesting, can you explain how your way is different? What is an underflow problem? Zac ======================================================================= You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer". comp.lang.java.programmer [EMAIL PROTECTED] Change your subscription type & other preferences: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe Report abuse: * send email explaining the problem to [EMAIL PROTECTED] Unsubscribe: * click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe ======================================================================= Google Groups: http://groups-beta.google.com
