java

Plugin Style architecture vs Mavenised Component Style

Which is a better approach to build Java Spring Web Application 1) Plugin Style architecture Ex : Blojsom 2) Component based architecture something like developing features as maven dependents Also can anyone suggest a good plugin style application for reference ...

Java Spring Modular Application Design

Any good resources to learn about designing a good java spring modular application. ...

Regular expression removing all words shorter than n

Well, I'm looking for a regexp in Java that deletes all words shorter than 3 characters. I thought something like \s\w{1,2}\s would grab all the 1 and 2 letter words (a whitespace, one to two word characters and another whitespace), but it just doesn't work. Where am I wrong? ...

Calling a method on an object the type of which I don't know

I have a generic PostProcessor interface that looks like this: public interface PostProcessor<T> { public void process( T t ); } I'm implementing a PostProcessor for generic lists that will call an appropriate postprocessor for each item in the list. public class ListPostProcessor implements PostProcessor<List<?>> { public vo...

How can I draw a chart with a TimeSeries in jfreecharts that doesn't interpolate date values for me?

Hello, I'm trying to display data on a XYBarChart using JFreechart. The chart should display points in time along with a count. Thus, if the user chooses Jan 25 and March 25th as the range, the chart should display data between those dates in certain intervals: if the user chooses HOUR, then I create a collection of every hour from Jan ...

Does a TCP socket connection have a "keep alive"?

I have heard of HTTP keep-alive but for now I want to open a socket connection with a remote server. Now will this socket connection remain open forever or is there a timeout limit associated with it similar to HTTP keep-alive? ...

Java Regular Expression value.split("\\."), The Forward Slash Dot divides by character?

From what I understand, the backslash dot ("\.") means one character of any character right? So because backslash is an escape it should be backslash backslash dot ("\\.") What does this do to a string. I just saw this in an existing code I am working on. From what I understand it will split the string into individual characters. Why do...

Regular Expression in Java: How to refer to "matched patterns" ?

I was reading the Java Regular Expression tutorial, and it seems only to teach to test whether a pattern matched or not, but does not tell me how to refer to a matched pattern. For example, I have a string "My name is xxxxx". And I want to print xxxx. How would I do that with Java regular expressions? Thanks. ...

Regular Expression Question in Java

Sample input: Did xxx xxx xxx (could be any number of words) live or die? For example: Did Michael Jackson live or die ? I want to capture: Michael Jackson, live, die. The sentence can have any number of spaces between words. How do I do it? ...

Java, reading a file from current directory?

I want a java program that reads a user specified filename from the current directory (the same directory where the .class file is run). In other words, if the user specifies the file name to be "myFile.txt", and that file is already in the current directory: reader = new BufferedReader(new FileReader("myFile.txt")); does not work. W...

How to check the scalability of my application

I have developed an application that will create lot of PDF's and serve those file. (Its normal Servlet-Buffering serving). How to make sure my application works efficient with multiple request? Is there any tool available to test the load/scalability/efficiency and how many parallel request does my code handle with the current server ...

Java EE technologies after learning SE?

Ok so there are lots of nifty little technologies included in Java EE. When one learns SE, where should they go from there? I think what I'm looking for is more abstract/high level technologies that pertain to EE. I want to learn more and it seems to be difficult to find a book to transition into EE from SE. Where should I go from here? ...

JSP: send request and get response XML

Hi guys. I want to setup a JSP page to: to call DDR server with address: http://ddr.mobileok.kr/profile/DeviceProfile.do with parameter is: ?mn=SCH-W420 (so i will request: http://ddr.mobileok.kr/profile/DeviceProfile.do?mn=SCH-W420 ) after get the return result is XML format Note: I tried get "XML return result" from DDR server wit...

Need help in passing Java Generics to Collections.sort()

Hi, I need help in passing a Java Generics List to Collections.sort(). Here is my code: List<MyObject> orgMyObjectList = new ArrayList<MyObject>(); Collections.sort(orgMyObjectList, new Comparable<MyObject>() { public int compareTo(MyObject another) { // TODO Auto-generated method stub return 0; ...

A regular expression question

In Java's regular expression, I want to match any sentence that contains the word "Mary" and the word "are" in that order, but DOES NOT contain "Bob" in between "Mary" and "are". Eg: Mary and Rob are married - MATCH Eg: Mary and John and Michael became good friends and are living together <- MATCH Eg: Mary, Rob and Bob are dead <- does ...

How can I slice an ArrayList out of an ArrayList in Java?

How do I get an array slice of an ArrayList in Java? Specifically I want to do something like this: ArrayList<Integer> inputA = input.subList(0, input.size()/2); // where 'input' is a prepouplated ArrayList<Integer> So I expected this to work, but Java returns a List - so it's incompatible. And when I try to cast it, Java won't let m...

Regular Expression Question

How do I match a list of words using regular expression. Like I want to match This is a apple This is a orange This is a peach I tried "This is a [apple|range|peach]. Does not work. Any ideas? I've sent 5 hours on this, there are "rules" published, but without exhaustive examples, these rules are too mystic. ...

Java Graphics library

I'm looking for a high-level java graphic library for creating artistic text, watermarks, resize, crop, image identification and manipulation. ImageMagic is a good example of such library, but its java ports are somewhat problematic (they either run imagemagic through JNI or via commandline and are hellish to deploy to servers). Ideally ...

Java regexp: How common is it? And how much resource does it use?

Hi I have a quite general question about java and regular expression. If we lock at embedded use, say mobile phones with J2ME or Android, how common is it that regexp is included and how resource hungry is it? I mean regular expression is a powerful beast, and a lot of magic is done in the background to make it happen. And my questi...

Unit testing a Swing component

I am writing a TotalCommander-like application. I have a separate component for file list, and a model for it. Model support listeners and issues a notification for events like CurrentDirChanged etc. in following manner: private void fireCurrentDirectoryChanged(final IFile dir) { if (SwingUtilities.isEventDispatchThread()) for...