java

Java: Trouble with Generics & Collection type detection

I have a class called DataSet with various constructors, each specifying a different type of variable. It might look a bit like this: public class DataSet { private HashSet Data; public DataSet( DataObject obj ) { Data = new <DataObject>HashSet(); Data.add( obj ); } public DataSet( ObjectRelations...

Object persistence strategy for desktop application

I am developing a Java based desktop application. There are some data generated from the application object model that I need to persist (preferably to a file). There is also a requirement to protect the persisted file so that others can't derive the object model details from the data. What's the best strategy for doing these? I was in t...

Java: Is there an easy, quick way to AND, OR, or XOR together sets?

That is, if I had two or more sets, and I wanted to return a new set containing either: All of the elements each set has in common (AND). All of the elements total of each set (OR). All of the elements unique to each set. (XOR). Is there an easy, pre-existing way to do that? Edit: That's the wrong terminology, isn't it? ...

Quick Java question: Cloning and subtracting sets - does this work?

private HashMap<DataObject, HashSet> AllDataObjects; ... /** Returns all DataObject elements that are NOT in the specified set. */ private DataObject[] invert( HashSet<DataObject> set ) { HashSet<DataObject> keys = (HashSet) AllDataObjects.keySet(); keys = (HashSet) keys.clone(); keys.removeAll( set ); return (DataObj...

Passing superclass as parameter to method expecting sub class

Hello, I have an object tree that looks something like Ball / \ LegalBall IllegalBall And I have 2 methods: class o { AddBall(LegalBall l) AddBall(IllegalBall i) } in another class I'd like to do the following: o.AddBall(myBall); where myBall is of type Ball. And get it to call the correct method de...

best open source ODBMS for java

Could you advise the best open source ODMBS (object oriented database management system) for Java application? I understand that usually there is no one definite answer for such questions. So the main points I look for are: good documentation/ support / community reliability performance UPDATE: I see db4o has a long history, the b...

Running Jar file in Windows

I have a "helloworld.jar" file. For running a JAR file I am using a command-line window and executing the following command: java -jar helloworld.jar By using this command I can execute the JAR file. But instead of doing it in a command-line window, I want to execute the JAR file if I double click on the JAR file. I did some Googl...

Can RowSets be used with PreparedStatements?

I have just found RowSets for database querying with JDBC. They are stateless and cacheable, they look to be superior to ResultSets. Can PreparedStatements be used with them though? PreparedStatements are a performance booster for querying very large databases, and not something I would want to give up (before something is said, this is ...

MVC in Java

Hi all, This is about a school assignment so I'm trying to do things by the book. I feel like I'm getting the grips of Java, but good programming practice, design patterns, etc. are all rather new to me. I've made my model and it works fine. It contains a student class which contains a number of fields with student information (obvious...

Quick Java question: Casting an array of Objects into an array of my intended class

Just for review, can someone quickly explain what prevents this from working (on compile): private HashSet Data; ... public DataObject[] getDataObjects( ) { return (DataObject[]) Data.toArray(); } ...and what makes this the way that DOES work: public DataObject[] getDataObjects( ) { return (DataObject[]) Data.toArray( new D...

Best way to separate Business from Presentation Logic?

I want to create a game that will work both locally and online. My first thought was to create an interface that would have all the methods that will be needed by the GUI for the business logic and then have a network implementation and a local implementation. This works fine for request-response messages. But what about messages that ...

Advantage of using NIO vs BIO in jetty ?

Any experience on the tradeoffs in terms of nio vs bio when having heap and computationally intensive process executed for every query with execution times in (100ms-900ms) range ? ...

lossless video codec playback in Java

I need to encode a sequence of frames with a lossless video codec and play them in a Java app. I don't care about the file size. The output frames should match the input frames exactly. Lossy codecs don't do this even at high bit rates. None of these well-known lossless video codecs appear to be supported in JMF or FMJ: HuffYUV CorePN...

SAML identity provider as Java servlet filter?

Can anyone recommend one? Thanks -Morgan ...

Printing Java collections nicely (toString doesn't return pretty output)

I wish to print a stack object as nicely as the Eclipse debugger does, ie [1,2,3] etc. printing it like so out = "outout:"+stack doesn't return this nice result. Just to clarify. I'm talking about Java's builtin collections I can't override their toString. How can get the nice printable version of the stack? ...

How to animate a window with Processing?

I am using Processing to learn programming and wondered if there is a way to make an OS window grow, shrink, make it transparent or give it round edges. As far as I know Processing uses Java's Frame class and not the JFrame class, but I just can't figure out how to do this. Thanks for your help. For reference, similar question asked at...

Best Java library for automatic language identification?

Which is the best Java library for automatic language identification/classification? Hypothetical syntax: String languageCode = LanguageIdentificationAPI.identifyLanguage("Hello world."); // languageCode would now contain "en" for English. Thanks a lot in advance! ...

Java graphic library for multicoloured text

I would like to know the recommended library or procedure for dealing with multi-coloured text within Java. My current usage of java.awt.Graphics, while function, appears to be a bit more complex than necessary. The main issue involves the frequent change of colour, creating a new java.awt.Colour() object whenever a new colour is need...

What are the steps I need to take to add nice java code formatting to my blogger/blogspot blog?

I'm looking for a sequence of steps to add java code formatting to my blogspot blog. I'm really looking for a dummies guide - something so simple a cleaner could follow it if they found it on a piece of paper on the floor. ...

Reference Groovy domain class from Java class using Eclipse?

How can I reference a Groovy domain class from Java class using Eclipse? I've put my domain class in package: package com.me.myproject public class Person { String name int age } Then in my Java class I attempt to reference com.me.myproject.Person. This works for grails run-app (command line) but not Eclipse. Eclipse can't re...