Stefan Haustein

Author
+ Follow
since Jul 28, 2002
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 Stefan Haustein

Since I was asked offline to explain the example in more detail, I will try to do so here, perhaps somebody else is interested....
Basically, what the example code does is to store the text just before the searche content in a variable trigger. In the example, this is "]1.".
The variable match is a counter that counts how many characters from trigger were matched so far.
When the char just read in the first while loop (variable i) matches the first char in trigger ("i==trigger.charAt(match)"), match is incremented. Now, match points to the second char in trigger (character indices in strings start with 0). If the next char matches the second char in trigger, match is incremented again, etc., until match equals the number of characters in trigger ("match==trigger.length()"), or a mismatch occurs ("else"). In the first case, the full trigger string was recognized, and the break statement terminates the first loop. In the second case, the match counter is reset to 0 or 1.
The second loop just reads the result string until the first character of an HTML tag (< is read.
Best,
Stefan
21 years ago
The PDAP profile is a profile especially for PDAs. MIIDP 2.0 is a different profile. PDAP is a superset of MIDP, so all existing MIDP applications should run on PDAP as well. You can find the public specification draft at http://jcp.org/aboutJava/communityprocess/review/jsr075/index.html
I think it will be presented at a more popular place on the SUN homepage as soon as a reference implementation is available.
Best,
Stefan
21 years ago
p.s.: My Utils4Me XML reader allows to set the parsing mode to relaxed. In relaxed mode, it is less strict concernig the XML encoding rules, so it may be able to read your HTML page. Actually, reading any HTML was the idea behind the relaxed mode, so if it does not, let me know...
Best,
Stefan
21 years ago
Well, some kind of progress bar would at least help the user to determine whether the application is still downloading or already crashed, even if it is not very reliable. However, for this purpose it is probably necessary that the download takes place in a separate thread, otherwise it may block the display: Some devices do not show screen updates until the command handler returns.... (and according to the MIDP spec the commandAction() method should return immediately)
Best,
Stefan
21 years ago
One problem may be that the Display is not available before the startApp() method was called by the application manager. So if you start the animation in the constuctor of your MIDlet, this may be the problem. Does the problem persist on all emulators/devices you tried? Did you include serviceRepaint()? Can you post the relevant part of your code?
Best,
Stefan
21 years ago

Originally posted by a sanjuan:
are you free to speculate on this?
also, some palm programmers are complaining about the possible SIZE footprint for this (about 1 MB?), and what effect it might have when preinstalled into newer PDAs (ie, that space could've been used for other things).
what do you think are the major advantages for palm/PDAs to having this new profile (as opposed to simply using C/etc to program in Palm)?


Hi Sanjuan,
I think the main advantage will be platform independence and simpler development, at least for programmers new to the Palm Platform. Unfortunately, I do not know whether the Palm PDAP implementation will be optional or mandatory, and when it will be available. I hope at least the RI will be available soon, but I do not have any concrete information about a release date. Your size estimation of 1 MB seems very reasonable.
Best,
Stefan
21 years ago
Lance,
please take a look at
me4se.org
Best,
Stefan
21 years ago

Originally posted by Huang Qingyan:

For example:
<html>
...
...
]1. the data i wanted<br>
</html>
Now form what you guys might had guess, the data that I wanted to extract is "the data I wanted". So how do I go about this?


Hi Qingyang,
if the data you are looking for is always embraced by "]1." and "<", you can read the stream until you find "]1." and use this as trigger for extracting the desired content. Of course, "]1." should not occur elsewhere, otherwise the extraction becomes more complicated. Example code:


Of course, depending on the actual HTML code, this can become more complex or even impossible... A general aproach may be to try to figure out a logical rule for detecting the content, something like "first <li> after the word 'prices'", and then to verify this manually for some examples, and finally to implement the rule found in Java.
Please note that this may still fail when the page design changes. When a machine readable version of the content is available (SOAP, RDF or XML-RPC), this is probably a more stable target for extraction.
Best,
Stefan
21 years ago

Originally posted by Rishi Tyagi:
Hi Java gurus,
(...)
Actually when we work on games in j2me in that we have to move towards left,right,top and bottom and for that generally we trap the number keys 4,6,2 and 8 respectively why this?
why we can't trap the navigation keys here. and if we can trap these then whether we should these keys on the basis of keyCode parameter in keyPressed method of Canvas class or there is some other ways to do the same.


Hi Risji,
the Canvas class contains the method getGameCode() for this purpose. Using this method, you can convert the code provided by keyPressed() to one of the constants Canvas.UP, Canvas.DOWN, Canvas.LEFT, Canvas.FIRE etc. The mapping performed by getGameCode is device dependent, so on telephones without separate cursor keys, the corresponding numbers will be mapped to these constants, whereas on phones providing separate cursor keys these keys will be mapped to the game code constants...
The example canvas below shows how to control a little black square with the device cursor keys:

HTH,
Stefan
21 years ago