comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * SimpleDateFormat Help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/91f141dd9dce11c0 * Setting Java Virtual Memory - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/991635c2a770e75c * Java Swing Design question - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96ea27640cdc1f26 * simple prog in javax.comm not running - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e4091413a3cdbf3 * JAXB : how to get the list of allowed values from an enumeration facet ? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a09f533eb9f4a4e0 * JAXB to get XML attributes - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aabd5d63af2274fc * AffineTransform rotation question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9f275d039d53e16 * Parsing a Schema to build a JTree - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4522b0f7e93fb2de * Commons logging question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c * Help me improve parsing trick? - 4 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ba6b745fd0b06de * static function to change Component properties application-wide - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3680a54fa0625336 * java&php - 2 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dbfc754949e2cb42 * performance of double checked locking - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6881393065d8371a * How to add Java .properties files to Apache Tomcat 4.0 Windows 2K environment - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f02c483545e5973 * opinion on coding standard - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a * specifiy9ing new JVM options?? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb51c2c0c502c9de * Telnet client - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34b0931dc564995f ============================================================================== TOPIC: SimpleDateFormat Help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/91f141dd9dce11c0 ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 1:14 pm From: "P.Hill" [EMAIL PROTECTED] wrote: > The problem with my database is that > in addition to the multiple date formats (yyyy/MM/dd, MM/dd/yyyy, > dd/MM/yyyy), I also have multiple date separators. So how DO expect to differentiate 1-12 followed by 1-12 in the first and second fields? That is certainly a problem. -Paul ============================================================================== TOPIC: Setting Java Virtual Memory http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/991635c2a770e75c ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 11:20 pm From: Daniel Sjöblom Chris Smith wrote: > Your scenario, on the other hand, could possibly avoid an > OutOfMemoryError but not in a very interesting way. Notice that you > basically just got lucky in your "smarterConcat" method. If that last > concatenation had required that the StringBuffer increase its buffer > size, it would have also ran out of memory. No, that is not necessarily the case. It would have in the original example, because I constructed it slightly wrong, but the example below produces the same result (the naive version runs out of memory), but the smarter version can actually double its buffer size without running out of memory. I leave it to the reader to figure out why this happens. public class StringConcatenation { public static void main(String[] args) { final int ITERATIONS = 32; smarterConcat("", ITERATIONS + 20); smarterConcat("", ITERATIONS); System.out.println("Smart is ok"); naiveConcat("", ITERATIONS); System.out.println("Naive is ok"); } public static String naiveConcat(String str, int iterations) { String str2 = new String(new char[250000]); for (int i = 0; i < iterations; i++) str += str2; return str; } public static String smarterConcat(String str, int iterations) { StringBuffer sb = new StringBuffer(str); String str2 = new String(new char[250000]); for (int i = 0; i < iterations; i++) sb.append(str2); System.out.println("StringBuffer capacity after " + iterations + " iterations: " + sb.capacity()); return sb.toString(); } } > Also note that use of a StringBuffer in this situation (concatenation is > a loop of non-trivial size) is always good practice, but that's > primarily because it avoids the work of consistently copying the > character data, *not* because of any probable decrease in the high water > mark for memory usage of the algorithm. The point of the example was obviously not to demonstrate good programming practices, which is why I called the method "smarterConcat", not "smartConcat" :-) -- Daniel Sjöblom Remove _NOSPAM to reply by mail ============================================================================== TOPIC: Java Swing Design question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/96ea27640cdc1f26 ============================================================================== == 1 of 2 == Date: Thurs, Dec 16 2004 1:16 pm From: "Sid" Hi All. To begin with i am pretty new at swing. I have a application wherein i want to render forms from a MenuBAR, meaning user clicks on Add record the add form shows up, search.. edit so forth. What i am doing is i have a single container and in that container i draw the menubar and set up listeners on the items to render respective forms. whenever a item is clicked i clear the container and add the new formpanel. 1. I read that listeners should not be doing too much work as it slows down the response time, so is there any better way to render these individual forms. 2. Going with the same design i needed a Scrollpane to my container and in turn to the forms, I want to add the Scrollpane to all forms so it makes sense to add it to the container but when i do the forms dont clear out anymore and the same welcome form is on the screen. Pseudo code Class A { private container c; FormInterface formInterface; Panel panel; JScrollpane ps; public A() { c = getContentPane(); createMenuBar() // heres where the menu comes and action listeners called. formInterface = new CompanyInfoForm(); panel = formInterface.renderForm(); ps = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); c.add(ps); } Sample action listener public void AddRecordListener() { System.out.println("Add record called"); if (panel != null) { FormPanel.removeFromParent(panel); c.remove(ps); System.out.println("removing panel ..."); } // Create a new form formInterface = new RegistrationForm(connection); panel = formInterface.renderForm(); // Add to Scrollpane ps.add(panel) c.add(ps) ; } The problem here is w/o the scrollpane i can switch between forms just fine its only with the pane i cannot render forms, any help/pointers be greatly appreciated.. Thanks much Sid. == 2 of 2 == Date: Thurs, Dec 16 2004 2:15 pm From: "Yamin" Question 1 Unless you're doing some crazy long calculation or accessing a network/database, don't worry about code in the listener. You'll just end up complicating the code for no reason. Even if you do, depending on the application and its target audience, you might just say 99.99% of the time this operation will take less than 1 second...i'll just block the GUI. Its can be okay for 'load' or 'submit' forms type of operations. Obviously using multiple threads is the proper way to do this. Question 2. First of all, you really only have 1 container that is changing. Since you add the scroll pane (ps) to the container on init, you don't need to add it again. Your listener should really only need to know about the scroll pane and nothing else. // Create a new form formInterface = new RegistrationForm(connection); panel = formInterface.renderForm(); //remove old form ps.removeAll() // Add to Scrollpane ps.add(panel) Not sure if that's the problem though. Yamin ============================================================================== TOPIC: simple prog in javax.comm not running http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6e4091413a3cdbf3 ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 1:18 pm From: "[EMAIL PROTECTED]" but why can't one jre solve the purpose!!! ============================================================================== TOPIC: JAXB : how to get the list of allowed values from an enumeration facet ? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a09f533eb9f4a4e0 ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 1:20 pm From: [EMAIL PROTECTED] (Dj Frenzy) Fromwhat I can tell and have experienced, this is not possible simply by using the xjc command. It will simply just use a String object rather than create a custom class. Whether there is a way round this I'm not sure. ============================================================================== TOPIC: JAXB to get XML attributes http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/aabd5d63af2274fc ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 1:35 pm From: [EMAIL PROTECTED] (Dj Frenzy) Hi, I'm using JAXB to process a XSD and generate a number of classes. I use these classes to build up a JTree with a visual representation of these elements (and attributes). It all works fine except that JAXB gives elements and attributes the same style method names, so just from looking at the generated output I cannot determine which variables are child elements that class, and which are simply attributes. Does anyone have any ideas how I can determine this? Cheers, David ============================================================================== TOPIC: AffineTransform rotation question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c9f275d039d53e16 ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 4:40 pm From: "hilz" Hi all: I have an AffineTransform that has a uniform scale(x scale == y scale). How can i get the rotation portion of it, or the rotation angle "theta" ? One suggestion was to scale it by the square root of the determinant of the matrix, and set the translate portion to 0,0 but that does not seem to give correct values. Can anyone please tell me what do i need to do to get the theta ? thanks hilz ============================================================================== TOPIC: Parsing a Schema to build a JTree http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4522b0f7e93fb2de ============================================================================== == 1 of 3 == Date: Thurs, Dec 16 2004 2:08 pm From: [EMAIL PROTECTED] Chris Smith wrote: > Dj Frenzy <[EMAIL PROTECTED]> wrote: > > Hi, I'm writing an XSLT generation tool in Java, and at the moment and > > working on a facility to display the hierarchical structure of a XML > > Schema. > > > > I know there are examples availible on the net for building a JTree > > from an XML file, but does anyone know of any existing programs which > > will build a JTree for a schema? > > I can't point you to publically available code, but I have done > something very close to this and can give advice. Specifically, you > ought to write your own model class instead of using DefaultTreeModel, > and use org.w3c.dom.Element directly as your tree node objects. If you > use a parser that implements the DOM Events spec, it's fairly simple to > have your model listen for events on the DOM document and translate them > into the appropriate TreeModelEvent. > > Finally, you'll need to install a TreeCellRenderer that's capable of > drawing the items in the way you want (since DOM Element instances > aren't guaranteed to override toString()). > > This isn't terribly difficult, and I can answer any questions you have > here on the newsgroup. > > -- > www.designacourse.com > The Easiest Way To Train Anyone... Anywhere. > > Chris Smith - Lead Software Developer/Technical Trainer > MindIQ Corporation == 2 of 3 == Date: Thurs, Dec 16 2004 3:15 pm From: Chris Smith <[EMAIL PROTECTED]> wrote: > > Chris Smith wrote: [...] Yes, I did write that. Did you have a question or comment? You seem to have sent this without adding your own content. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation == 3 of 3 == Date: Thurs, Dec 16 2004 11:49 pm From: Andrew Thompson On Thu, 16 Dec 2004 15:15:07 -0700, Chris Smith wrote: > <[EMAIL PROTECTED]> wrote: >> >> Chris Smith wrote: > > [...] > > Yes, I did write that. Did you have a question or comment? You seem to > have sent this without adding your own content. Maybe dado0583 thought it was so important that it was worth repeating exactly as is, for emphasis. ;) -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: Commons logging question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 2:23 pm From: "James Zhou" Hi all, I am working on an application that uses jakarta commons logging package to log message. Since I put the log4j jar file under the classpath, I would assume log4j library is used by commons logging. Here is my question: if I put two log4j.properties config files into different directories, and both directories are part of classpath, which log4j.properties config file will be taken? How to debug this kind of classpath problems? Thanks, ============================================================================== TOPIC: Help me improve parsing trick? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/8ba6b745fd0b06de ============================================================================== == 1 of 4 == Date: Thurs, Dec 16 2004 10:33 pm From: "Aaron Fude" Hi, I use this trick for parsing mathematical expressions, that when a user enters sin(x) + cos(x) my program pastes that line into a java class "template", writes the code to some file, runs a shell command to compile it and then loads the class. There are several advantages over something like "JEP". First, I can use any java expression. Second, compiled code then runs much faster. This works but takes too long. Is there a way to speed this up by doing everything in memory and avoid writing to files and running compilation scripts. Many thanks in advance, Aaron Fude == 2 of 4 == Date: Thurs, Dec 16 2004 11:46 pm From: Andrew Thompson On Thu, 16 Dec 2004 22:33:21 GMT, Aaron Fude wrote: > This works but takes too long. Is there a way to speed this up by doing > everything in memory and avoid writing to files and running compilation > scripts. You can avoid the last part by invoking javac from within Java itself. ( But I do not know if that will be any 'quicker'. ) -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane == 3 of 4 == Date: Thurs, Dec 16 2004 11:54 pm From: "Aaron Fude" "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Thu, 16 Dec 2004 22:33:21 GMT, Aaron Fude wrote: > >> This works but takes too long. Is there a way to speed this up by doing >> everything in memory and avoid writing to files and running compilation >> scripts. > > You can avoid the last part by invoking javac from within Java itself. > > ( But I do not know if that will be any 'quicker'. ) > Can you give an example of how to do it? > -- > Andrew Thompson > http://www.PhySci.org/codes/ Web & IT Help > http://www.PhySci.org/ Open-source software suite > http://www.1point1C.org/ Science & Technology > http://www.LensEscapes.com/ Images that escape the mundane == 4 of 4 == Date: Fri, Dec 17 2004 12:13 am From: Andrew Thompson On Thu, 16 Dec 2004 23:54:23 GMT, Aaron Fude wrote: > "Andrew Thompson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >> On Thu, 16 Dec 2004 22:33:21 GMT, Aaron Fude wrote: >> >>> This works but takes too long. Is there a way to speed this up by doing >>> everything in memory and avoid writing to files and running compilation >>> scripts. >> >> You can avoid the last part by invoking javac from within Java itself. >> >> ( But I do not know if that will be any 'quicker'. ) > > Can you give an example of how to do it? a) Can you Google? Try these.. <http://www.google.com/search?q=tools.javac.Main.compile+class> <http://groups-beta.google.com/groups?as_q=class&as_epq=tools.javac.Main.compile&as_ugroup=comp.lang.java*> If no to a) b) How much are you offering for a prepared example? -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: static function to change Component properties application-wide http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3680a54fa0625336 ============================================================================== == 1 of 2 == Date: Thurs, Dec 16 2004 3:22 pm From: "Gert" I know there is a way to change the properties for all, for example, JComboBox components used in an application, with just one function call to a static library. Does anyone here know which function I mean? == 2 of 2 == Date: Thurs, Dec 16 2004 11:43 pm From: Andrew Thompson On 16 Dec 2004 15:22:44 -0800, Gert wrote: > Does anyone here know which function I mean? Maybe somebody on the other group to which you multi-posted, does. <http://www.physci.org/codes/javafaq.jsp#xpost> -- Andrew Thompson http://www.PhySci.org/codes/ Web & IT Help http://www.PhySci.org/ Open-source software suite http://www.1point1C.org/ Science & Technology http://www.LensEscapes.com/ Images that escape the mundane ============================================================================== TOPIC: java&php http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/dbfc754949e2cb42 ============================================================================== == 1 of 2 == Date: Fri, Dec 17 2004 1:24 am From: "codemaster" is there a way to pass data from java application to php-script? == 2 of 2 == Date: Fri, Dec 17 2004 1:29 am From: "codemaster" stupid question :) java.io.FileOutputStream "codemaster" <[EMAIL PROTECTED]> kirjoitti viestissä:[EMAIL PROTECTED] > is there a way to pass data from java application to php-script? > ============================================================================== TOPIC: performance of double checked locking http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6881393065d8371a ============================================================================== == 1 of 1 == Date: Fri, Dec 17 2004 12:32 am From: "Gerald Thaler" >> No, you're wrong here. Any JVM is legally allowed to move instructions >> from >> outside into a synchronized block, and most will do so. So the local >> variable and the synchronized(foo) doesn't help at all. > I think we agree to disagree on this point. We are talking about the new memory model JSR 133 (Java 1.5), not the broken old one? >> The JVM is even >> allowed to fully optimize the synchronized(foo) away if it can proof that >> no >> other thread will ever synchronize on foo/instance. > > I doubt that is possible in the general case. Trivial cases > may be possible, but not worth the extra investment in the > JVM implementation. It is possible. For example use a java.util.Vector locally only in one method as a helper object. This is easy to verify by the compiler/VM. It then can remove all synchronizations inside the code of Vector. Thus the resulting code will run with the same speed as a java.util.ArrayList. It was one goal of JSR 133 to make such optimizations possible. >> For synchronized(foo) to >> enforce memory ordering constraints between two threads in any way, >> _both_ >> threads must synchronize on foo. This isn't the case here. > > The definition for monitor entry/exit does not depend > on whether there is another thread in contention for > the monitor. Memory flushes happen regardless of whether > there is another thread in the picture. No, that's not true. The memory model is not defined in terms of "memory flushes", but in terms of "actions" and "happens-before". synchronized(new Object()) is a no-op. It does not "flush memory". This is explicitly stated in JSR 133. ============================================================================== TOPIC: How to add Java .properties files to Apache Tomcat 4.0 Windows 2K environment http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5f02c483545e5973 ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 3:41 pm From: "nuklea" normally you define it in web.xml like such: <servlet> ... <init-param> <param-name>log4j-init-file</param-name> <param-value>WEB-INF/classes/log4j.properties</param-value> </init-param> ... </servlet> and in your servlet calls: String mypropertyfile = getInitParameter("log4j-init-file"); ============================================================================== TOPIC: opinion on coding standard http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/1f96751a1d317c1a ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 3:58 pm From: "Tim" "Comments" does not denote fully what you or I mean. Most CSci curricula discourage any commented text that duplicates what one can express in code; in contrast, comments that actually convey the purpose of the code are needed. It is the lack of good design documents that can be addressed by proper JavaDocs. In a time of Extreme Programming mythodology, meaningful comments are neccesary to provide design information due to lack of complete and updated design documents. The need for development by prototyping is more from bad, new, and unweildy tools and frameworks rather than any effort at better software engineering. A lack of comments leaves the follow-on programmer the detective's task of analyzing the code, the design documents, and other sources to determine what the author tried to do with the code. I agree that good variable names are preferable. I cannot defend Java's naming standards other than say they impose consistency and work with most word combinations. Other than that I cannot see how they are better or worse than other coding standards. For those that support programming without design (programming by prototyping, extreme programming, or whatever the current fad calls it), here is a counter argument: http://www.cs.utexas.edu/users/EWD/videos/NoorderlichtVideo.html Another statement that is more general to all science is by Tesla that Edison would, when asked to find a needle in a haystack, prefer to pick up each needle one by one to see if it were the needle or hay rather than perform a few basic calculations and determine the probable place to find the needle. Of course, Edison made a lot more money, is better recognized, and was one of the most proliferate patenters of US history while Tesla did not need to employ hundreds of people and has contributed at least as much to our every day lives as Edison. TimJowers ============================================================================== TOPIC: specifiy9ing new JVM options?? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bb51c2c0c502c9de ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 4:24 pm From: [EMAIL PROTECTED] (daniel zhu) Hi, Can anyone point me to some resources on explaining specifying new JVM options? For example, some java profilers have some jvm options like -XRunprofilerDLL or -Xrunpri . How are these things handled? I know the basics of proifiler implementing a profiler agent talking to jvm through jvmpi. But I am not sure how they start themselves and load the tobeprofiled app. And it seems we can also "attach" themselves when the app is running provided the pid is known for the target jvm. How is this working? Thanks. ============================================================================== TOPIC: Telnet client http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/34b0931dc564995f ============================================================================== == 1 of 1 == Date: Thurs, Dec 16 2004 5:10 pm From: Esmond Pitt For telnet I would suggest that you should set the Nagle algorithm off. You should use a BufferedInputStream around Socket.getInputStream() and a BufferedOutputStream around Socket.getOutputStream(), flushing the output whenever you have sent a complete Telnet command or a piece of user input - try to avoid writing just one character at a time. You should also use two separate threads for socket input and output. ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
