java

Java: RegEx Problem (using the '.' all character symbol)

I have some document stored as a large String. In the String I have some inline XML tags and I want to get out the words inbetween the tags. The documents may also contain HTML tags, as the documents are often web sites. Example Document: "< tr > My name is < b >< PERSON >Bobby< /PERSON >< /b >, I live in the USA." Current RegEx: ...

hibernate @GeneratedValue correct?

I set my entity property @GeneratedValue Long id; and I able to generate id for the entity in database. My question is why all the entities are sharing the same incremental number? aren't each table should start counting from zero? ...

Save object in debug and than use it as stub in tests.

My application connects to db and gets tree of categories from here. In debug regime I can see this big tree object and I just thought of ability to save this object somewhere on disk to use in test stubs. Like this: mockedDao = mock(MyDao.class); when(mockedDao.getCategoryTree()).thenReturn(mySavedObject); Assuming mySavedObject - is...

Problems with Java Utility App on Mac OS 10.6

I have problems with my java utility application on Mac OS. When I try to start it I get 26.11.09 10:00:04 [0x0-0x29029].com.apple.java.JavaPreferences[984] [JavaAppLauncher Error] CallStaticVoidMethod() threw an exception 26.11.09 10:00:04 [0x0-0x29029].com.apple.java.JavaPreferences[984] Exception in thread "main" java.lang.NullPoi...

How do I get the current time in a different TimeZone in Java?

OK - I feel pretty dumb asking such a basic question, but hey. I'm trying to get the current time in a different timezone in a Java webapp. I've tried the following obvious solution: in my servlet, Calendar localCalendar = Calendar.getInstance(myBean.getTimeZone()); then I pass the calendar object through to a JSP as a request attribu...

Couldn't understand this method summary at Apache commons API documentation

I've found this method summary from Apace Commons APIDOC but I don't understand how to use it. byte[] decode(String pArray) Decodes a String containing containing characters in the Base64 alphabet. Can you give the example of the syntax. I couldn't find the syntax in APIDOCs. PS : this is from base64 decoding part. I under...

Java's WeakHashMap and caching: Why is it referencing the keys, not the values?

Java's WeakHashMap is often cited as being useful for caching. It seems odd though that its weak references are defined in terms of the map's keys, not its values. I mean, it's the values I want to cache, and which I want to get garbage collected once no-one else besides the cache is strongly referencing them, no? In which way does it h...

Java: synchronized method

Dear all, we have two threads accessing one list via a synchronized method. Can we a) rely on the run time to make sure that each of them will receive access to the method based on the order they tried to or b) does the VM follow any other rules c) is there a better way to serialize the requests? Many thanks! ...

attributeRemoved not being called after session.invalidate

I have a object that implements the HttpSessionAttributeListener, and as you'd expect it does some work when certain objects are added, replaced and removed from the session. I thought that the if the session is ended [session.invalidate()], each object from that session is removed from the session as so the attributeRemoved() method ...

Java - Create a new String instance with specified length and filled with specific character. Best solution?

I did check the other questions; this question has its focus on solving this particular question the most efficient way. Sometimes you want to create a new string with a specified length, and with a default character filling the entire string. ie, it would be cool if you could do new String(10, '*') and create a new String from there,...

Unit testing ModalWindow's content refresh fails while the actual functionality works as expected - what am I doing wrong?

So, I've spent a couple of hours first trying to "fix" this myself and then Googling like a madman but didn't find anything that would've helped so now I'm here. Basically I have a custom Panel within Wicket's own ModalWindow and since I like unit testing, I want to test it. The specific behavior here is refreshing the ModalWindow's con...

Is it possible to have a JMS server without an application server?

Hi, does anyone here knows if there exists a JMS server that could be executed on Tomcat or without an application server? ...

Crowdsourcing a Complete list of Common Java System Properties and Known Values

I've been inspired by another question: Best Practice for Using Java System Properties I'm currently looking for a complete list of Java system properties and possible values. I'm working on a simple class to simplify use of them (If you're interested, get the source and background info (my blog)). With this class, I try to provide the ...

rotate shape java2d without losing its origin

protected void paintComponent(Graphics g) { Graphics2D gr = (Graphics2D) g.create(); // draw Original image super.paintComponent(gr); // draw 45 degree rotated instance int aci=-45; gr.transform(AffineTransform.getRotateInstance(Math.toRadians(aci))); super.paintComponent(gr); //translate rotated instanc...

Store Password Field in Encryption Form Using MySQL and Hibernate

I am using Spring, Hibernate for developing my application. And as DB side, I have MySQL. I have an User table and that has password field of varchar type. Now, when a new user is created, I just want store password field in an encrypted form. Is there any facility provided by Hibernate to do so? Or is there any other way? ...

How can I get read all the parameters of an applet?

There's getParameter() which is fine for reading a parameter I know of. However, should I want (for lib architecture reasons) to read all the parameters that have been passed to an applet, is there a way to do it? I've looked at the API and googled a bit, but no luck. ...

Why does Java string have a copy constructor?

Possible Duplicate: What is the purpose of the expression new String() in Java? It's immutable, why would you need to invoke String.String(String str) ? ...

Android Frame by Frame Animation problem on elements in a CursorAdapter

Hi, I am having trouble applying an animation to a View. I am trying to load the animation from inside the constructor of a CursorAdapter, so I can set it later assign it to certain children in the list. In the constructor I have : shineAnimation = AnimationUtils.loadAnimation(ctx, R.anim.news_list_item_shine); the animation is in m...

Using a returned string to call a method?

I have an ArrayList and wish to be able to call an index and use the returned string for a method call. e.g. stringList.get(2)(); Is there any way I could go about this? ...

How to disable scrolling from mouse wheel in a JScrollPane header ?

Hello, I am currently working on a SWING frame with a JScrollPane (including a JComponent), with a row header and a column header (which are also JComponents). When the mouse is over the JComponent or one of these 2 headers, mouse wheel provokes scrolling. What I want to do is to disable this scrolling when the mouse is over the column...