Steli Niculescu

+ Follow
since Jul 14, 2009
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steli Niculescu

Huachaitou Peek wrote:

Wouter Oet wrote:Internally the TreeSet uses a TreeMap. And the TreeSet.add() delegates it to TreeMap.put(). Just open the source of that method and you'll see the bug. There is even a comment about the bug.

How can I take a look at source code ? Is there an easy way to do that ? Thanks.
The last two operands in a ternary expression must result in some kind of value. It's that simple.
Yes, I'm not sure either, actually my question was only for the last code sample.
I thought the compiler is sure that the exception will be thrown and the last statement will be unreachable, but it seems that's not true.
13 years ago
This, obviously, does not compile.

This compiles:

This, not so obviously, does not compile :


Why ??!
13 years ago
I'm not a big pro with Hibernate (just started learning it this week for my job). I have a small task to do concerning the following class hierarchy, which has
to be mapped in a single table :

----- UnaryExpression ---- NOT
----- BinaryExpression ---- OR
---- AND
LE: AND derives from BinaryExpression

The only concrete classes are NOT, OR and AND.
Expression is the root of the hierarchy, so i annotated it with @Entity :

Each binary expression has two operands, so i have to put their references in the abstract class BinaryExpression, which has to be a MappedSuperclass (it won't be an actual entity) :

The AND and OR classes have only simple implementation code, no more data needed for them :

When i run the code i get the following exception :

What am i doing wrong here? I've tried tens of changes to this, including annotating Expression with @MappedSuperclass (must it be @Entity, because
it's the root of the hierarchy?), annotating the attributes instead of the getters etc.
I have a task for an internship interview : a small JDBC application that uses an Oracle database. I have to send it to the interviewer to review it.
My code connects to my local testing Oracle XE database using user/pass "system"/"system" (that's the password i defined).

If I export the application into a JAR and send it, it will surely not work on the reviewer's machine because he probably has a different password
for the "system" user, and he will have to modify the code.

Is there a universal user (or something like this) for the Oracle database, for which i'm not required a password defined by me?

I have to do a small JDBC program that works with an Oracle 10g express edition installed on my computer.
I downloaded the driver (ojdbc14.jar) from here, and i have the
following code :

I get the exception
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(
, even if the service is started.

What am i doing wrong?
I have a task in which i have to serialize with XMLEncoder an object which contains a SimpleAttributeSet attribute.
I noticed that trying to xml serialize a SimpleAttributeSet doesn't produce any output.

The API says that :
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder.

What does this exactly mean ?
Can i serialize SimpleAttributeSet or i have to make a HashMap to manually add the attributes?
14 years ago
First of all, excuse my bad english

I asked a question yesterday about how to cut/copy/paste styled text in a JTextPane and nobody answered . I did some research myself and i found i need to write my own TransferHandler for a class to store the transfered data.

I made this class, which contains a simple String and a list of attributes for each of the elements which will be contained in the text.

I created a TransferHandler which uses this mime type, and tries to create a DataFlavor based on it. If the class cannot be found, a ClassNotFoundException is thrown.

As you can see, the classes are in the same package, I can't imagine why the class cannot be loaded.

java.lang.ClassNotFoundException: StyledString
at java.awt.datatransfer.DataFlavor.tryToLoadClass(Unknown Source)
at java.awt.datatransfer.DataFlavor.initialize(Unknown Source)
at java.awt.datatransfer.DataFlavor.<init>(Unknown Source)
at com.twip.editor.controller.StyleTransferHandler.<init>(
at com.twip.editor.controller.TextController.initUI(
at com.twip.editor.controller.TextController.<init>(
at com.twip.editor.controller.TextController$
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at Source)

14 years ago
I'm making a text editor using JTextPane and i noticed that ctrl + c and ctrl + v use only plain text, ignoring styles.
How can i copy text, including its styles?
14 years ago