Maciej Wegorkiewicz

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

Recent posts by Maciej Wegorkiewicz

Well Garrett, this is interesting idea. It is not the same exactly as I wanted but I think I will do it your way.

Factories would contain nothing more but invocations of toString/fromString methods from their objects as they have no access to private attributes, so the code would look a bit silly.

So thanks for answer.

Anyway I think the best situation would be to be allowed to define constructors or static methods in interfaces.
17 years ago
Why generic type? Because I have to.

What I need is to serialize to String the class that contains objects of other classes that have to be serialized also. How can I deserialize them inside "fromString" method without generics? I cannot use inheritance because one of these inner objects have to be BigDecimals so I must use interface to make BigDecimals StringSerializable.

To be concrete, I have such class:

public class DiscreetTimeFunction<E extends StringSerializable>
implements StringSerializable
{
List<PolishDate> timepointStarts=new ArrayList<PolishDate>();
List<PolishDate> timepointEnds=new ArrayList<PolishDate>();
List<E> values=new ArrayList<E>();
(....)
}

I have to write to string whole object of this class, with lists of PolishDates (which inherit from GregorianCalendar) and E objects that can be BigDecimals or arrays of BigDecimals or other objects maybe in the future.
[ March 17, 2007: Message edited by: Maciej Wegorkiewicz ]
17 years ago
Hi I want to create class that is generic-customized and can be serialized to String. And you know what? Java does not allow this!
Or maybe does - please help me if someone knows how to do it.

Ok, I begin with creating interface that defines "serializable to string" classes:

interface StringSerializable
{
public StringSerializable fromString(String s);
public String toString();
}

Then, I want to define the class that is StringSerializable but can contain other classes that are StringSerializable:

class A<E extends StringSerializable> implements StringSerializable
{
E innerData=null;

public String toString()
{
return innerData.toString();
}

public A<E extends StringSerializable> fromString(String s)
{
E eObj=somehow create object of class E (how?)
innerData=eObj.fromString(s);
}
}

Sad surprise nr 1:
You cannot create eObj. It is normal because compiler does not know what constructors class E has. If we want to tell him using interface we meet

Sad surprise nr 2:
Interfaces do not allow defining constructors... The solution would be making fromString as static method to invoke just E.fromString but here we meet

Sad surprise nr 3:
Interfaces do not allow defining static methods... If we are so desperate that we are ready to create eObj by reflections we got

Sad surprise nr 4:
E.class expression does not work... you cannot then get reference to class of object eObj.

That is all I tried. I really see many interface constraints as not really intelligent. Maybe someone has a clue how to solve my problem?
17 years ago
No 35:
Maciek Wegorkiewicz
Poland
Hi,
Well maybe for many of us it is unfair, but from my point of view Sun has gave all of us a chance to look at the exam free of charge. That is why I think they have right to do it that way, so for me it is not unfair - Sun has right to do whatever it wants.
As about me - a was studying J2ME for this exam and tried to pass it yesterday. I got to know about extensions the day before. Maybe I could try to reschedule but I was psychically ready to do it yesterday so I didn't want to do any mess. I am really unsure of results - it is probable that I won't pass.
As many suggested before - Sun can make us a favor and give a chance to pass real exam for free in reward for our work on beta. I would be happy to get such a gift.
Hi,
I have such a problem: I am developing Swing app and sometimes it crashes by throwing an Exception which I don't catch. The effect is that this exception prints stack trace on System.err but user is not notified and wonders what is happening... I would prefer to show custom ErrorDialog with stacktrace.
I am searching for simple and effective way to catch every possible exception thrown from within any library. I think of a few ways from which everyone has some disadvantages.
The ideal way would be replacing AWT event queue dispatcher so I could process every GUI event inside try { } catch (Exception e) {} block. That would be a good place to catch all exceptions. Unfortunately I don't know if it is possible.
For now I am trying such a solution:
I start background thread together with main app. Then I redirect System.err and System.out streams to PipedStream connected to this background thread. This thread can analyze anything that is going to System.err and maybe recognize potential exception stacktraces. Then it can notify main thread of an exception. But it is not ideal as I have to parse the stream and it can always be not ideal in exception recognition. And the code is quite costly.
Do you have any ideas, had similar problems?
20 years ago
And another aspect:
If attributes are kept it means that after destroyApp the device cannot garbage app class. What if this class allocated a lot of memory? It is strange as we know CLDC devices can have very little amount of memory.
Hi,
It seems that destroyApp() does not touch class members (attributes) or in MIDP 2.0 spec is an error.
Look at the example on page 95 (SamplePingMe class).
On start of the startApp() it checks dconn == null.
But dconn is not initialized in constructor!
It assumes that there was destroyApp() earlier and there is dconn=null.
I think that in J2SE compilator I would have compilation error ("variable might not been initialized").
Does anybody know if there is any place in spec that guarantees that after destroyApp() variables are kept?
On the other side - is such a programming practice that is shown in this example really good? I think it is not...
Hi,
Evelyn annouced putting here some example questions?
Are they available somewhere?
It would be good to have some questions (preferably dividen on exam objectives).
Eduardo, don't panic.
I've sent request also on 28.01 and still waiting for answer.
Let's wait two days more and we'll see.
I tried to book in Poland and was also rejected.
Evelyn, can you explain? I don't want to email you cause i suppose you have many emails for now. Just tell us on this forum, so everybody can get to know.