java

Intellij IDEA plugin for saving Java -> HTML?

Is there an IDEA plugin for pretty printing (or save/export) Java to syntax colored HTML? Failing that, what's your favorite web site for that? EDIT: I have a Java program, I want to convert the source code to HTML so that I can display it on the web. As I will be making lots of edits to the source, it would be handy to be able to con...

Optimizing equals() method

The equals() method (and for that matter, also the compareTo() method) can become a performance hotspot (e.g. in a high-traffic HashMap). I was wondering what tricks folks have adopted to optimize these methods for these cases when they prove necessary. IntelliJ IDEA, for example, generates the following: public boolean equals(Object o...

Generic Class Problems!

I have been research this all day and I cannot find a solution. I understand the problem of using subclasses and how the compiler wont know what the class will actually be because of the possibility of setting setting it to something else before calling add. I have look everywhere and I still don't know how to fix this problem. I have an...

Best way to accomplish inter-activity communication in an Android TabHost application

Here's the deal: I have an Android application that needs to call a web service every X seconds (currently 60 seconds). This application has multiple tabs and these tabs all need to interact with the data themselves. One is a MapView, one is a ListView and then the third is irrelevant but will need to also get some global data eventually...

What object should I lock on when I am passing a Collection<Foo> into a separate class ?

Please refer to UML The Connection class's constructor initializes its foos member via foos = Collections.synchronizedList( new ArrayList<Foo>(10) ); When Connection#start() is invoked, it creates an instance of Poller (while passing the foos reference into Poller's constructor) & Poller is started (Poller is a Runnable). Question: ...

How is values() implemented for Java 6 enums?

In Java, you can create an enum as follows: public enum Letter { A, B, C, D, E, F, G; static { for(Letter letter : values()) { // do something with letter } } } This question concerns the "values()" method. Specifically, how is it implemented? Usually, I could jump to the source for Java classes us...

Java for a video based application: Good choice?

I am in the concept phase of an application that is going to have a lot of Audio/Video input and output. I want to do it in Java; but somehow am not fully convinced yet. What do you think? How bad could it be? And any advices? Why I am thinking Java: It's the language I'm most comfortable with. Easier cross platform migration would be...

Problem in Wicket

I have a page by name BranchMap that uses GoogleMap to show some building to user after he has logged in. the data was at first in protected(password required) situation (in CategoiresXML which extends ProtectedPage) but i found that google can't log in the system and make the page extended from WebPage. But now when I go to BranchMap pa...

POJO vs EJB vs EJB 3

Does anyone have any example of what a Java Class might look like as a POJO, EJB, and EJB 3? I'm trying to understand these java technologies but am having trouble. I was hoping it would help if I could see what an implementation of all three would look like. ...

can Use Hibernate and Tomcat Connection pool at same time?

Hi every one, I have a java web Application and I use Tomcat connection pooling for it, this my setting: <?xml version="1.0" encoding="UTF-8"?> <Context path="" docBase="" debug="5" reloadable="true" crossContext="true"> <Resource name="jdbc/jdbcPool" auth="Container" type="javax.sql.DataSource" maxAc...

Why use Gradle instead of Ant or Maven?

What does another build tool targeted at Java really get me? If you use Gradle over another tool, why? (See also Why use Buildr instead of Ant or Maven) ...

Java secure session

Whenever you authenticate, your application should change the session identifier it uses. This helps to prevent someone from setting up a session, copying the session identifier, and then tricking a user into using the session. Because the attacker already knows the session identifier, they can use it to access the session after the user...

Access Java RMI from .NET

Hi, I have a existing java based system which uses RMI. I do not have access to change this system. I want to be able to call the RMI api methods directly from .NET. What is the best way to accomplish this? Free or lowish cost preferred if its a third party component. Thanks ...

Function Pointer in Java

I'm writing a Login page in wicket by java and want to write it as general as possible so I need to pass to class a function which famous as Function Pointer in C++. The class is: class LoginForm extends Form { public LoginForm(String id,TextField username,TextField password,WebResponse webResponse) { super(id); } ...

Missing activation DataHandler class

I have a java programs that outputs a warning for missing javax.activation.DataHandler and javax.mail.internet.MimeMultipart I'm not sure what these are used for, nor can I recall adding any specific code that may require these classes. I realize the warning can be resolved by adding the activation.jar and mailapi.jar, but I'm interest...

Is there an implementation of org.apache.commons.lang.Validate for .Net ?

Is there an implementation of org.apache.commons.lang.Validate for .Net ? ...

Covariance and contravariance in programming languages

Can anyone explain me, the concept of covariance and contravariance in programming languages theory? ...

Apache Tomcat 404 Error

I downloaded Apache Tomcat 6.0.2 And created a new server in Eclipse New -> Server Select "Tomcat v6.0 Server", Next Tomcat Installation Directory -> Where I unzipped Apache Tomcat 6.0.2 Finish Then I start the server and go to http://localhost:8080/ to see if it works. And I get a 404 error. I've already googled it and tried to fin...

Java library to check whether a String contains a number *without* exceptions

I'm looking for a method that returns a boolean if the String it is passed is a valid number (e.g. "123.55e-9", "-333,556"). I don't want to just do: public boolean isANumber(String s) { try { BigDecimal a = new BigDecimal(s); return true; } catch (NumberFormatException e) { return false; } } Clea...

What is the best map implementation to use when storing integers with char keys?

I have a set of flags which are part of a huge text data file as single characters. Before processing the file I map each flag to the id of a property it represents. While processing the file I need to look up these mappings as fast as possible (I do it a lot). Currently I store these in a HashMap. And the code looks like this: pri...