java

ASTVisitor in Eclipse

Hi, I am learning how to do an ASTVisitor for a project, so I started using Eclipse, which has a comprehensive API for that. I have downloaded the Packed Example Project from this website: http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation%5FAST/index.html But I realised that the codes do not have a main() m...

Problems while saving a pre-persisted object in Google App Engine (Java)

I am having problems while saving a pre-persisted JDO object in google-app-engine data store. Basically, in one servlet, I create the object and save it. In another servlet, I read the object, set a bunch of properties and try updating it. The update is through a makePersistent call on PersistenceManager. There is no exception being thro...

How do we count rows using Hibernate?

For example, if we have a table Books, how would we count total number of book records with hibernate? Thanks ...

How to obtain class instance generic argument type

In code, if i write a code line like: gClass<Double> x = new gClass<Double>(); And let say, that class is like: public static class gClass<T> { private T value = null; public gClass() { // What is T? } } Where i inserted the question: "What is T?", i don't want the value (what is null), but its type (what is instanceof Doubl...

UserNameToken in soap from Java

Hi, I am trying to use a gSoap-generated wsdl from Netbeans. The webservice requires that the UserNameToken be passed in. When I use the wsdl from SoapUI (which works), it sends this: <wsse:Username>myname</wsse:Username> <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordTex...

XStream short dynamic aliases

I want to have short names for classes, now i can do it with aliases XStream x = new XStream(); x.alias("dic", Dic.class); but i have to define alias manually for every class, is there any way to configure xstream to do it automatically? ...

Can't retrieve urlencoded umlauts. [solution: use UTF8]

Hello, I'm programming some websites with JSP-Scripting and I encounterd a strange problem with urlencoded web-formular parameters. The site itself is encoded in iso-8859-1. I have a simple webform with a field called description. If I enter german Umlauts or specialchars like "ü" or "ß", these get automatically urlencoded. But if I wa...

Algorithm to filter a set of all phrases containing in other phrase

Given a set of phrases, i would like to filter the set of all phrases that contain any of the other phrases. Contained here means that if a phrase contains all the words of another phrase it should be filtered out. Order of the words within the phrase does not matter. What i have so far is this: Sort the set by the number of words in ...

Problem sending Apple Push Notification using Java and REST.

Hello there, This is a follow up to my previous posting on StackOverflow. Figured its better to start a new post (since I made more progress than before) rather than appending a new question on a previous thread. Am using the Javapns library on Google Code to send an Apple Push Notification through a REST based web service... Here ar...

Class is a raw type. References to generic type Class<T> should be parameterized

There are lots of threads about this type of question, but I want to get a complete answer and actually understand it without 'hiding' the problem with a @SupressWarnings ! I have the following class (from a simple Spring tutorial) public class CarValidator implements Validator { public boolean supports(Class aClass) { return Car.cla...

How to convert a String into an array of Strings containing one character each

I have a small problem here.I need to convert a string read from console into each character of string. For example string: "aabbab" I want to this string into array of string.How would I do that? ...

Java mouse pressed - without events

Hi, is there a way, in Java, to directly check whether one of the mouse buttons is down without using events, listeners etc. ? I'd like to have a thread that, every 100 milliseconds or so, checks whether a mouse button is down and then does something. So if the user holds a mouse button down for a while it will trigger several responses...

java browser using mozilla webclient

I am creating the a browser using mozilla web client by invoking setAppData() on BrowserControlFactory.I have placed xulruuner at c:\demo folder. code of program is as follows : Editor() { setVisible(true); setSize(200,200); try { BrowserControlFactory.setAppData("c:\\demo\\xulrunner"); ...

Spliting child node from XML file into their own XML files

I have an XML file below and I want to create multiple files: <ParentNode> file1: <ChildNode> <ParentNode> <node></node> <ChildNode> </childNode> <node></node> <ChildNod...

Analysing Thread behaviour in Java

I need to draw a graph of write accesses of two concurrently running threads. What is the best way to write a timestamp value pair of these accesses to an array, without interfering with the threads themselves? The queue that is being written to looks like this: import java.util.concurrent.atomic.AtomicInteger; class IQueue<T> { A...

How and where are Annotations used in Java?

What are the major areas that we can use Annotations? Is the feature a replacement for XML based configuration? ...

System level changes for JVM

Hi, What are the architectural/system level changes has to made if I want to develop a JVM (Java Virtual Machine) like tool/application for Windows and Linux? Basically, What are the architectural differences in JVM wrt Windows & Linux? Thanks, Naveen ...

ORM tools for Java

Any ORM tools available for java other than Hibernate, with high scalability. ...

Should a collection of constants be placed in a class or interface?

If I have a collection of static constants that I want to declare centrally so that they can be shared among various projects should they be put in a class or interface (Java). In the past I have seen them mostly put in a class but I started thinking that since the class will not and should not be instantiated maybe they would be better...

Java Sound API noise after processing the byte array with a fraction number

Hi, I'm trying to process my byte array which I got from the sampled sourcedataline (Java Sound API). If I'm multiplying the byte array with a fraction number, I will get noise while playing the stream. Before I'm playing the sound I separate the stereo wav file into his left and right channel. This works fine. But if I want to proce...