java

How to get current Transfer Rate in Commons HttpClient 3.x

I have some code that does a bunch of HTTP GETs, POSTs, and PUTs using Commons HttpClient 3.1. I'd like to provide a current transfer speed indicator in my GUI, but was unable to find any methods for determining the transfer rate of a HttpMethod being processed. I could easily just time the transfer and do some simple math after it was...

How do I validate a Word 2007 File against wml.xsd with Java?

I would like to validate a given Word 2007 XML file against the Schema defined in wml.xsd. How could it be done in Java? Loading the Schema with the following line is not a problem. But it seems that I have to tweak the validation process becaus I get error messages even on valid input files (I could open and view the input file in Word ...

Java AWT/SWT/Swing: How to plan a GUI?

hello I've already realized some applications with a small graphical user interface. Nothing complex, but I've encountered several problems that components aren't displayed or just not behaving as expected. Now my question: How do you plan those user interfaces? What do you do when you need to make changes? How do you debug strange be...

Connection and Collection Interfaces in Java

Which class implements all the Connection Interfaces which are in javax.microedition.io package and how? And in the same way which class implements the some of Collection interfaces like Iterator interface. I saw a code: - Iterator it; ArrayList list = new ArrayList(); it = list.iterator(); The iterator() return type is "Iterator"...

Different lucene search results using different search space size.

I have an application that uses lucene for searching. The search space are in the thousands. Searching against these thousands, I get only a few results, around 20 (which is ok and expected). However, when I reduce my search space to just those 20 entries (i.e. I indexed only those 20 entries and disregard everything else...so that deve...

Java Dropdown Checklist

I understand how to make a multiple-select list box using JLists but I want to add JCheckBoxes to the list and make it dropdown like. The best visual representation I have found online is dropdown-check-list. What would be the best way to accomplish the above? I was thinking of a TableList. Any suggestions? ...

How to make entire window aero glass in Java?

I am trying to program a small application but I would like the entire window to be glass with buttons and labels on top of it. Is it possible to do this within Java? ...

How to synchronize Swing model with a rapidly changing "real" model?

As is widely known, anything related to Swing components must be done on the event dispatch thread. This also applies to the models behind the components, such as TableModel. Easy enough in elementary cases, but things become pretty complicated if the model is a "live view" of something that must run on a separate thread because it's cha...

Embedded jetty ServletTester serving single static file

I'm unit testing with jetty and I want to serve not only my servlet under test but a static page as well. The static page is needed by my application. I'm initializing jetty like this tester = new ServletTester(); tester.setContextPath("/context"); tester.addServlet(MyServlet.class, "/servlet/*"); tester.start(); What I need now, is s...

Hibernate + Spring + persist one-to-one relation + empty foreign key

Hello, I am trying to persist a one-to-one relation with Spring 1.2.8 and Hibernate 3.2.7ga but the foreign key is always empty. But let me first give you a short introduction: I have two Entities called "ClientDomain" (Web-Domain) and "Measurement". Hibernate Mapping Files: ClientDomain.hbm.xml: <hibernate-mapping package="statist...

flush in java.io.FileWriter.

I have a question in my mind that, while writing into the file, before closing is done, should we include flush()??. If so what it will do exactly? dont streams auto flush?? EDIT: So flush what it actually do? ...

Should references in RMI exposed services be transient?

I'm exposing some services using RMI on Spring. Every service has a dependency to other service bean which does the real processing job. For example: <bean id="accountService" class="example.AccountServiceImpl"> <!-- any additional properties, maybe a DAO? --> </bean> <bean id="rmiAccount" class="example.AccountRmiServiceImpl"/> <...

Weblogic 10.3.1 gives 'Dependency injection failure' warning when publishing code

Weblogic 10.3.1 gives me a "Dependency injection failure" when I publish my code; the publish itself succeeds. I am working via Eclipse. Basically I publish an ear with a web service aaa.MyWebServicePort that has a bean bbb.MyBean declared as local variable with the ejb 3.0 @EJB annotation. bbb.MyBean is also in the ear as well as a cl...

How is a union different from a struct? Do other languages have similar constructs?

Possible Duplicate: Difference between a Structure and a Union in C I see this code for a union in C: union time { long simpleDate; double perciseDate; } mytime; What is the difference between a union and a structure in C? Where would you use a union, what are its benefits? Is there a similar construct...

Easiest way to call Java from C#?

We have a major body of code in Java that runs on the desktop that we want to reuse with a MS.NET user interface (desktop rather than web). Any do's or don'ts would be very welcome. ...

How to get good perfomance of Regex in java

Below is example of text: String id = "A:abc,X:def,F:xyz,A:jkl"; Below is regex: Pattern p = Pattern.compile("(.*,)?[AC]:[^:]+$"); if(p.matcher(id).matches()) { System.out.println("Hello world!") } When executed above code should print Hello world!. Does this regex can be modified to gain more performance? ...

Most compact way to compare three objects for equality using Java?

What's the most compact code to compare three objects for (semantic) equality using Java? I have a business rule that the objects must be unique i.e. A is different to B, A is different to C and B is different to C. Assume that the objects are all of the same class and have correctly overridden equals and hashCode methods. A slight wrin...

accept supertype of generic parameter on single object?

is it possible somehow to accept only super types of the generic Type of a class? what im looking for is something like: class <T extends Object> MyClass { public <TS super T> void myMethod(TS someObjectSuperToTheClass) { //do stuff } } i don't really need it anymore (and its probably not all that usefull to begin with) but I'm ...

Java SocketChannel Eating my bytes

Hi, I created a SocketChannel to a remote server to send and receive messages on Tomcat. To receive messages from a remote computer, I used a thread dedicated to task (only this thread will read from the socket, nothing else). When some bytes are received at the SocketChannel (I keep polling the SocketChannel on non-blocking mode for n...

Are there any tools similar to XML Beans for 834 files in JAVA

I love the pleasure of dealing with XML files with XMLBeans objects... Now working with 834 files, i wonder if its a similar tool for 834 files A flat file object will be helpful also thanks Chung ...