java

Efficient persistent storage for simple id to table of values map for java

I need to store some data that follows the simple pattern of mapping an "id" to a full table (with multiple rows) of several columns (i.e. some integer values [u, v, w]). The size of one of these tables would be a couple of KB. Basically what I need is to store a persistent cache of some intermediary results. This could quite easily be ...

.NET equivalent or alternative to Java's GlyphVector?

I'm in the process of porting a Java program to .NET using IKVM. Unfortunately IKVM's Graphics2D implementation throws a NotImplementedException in drawGlyphVector, i.e. it needs to be "fleshed out" with a .NET implementation (or by reducing it to calls of other IKVM Graphics2D methods which are implemented). Any ideas for an equivalent...

Regex for removing comma in a String when it is enclosed by quotes

Hi, I need to remove commas within a String only when enclosed by quotes. example: String a = "123, \"Anders, Jr.\", John, [email protected],A" after replacement should be String a = "123, Anders Jr., John, [email protected],A" Can you please give me sample java code to do this? Thanks much, Lina ...

Scalability of J2EE Application. How would you approach it?

I've been working on the solution for financial industry. The main functionality of the application is the ability to load massive input files, digest them, update state in persistent store and generate extracts from persistent store on request. Pretty straightforward. The input files are industry standard formatted XML large (more that...

Change the Ctrl + click behaviour on a JTable

Is there an easy way to manipulate the controls on a JTable to give different functionality when there is a keyboard button pressed (ie. CTRL button) and a row is selected? I've been asked to create a table where the CTRL + Click (mouse click) on a row will only deselect a selected row, never select a row. If the user CTRL + Clicks an un...

Why are interfaces preferred to abstract classes?

I recently attended an interview and they asked me the question "Why Interfaces are preferred over Abstract classes?" I tried giving a few answers like: We can get only one Extends functionality they are 100% Abstract Implementation is not hard-coded They asked me take any of the JDBC api that you use. "Why are they Interfaces?". C...

How do I write StoredProcedure sub-classes to call Oracle functions?

I've written the following Spring JDBC API StoredProcedure sub-class: class GetLdapPropertiesStoredProcedure extends StoredProcedure { protected GetLdapPropertiesStoredProcedure(JdbcTemplate jdbcTemplate) { super(jdbcTemplate, "get_ldap_properties"); setFunction(true); declareParameter(new SqlReturnResultSet("rs", new Produ...

OptimisticLockException when trying to fetch data from postgreSQL

We're developing a WebSite that's intended to have several requests per second.- Our current environment is JavaEE, JBoss 4.2.3, Struts2 for MVC, JPA with Hibernate as ORM and Postgres as DB.- This is the scenario: whenever a request comes to any of the pages, some action checks for information in the DB to fill the requested page (tha...

Howto perform a MULTIPLY composite effect using Graphics2D

I have two different javax.swing.Icon objects and I want to a create new Icon which is the composite of these two. I want the composite to be a MULTIPLY effect, similair to what you would get in any photoshop-like image editing application when you choose that option. Specifically, per every pixel, if you have color Ca and Cb from image ...

Howto embed Tomcat 6?

I'm currently running my webapps on Tomcat 6 in production, and would like to evaluate running Tomcat in embedded mode. Is there a good tutorial or other resource besides what's in the api documentation? ...

Java to transcode and manipulate mp3 files

I am looking for a java library to efficently/fast transcodig and manipulation mp3 files. I am working on a sophisticated streaming server that mixes music and has some other functions to allow to users to interact with each other. A recommendation functonallity for example should fade over the stream of the sending user to the reciever ...

Is Jasper Reports the appropriate solution to display reports in a web application?

We want to generate Reports either embedded as html pages in a web app or downloadable as a pdf. Hence I came across Jasper Reports because it thought it would fullfill these requirements. Currently we assume our report will have about 50-100 pages, consisting of nearly only histograms and some tables. The data is retrieved by some exp...

What is the best IDE for developing in Tomcat?

Recently I've been doing a bunch of work developing servlets for deployment in Tomcat 5.5. My current IDE is Eclipse Ganymede with WTP. I've been very unhappy with the Tomcat integration, as the configuration is constantly breaking and needing tweaking. I was wondering if anyone could recommend another IDE that handles this integrat...

Mapping XPath 1.0 data types to java

I'm using XPath 1.0 to process incoming web services messages. This can be quite hard to get right if schema data types are used, because XPath 1.0 does not recognize them (XPath 2.0 does, but there seems to be no full open source implementation. Not sure if Saxon-B does this). E.g., the literals "true" and "false" in a xs:boolean repr...

Declarative validation of forms in Java/Swing

I use Java for client-side development with Swing. I love Swing; I believe it is one of the better GUI frameworks there. What I miss, however, is the support for declarative validation. Like this snippet from XForms. Do you know any library which allows validating data entry in forms in a declarative way, not by writing ugly validation ...

j2me - Rotate array of 2d points in 45 degree increments

I'm working on a roguelike style cellphone game that operates on a grid. Attacks/Items in this game operate by targeting tiles in a pattern relative to the user. The paturn is usually relative to the direction the user is aiming in as well, For instance in this screenshot the pattern Point2d[] damageTiles = new Point2d[4]; ...

Is there anything dangerous about using Thread.currentThread.sleep() in my main code?

in my code I'm using Thread.currentThread().sleep(sleepTime); in the main (non Thread object) portion of the code. It appears to be working fine, but I'm worried that there might be some hidden pitfall that will bite me in the ass later. Is there a better way to make your main process sit around for a while? or is this the prescribe...

Java Swing custom text JEditorPane

I have a list of Objects (the model) that are constantly appended to (similar to a log file) and I'd like to display as rich text in a JEditorPane (the view). How can I glue them together? http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#document doesn't seem to give enough information to use. ...

Component in a JScrollPane stops receiving KeyEvents

I am putting a component ( derivative on JPanel ) inside a JScrollPane. scrollPane = new JScrollPane(component); since the component occasionally changes size, I have to occasionally do : SwingUtilities.invokeLater(new Runnable(){ public void run() { scrollPane.getViewport().setView(component); ...

Strategy for detecting an object in JTable row?

Here's the thing: a sortable JTable backed by JTableModel with an array of objects that populate rows (one object = one row). Need to delete rows. Without sorting, deleting an object is simple: get selected row index, delete array object under the same index. With sorting, though, row indexes mess up in a sense that they no longer match...