comp.lang.java.programmer
http://groups-beta.google.com/group/comp.lang.java.programmer
[EMAIL PROTECTED]

Today's topics:

* Iteration over sets - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2464f0c85c8b717f
* xdoclet entity and dao help - 4 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51485373c1a7d27b
* Integrating servlet container into my stand alone App - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/876916b4cfd4b10c
* test - please ignore - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2f89ed9580d14a0
* Some sort of searchable or two way Map - 3 messages, 3 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/315c1a2663bb6e58
* Object class - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63fef30fd89ad0f2
* System.out.flush() - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65a3ad6f4d26842f
* assign JavaScript variable to Java variable problem in JSP - 2 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3491429a868b5a8b
* JAVA SPEECH RECOGNITION - 3 messages, 2 authors
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e6752c5ef9351d71
* Good idea or full of it? - 1 messages, 1 author
  
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4ceda7465055571c
  
==========================================================================
TOPIC: Iteration over sets
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2464f0c85c8b717f
==========================================================================

== 1 of 1 ==
Date:   Sat,   Sep 25 2004 4:32 pm
From: Swarat Chaudhuri <[EMAIL PROTECTED]> 


This solves my problem. Warm thanks to you and everyone else who
responded on this thread.


On Sat, 25 Sep 2004, Babu Kalakrishnan wrote:

> Swarat Chaudhuri wrote:
> >
> > I have a set S over which I would like to iterate. While iterating, in
> > certain cases, I want to add elements to the set. I would like the
> > iterator to treat these new elements as if they have not been seen so
> > far.  However, doing so seems to guarantee that concurrent modification
> > exception will be thrown.
> >
> > So the question is, is there a way to achieve what I want to do? Without
> > needing to restart the iteration every time an "update" occurs?
> >
>
> The standard HashSet implementation and the Iterator returned by it
> cannot do this job (as you already found out). Also since the Iterator
> returned by a HashSet does not guarantee any specific order in which it
> returns its elements, making the newly added elements appear later in
> the iteration order isn't guaranteed either (even assuming that you
> manage to somehow get rid of the ConcurrentModificationException)
>
> The easiest thing to do would be to use the combination of a List and a
> HashSet and write your own ListIterator implementation. Check out the
> code sample below. You can use the add/remove methods of the
> ListIterator to add/remove elements.
>
> // Warning - untested : provided only as sample
>
> // ListIterator implementation does not check for concurrent
> // modification. Code for this should be added . (See the
> // API docs for "modCount" field in the AbstractList class)
>
>
> import java.util.ArrayList;
> import java.util.HashSet;
> import java.util.ListIterator;
>
> public class MyHashSet extends HashSet
> {
>
>      private ArrayList list = new ArrayList();
>
>      public boolean add(Object o)
>      {
>          if (super.add(o))
>          {
>              list.add(o);
>              return true;
>          } else
>              return false;
>      }
>
>      public boolean remove(Object o)
>      {
>          if (super.remove(o))
>          {
>              list.remove(o);
>              return true;
>          } else
>              return false;
>      }
>
>      // Do similar stuff with other HashSet methods if necessary
>      // ensuring that the contents of "list" matches that of the set
>
>      public ListIterator listIterator()
>      {
>          return new MyListIterator();
>      }
>
>      public class MyListIterator implements ListIterator
>      {
>          private int nextIndex;
>          private Object lastReturned;
>
>          public int nextIndex()
>          {
>              return nextIndex;
>          }
>
>          public boolean hasNext()
>          {
>              return nextIndex < size();
>          }
>
>          public Object next()
>          {
>              return lastReturned = list.get(nextIndex++);
>          }
>
>          public int previousIndex()
>          {
>              return nextIndex - 1;
>          }
>
>          public boolean hasPrevious()
>          {
>              return nextIndex > 0;
>          }
>
>          public Object previous()
>          {
>              return lastReturned = list.get(--nextIndex);
>          }
>
>          public void add(Object o)
>          {
>              MyHashSet.this.add(o);
>          }
>
>          public void remove()
>          {
>              if (lastReturned == null)
>                  throw new IllegalStateException(
>                          "Cannot remove before a next or previous call");
>              MyHashSet.this.remove(lastReturned);
>          }
>
>          public void set(Object o)
>          {
>              throw new UnsupportedOperationException("Unsupported");
>          }
>      }
> }
>
> BK
>




==========================================================================
TOPIC: xdoclet entity and dao help
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/51485373c1a7d27b
==========================================================================

== 1 of 4 ==
Date:   Sat,   Sep 25 2004 5:02 pm
From: Sudsy <[EMAIL PROTECTED]> 

William Zumwalt wrote:
<snip>
> My question is how do I define (in this case) a create() method of my 
> DAO which will look something like this (but hasn't been generated yet) 
> ...
> 
> public abstract class MyDAO { 
>     static public void create(HashMap data) throws PersistanceException {
>         CreateThing.getInstance().execute(data);
>     }
> }
> 
> I saw the @dao.call, but not sure how to use it.
> 
> Any help much appreciated.

I added the following to one of my entity beans:

  * @ejb.dao class="classname"

and added the dao task to my ejbdoclet. It generated the DAO interface
with a create method which accepts a single argument of type of the bean
class. I would imagine that it's up to you (the programmer) to invoke
the create method in your ejbCreate. Don't know if this helps...




== 2 of 4 ==
Date:   Sat,   Sep 25 2004 5:41 pm
From: William Zumwalt <[EMAIL PROTECTED]> 

In article <[EMAIL PROTECTED]>,
 Sudsy <[EMAIL PROTECTED]> wrote:

> William Zumwalt wrote:
> <snip>
> > My question is how do I define (in this case) a create() method of my 
> > DAO which will look something like this (but hasn't been generated yet) 
> > ...
> > 
> > public abstract class MyDAO { 
> >     static public void create(HashMap data) throws PersistanceException {
> >         CreateThing.getInstance().execute(data);
> >     }
> > }
> > 
> > I saw the @dao.call, but not sure how to use it.
> > 
> > Any help much appreciated.
> 
> I added the following to one of my entity beans:
> 
>   * @ejb.dao class="classname"
> 
> and added the dao task to my ejbdoclet. It generated the DAO interface
> with a create method which accepts a single argument of type of the bean
> class. I would imagine that it's up to you (the programmer) to invoke
> the create method in your ejbCreate. Don't know if this helps...
> 

But as you can see, I am invoking the create method in my ejbCreate. And 
I left out @ejb.dao at the class level declaration of my entity bean 
because that just seems to name the interface w/ a given name from me. 
My DAO's are being generated, but ... and I think what you said may help 
a bit, something to do with defining the method of my DAO inside a DAO 
task. It's that code that goes inside the methods of my DAO's that I'm 
trying to figure out how and where to put. The code within my entities 
seems ok for now.



== 3 of 4 ==
Date:   Sat,   Sep 25 2004 6:16 pm
From: Sudsy <[EMAIL PROTECTED]> 

William Zumwalt wrote:
<snip>
> But as you can see, I am invoking the create method in my ejbCreate. And 
> I left out @ejb.dao at the class level declaration of my entity bean 
> because that just seems to name the interface w/ a given name from me. 
> My DAO's are being generated, but ... and I think what you said may help 
> a bit, something to do with defining the method of my DAO inside a DAO 
> task. It's that code that goes inside the methods of my DAO's that I'm 
> trying to figure out how and where to put. The code within my entities 
> seems ok for now.

Sorry, I should have mentioned that a lot of the magic happens in the
<classname>CMP.java file. A static synchronized getDAO method is
defined. It gets even spiffier if you specify impl-jndi attribute as
it performs a context lookup for the named identifier.
I don't want to include all the code here, but assuming a class of
org.mine.ejb.entity.MyClass and the inclusion of the following:
  * @ejb-dao class="org.mine.ejb.entity.MyClassDAO"
  *          impl-jndi="dao/MyClass"
look at the generate file MyClassDAO.java and MyClassCMP.java. It's
a lot of time-saving code. You can simple plug in a class at deployment
time which implements the interface. Sweet!




== 4 of 4 ==
Date:   Sat,   Sep 25 2004 11:23 pm
From: William Zumwalt <[EMAIL PROTECTED]> 

Thanks, this gives me much to go on and try to work out.


> William Zumwalt wrote:
> <snip>
> > But as you can see, I am invoking the create method in my ejbCreate. And 
> > I left out @ejb.dao at the class level declaration of my entity bean 
> > because that just seems to name the interface w/ a given name from me. 
> > My DAO's are being generated, but ... and I think what you said may help 
> > a bit, something to do with defining the method of my DAO inside a DAO 
> > task. It's that code that goes inside the methods of my DAO's that I'm 
> > trying to figure out how and where to put. The code within my entities 
> > seems ok for now.
> 
> Sorry, I should have mentioned that a lot of the magic happens in the
> <classname>CMP.java file. A static synchronized getDAO method is
> defined. It gets even spiffier if you specify impl-jndi attribute as
> it performs a context lookup for the named identifier.
> I don't want to include all the code here, but assuming a class of
> org.mine.ejb.entity.MyClass and the inclusion of the following:
>   * @ejb-dao class="org.mine.ejb.entity.MyClassDAO"
>   *          impl-jndi="dao/MyClass"
> look at the generate file MyClassDAO.java and MyClassCMP.java. It's
> a lot of time-saving code. You can simple plug in a class at deployment
> time which implements the interface. Sweet!
>




==========================================================================
TOPIC: Integrating servlet container into my stand alone App
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/876916b4cfd4b10c
==========================================================================

== 1 of 1 ==
Date:   Sat,   Sep 25 2004 5:20 pm
From: "Silvio Bierman" <[EMAIL PROTECTED]> 


"DiscoStu" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hello Everyone,
>
>      I had this idea for an application I would like to write. I want
> to write it as a java application, but be able to output
> program-generated .html into an Internet Explorer window. Sending the
> generated html to the IE window is easy... just using the Runtime
> class. But I want the Internet Explorer window to be able to make http
> calls back to my application for form submissions. I didn't want to
> have to force my users to install Tomcat just so the internet explorer
> could pass back information to the servlet in my .Jar file.
>
> How hard is it to add a servlet container and respond to http post's
> from the localhost internet explorer window? This is all from my .jar
> file and not from a web application running under tomcat remember. The
> only http requests coming into my application will be from that one
> internet explorer window... so its really acting like a
> single-user-local-machine Tomcat server. But I dont want the burden of
> forcing Tomcat on people.
>
> I suppose you'll say pick a standard application or a jsp/servlet
> solution, but not both.... but I think there is a lot of flexability
> to this method, being able to generate GUI screens on the fly in the
> IE window is really exciting.
>
> Thanks,
>
>      Greg

Greg,

My company supplies a software system that is basically based on standard
servlets but since most of our potential customers do not own or want to own
a J2EE server environment we normally distribute our servlets packages with
a servlet container that can be simply embedded in a Java app (of no more
then a few lines). In short, people only install a JRE, unpack our ZIP and
fire up the app. For windows environments we cooked up a service wrapper EXE
and that is it.

Actually, our system consists of a central server that has no user
interfaces but handles XML requests through HTTP (servlets handle the
requests through the servlet container) which come from multiple application
servers (servlets that generate HTML as the UI and connect to the central
server via HTTP requests). Both tiers are servlet based and use the same
setup.

The embeddable server is Jetty (www.mortbay.org) which is one of the best
(free) servlet containers available and very simple to embed (including
sample code and great free support through the mailing lists).







==========================================================================
TOPIC: test - please ignore
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/a2f89ed9580d14a0
==========================================================================

== 1 of 2 ==
Date:   Sat,   Sep 25 2004 6:04 pm
From: [EMAIL PROTECTED] (zxcv) 

Andrew Thompson <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> On 25 Sep 2004 10:57:33 -0700, zxcv wrote:
> 
> Failed dismally!   alt.test.* is the place for testing. 
> 

Thanks for the info.

zxcv



== 2 of 2 ==
Date:   Sun,   Sep 26 2004 12:05 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

[EMAIL PROTECTED] (zxcv) writes:

> <hr>
> <table border=2>

Doesn't look like text/plain (your stated content type) to me. So you
failed the test.




==========================================================================
TOPIC: Some sort of searchable or two way Map
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/315c1a2663bb6e58
==========================================================================

== 1 of 3 ==
Date:   Sat,   Sep 25 2004 6:47 pm
From: Lasse Reichstein Nielsen <[EMAIL PROTECTED]> 

Albretch <[EMAIL PROTECTED]> writes:

>  Is there such a thing?
>
>  I need a Data Structure that would let you insert Strings into it
> and give you back an index you could use later on to refer to the
> inserted String and it should work the other way around too, given
> the String it should return to you the index if the String exists.

There is no two-way map, but you can easily build one.
Keep both an ArrayList (for quick index->string lookup) and
a HashMap (for quick string->index lookup). Then make sure
that when adding a string, a map entry mapping the string
to its new index is also created.
/L
-- 
Lasse Reichstein Nielsen  -  [EMAIL PROTECTED]
 DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
  'Faith without judgement merely degrades the spirit divine.'



== 2 of 3 ==
Date:   Sat,   Sep 25 2004 9:53 pm
From: "Mike Schilling" <[EMAIL PROTECTED]> 


"Thomas Kellerer" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>
>
> Albretch wrote on 26.09.2004 00:23:
>>
>>  Is there such a thing?
>>
>>  I need a Data Structure that would let you insert Strings into it and 
>> give you
>> back an index you could use later on to refer to the inserted String and 
>> it should work the other way around too, given the String it should 
>> return to you the index if the String exists.
>>
>
> ArrayList is exactly what you need.
>
> Have a look at the add(Object) and indexOf(Object) methods.
>

The pronblem is that ArrayList.indexOf(Object) is implemented with a linear 
seach.  Not a good idea if the list is much bigger than about 20 objects.





== 3 of 3 ==
Date:   Sun,   Sep 26 2004 12:55 am
From: [EMAIL PROTECTED] (Albretch) 

Thomas Kellerer <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> ArrayList is exactly what you need.
> 
> Have a look at the add(Object) and indexOf(Object) methods.
> 
> http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html
> 
> Thomas

 I do know of ArrayList<String>'s (1.5 typesafe version) add(Object)
and indexOf(Object) methods.

 Thing is that if you stress test it (say with 12695 Strings (I am
using all the names of the classes in $JAVA_HOME/lib/rt.jar)), you
will be roughly getting a search time of 1 millisecond per string
which is way to slow.




==========================================================================
TOPIC: Object class
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/63fef30fd89ad0f2
==========================================================================

== 1 of 1 ==
Date:   Sat,   Sep 25 2004 7:39 pm
From: [EMAIL PROTECTED] (Batman4050) 

It gives the class the inheritance of the Object class.




==========================================================================
TOPIC: System.out.flush()
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/65a3ad6f4d26842f
==========================================================================

== 1 of 2 ==
Date:   Sat,   Sep 25 2004 7:43 pm
From: [EMAIL PROTECTED] (Batman4050) 

Does the line System.out.flush(); do anything?

I have added it to many of my programs, and I can't find any
difference with using it?

Does anyone know it's intended use, and why it's needed?

Thank you very much. :D



== 2 of 2 ==
Date:   Sat,   Sep 25 2004 8:40 pm
From: Chris Smith <[EMAIL PROTECTED]> 

Batman4050 wrote:
> Does the line System.out.flush(); do anything?
> 

Of course.  It causes everything that's been written to System.out to be 
completely written.  System.out can do some internal buffering of data, 
so you aren't guaranteed that something written to the stream will 
appear immediately in the standard output of the process... unless you 
call flush().

However, System.out is generally set up with auto-flush, so that you 
only need to worry about this if you write something less than complete 
lines at a time.

-- 
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==========================================================================
TOPIC: assign JavaScript variable to Java variable problem in JSP
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3491429a868b5a8b
==========================================================================

== 1 of 2 ==
Date:   Sat,   Sep 25 2004 8:49 pm
From: "Hal Rosser" <[EMAIL PROTECTED]> 


"Matt" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> If I assign Java variable a to javascript variable x, it is
> fine.
>  <%
>   int a = 10;
>  %>
>  var x = <%= a %>;
>  alert(x);
>
> But if I do the other way around, then it has 500 error. any ideas??
>
> <%
>   int b;
> %>
>  <% b %> = x;
Matt,
Javascript does not execute until it gets to the browser,
Java executes on the server as you know.
Java does not know the value of the JavaScript variable.
HTH
Hal


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 9/24/2004





== 2 of 2 ==
Date:   Sun,   Sep 26 2004 12:07 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

[EMAIL PROTECTED] (Matt) writes:

>  <% b %> = x;

In addition to the response you got, "b" is not a legal Java
statement, which gives the compiler error that the 500 error probably
wraps.




==========================================================================
TOPIC: JAVA SPEECH RECOGNITION
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e6752c5ef9351d71
==========================================================================

== 1 of 3 ==
Date:   Sat,   Sep 25 2004 9:29 pm
From: "Pak_indo" <[EMAIL PROTECTED]> 

Gday Folks,

Im currently deciding whether or not to write off a project of mine....what
I have is a JAVA program which I would like users to interract with via
voice prompts for example Withdraw X, deposit Y. I have been looking at the
various ways of doing this and am not sure if this would be a viable
project. If anyone could help, I would like to know whats the best way to
accomplish this task(I only need basic recognition) and how hard/how much
effort it would require.

Thank you all for your time





== 2 of 3 ==
Date:   Sat,   Sep 25 2004 10:18 pm
From: David Segall <[EMAIL PROTECTED]> 

"Pak_indo" <[EMAIL PROTECTED]> wrote:

>Gday Folks,
>
>Im currently deciding whether or not to write off a project of mine....what
>I have is a JAVA program which I would like users to interract with via
>voice prompts for example Withdraw X, deposit Y. I have been looking at the
>various ways of doing this and am not sure if this would be a viable
>project. If anyone could help, I would like to know whats the best way to
>accomplish this task(I only need basic recognition) and how hard/how much
>effort it would require.
>
>Thank you all for your time
>
Sun, in collaboration with IBM, have come up with a Java Speech API.
You can download IBM's first cut of an implementation from
http://www.alphaworks.ibm.com/tech/speech. I have no experience with
it and would be interested in your comments if you proceed. 



== 3 of 3 ==
Date:   Sat,   Sep 25 2004 10:48 pm
From: "Pak_indo" <[EMAIL PROTECTED]> 

Thanks for the reply mate,
Ive been looking at that one I think that is the direction I will go, if I
can determine its viability ;-)

cheers mate
"David Segall" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> "Pak_indo" <[EMAIL PROTECTED]> wrote:
>
> >Gday Folks,
> >
> >Im currently deciding whether or not to write off a project of
mine....what
> >I have is a JAVA program which I would like users to interract with via
> >voice prompts for example Withdraw X, deposit Y. I have been looking at
the
> >various ways of doing this and am not sure if this would be a viable
> >project. If anyone could help, I would like to know whats the best way to
> >accomplish this task(I only need basic recognition) and how hard/how much
> >effort it would require.
> >
> >Thank you all for your time
> >
> Sun, in collaboration with IBM, have come up with a Java Speech API.
> You can download IBM's first cut of an implementation from
> http://www.alphaworks.ibm.com/tech/speech. I have no experience with
> it and would be interested in your comments if you proceed.






==========================================================================
TOPIC: Good idea or full of it?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4ceda7465055571c
==========================================================================

== 1 of 1 ==
Date:   Sun,   Sep 26 2004 12:02 am
From: Tor Iver Wilhelmsen <[EMAIL PROTECTED]> 

Alex Hunsley <[EMAIL PROTECTED]> writes:

> What is wrong with writing:
> 
>           getSingleton()
>           {
>               return singleton;
>           }

If the goal is to remove Sun's error of allowing referencing static
members via instances, that's really "return this.singleton", and
hence bad since it uses an instance reference implicitly.



=======================================================================

You received this message because you are subscribed to the
Google Groups "comp.lang.java.programmer".  

comp.lang.java.programmer
[EMAIL PROTECTED]

Change your subscription type & other preferences:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

Report abuse:
* send email explaining the problem to [EMAIL PROTECTED]

Unsubscribe:
* click http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe


=======================================================================
Google Groups: http://groups-beta.google.com 

Reply via email to