| EMPTY_SET.iterator() and generics |
|
 |
Index ‹ java-programmer
|
- Previous
- 3
- Clients are bad ?Hello John Bailo , You say :
" Open source is just about old style client software
catching of to the Web economy "
You obviously don't believe that yourself ,
otherwise you'd be using Google ... Not Moz .
- 4
- Asking help for a java io problemHello, guys! I have a problem running the following code with eclipse
showing that:
java.io.IOException: Stream closed
at sun.nio.cs.StreamDecoder.ensureOpen(Unknown Source)
at sun.nio.cs.StreamDecoder.read(Unknown Source)
at java.io.InputStreamReader.read(Unknown Source)
at HtmlFileParser.parseHtmlDoc(HtmlFileParser.java:32)
at HtmlFileParser.main(HtmlFileParser.java:52)
//code here:
try{
FileInputStream fin = new FileInputStream("test.html");
InputStreamReader fr = new InputStreamReader(fin);
for(i=0; i<2048; i++) buf[i] = '0';
fr.read(buf, 0, 2048); //problem here (line 32)
FileWriter fw = new FileWriter("bufWriteTest.txt");
fw.write(buf);
fw.flush();
}
catch(FileNotFoundException e) {
e.printStackTrace();
}
catch(IOException e) {
e.printStackTrace();
}
There are no syntax erro in the above code, it just dosen't work,
please help me finding out what the problem is, thank you.
- 5
- 7
- JavaHelp and root nodehi,
Simplifying i have a java help set as this
ROOT -> C
-> B -> b1
-> b2
-> b3
->C
I can set B as current visualized node with these instructions:
helpBroker =(DefaultHelpBroker)coreHelpSet.createHelpBroker();
helpBroker.setCurrentID(B);
my problem is that i'd like to hide the other nodes setting B as tree
root node so that i could only see B and its children b1,b2,b3.
This is because entire help set is recovered from a big manual
describing a lot of applications and i'd like to show only one referred
by node B avoiding to show others that couldn't be installed.
Can you help me?
thanks
- 7
- Problem in connecting to a proxyHi,
i need to see if a user enters the correct username/password to
authenticate to a proxy. My problem is... through the following code,
i am
able to connect to a proxy with even invalid username/passwords.
Suppose
if the valid username and password to a proxy is test/test , i am able
to connect to the proxy using x/x . the response code returned is
always 200. Please advice..
################################
public static boolean isValidProxyAccount(String proxyServer,String
proxyPort,String proxyLogin,String proxyPassword) throws IOException
{
String go_url = new String ("http://www.google.com/");
boolean VALID_STATUS = true;
try{
URL url = new URL(go_url);
System.getProperties().put("proxySet",
"true");
System.getProperties().put("http.proxyHost", proxyServer);
System.getProperties().put("http.proxyPort", proxyPort);
HttpURLConnection con = (HttpURLConnection)
url.openConnection();
Base64Encoder b1 = new
Base64Encoder(proxyLogin+":"+proxyPassword);
con.setAllowUserInteraction(true);
String enStrProxy = "Basic "+ b1.processString();
con.setRequestProperty("Proxy-Authorization", enStrProxy);
int code = con.getResponseCode();
String retMsg = con.getResponseMessage();
System.out.println("code::"+code);
System.out.println("retMsg::"+retMsg);
System.getProperties().put("proxySet", "false");
System.getProperties().remove("http.proxyHost");
System.getProperties().remove("http.proxyPort");
con.disconnect();
if (code != 200){
VALID_STATUS = false;
throw new IOException("Failed to connect to CCO: "+retMsg);
}
}catch (Exception ex){
System.out.println(ex.getMessage());
throw new IOException(ex.getMessage());
}//catch
return VALID_STATUS;
}
- 8
- Applet using jdbc (ms sqlserver)Hi,
After reading lots of docs, a got the impression that it is possible to
write an Java Applet, that uses jdbc to connect to MS SQLServer (Without
flushing all security permissions down to drain).
Here is what I've done:
1. Downloaded the Microsoft JDBC driver for SQL Server 2000 SP 3.
2. Downloaded the app from Microsoft's site:
http://support.microsoft.com/default.aspx?scid=kb;en-us;313100
3. Tried to compile.
I get the java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for
JDBC]Error establishing socket.
I have tested every possible error that I can find in MS's site. I have
tried to alter policies granting "permission java.net.SocketPermission",
with no luck. I think that before granting this permission, I also got
some security exceptions..
So here's my question: is it possible to create an applet (UnTrusted)
that uses SQL server, that can be run in browser, that doesn't need any
security alternations?
Best Regards,
Mika
- 9
- Printing EPS (embedded postscript) from Java.
Hello all,
I need to print .eps (also called .epsf, .epi, .epsi) from inside a
java program. My target platforms are windows and mac-- although
windows is first.
The new 1.4 printing API has aupport for printing normal postscript
but does not have .eps support.
I've been looking around the internet to see what solutions people
have come up with and unfortonately I didn't get what I would call a
solid answer by doing this....
I looked at the source of two open source programs the support .eps.
They both have origianal source but esstenially did it almost exactly
the same way. They took the .ps file the the standard Java classes
generated and just stuck an .eps header on it. They then stick the .ps
inside a box as required. They then searched the .ps file for commands
that are illegal in the .eps and if they are there they just die.
I've got some serious problems with this:
(1) It assumes that the Sun classes are going to generate a .ps that
is easily converted to an eps. Maybe they do now but what about future
versions of Java?
(2) It makes big assumptions about future .ps and .eps formats.
(3) It stinks of just being a hack. Does anyone really know this is
going to work all the time and on all platforms?
Does anyone have any experience with making .eps from Java that has
any sugestions? I want to translate my Garphics2D objects to .eps. I
want the .eps to be accepted by major publishing programs on windows and
mac.
Thanks
Glen Pepicelli,
http://www.glenp.net
(reply to group)
- 9
- how to mail a form in JSPhi this is ravin. i m a last year IT student and i am doing my project
at a govt. organization. i have to do one thing in my project that:
> there is a feedback form which is to be filled by any user.
> it is having four fields.
1) name
2) tel.no
3) e-mail address
4) comments
> i simply have to mail this fields to the org.'s mail address when user hits submit button. there is nothing to do with this fields.
please send releated help as early as possible.
- 9
- Java Training QuestionI am an unemployed web developer with php, perl, and asp programming
experience and in order to be able to widen my job search I am considering
getting some formal training in Java. I am looking for training
recommendations in order to be able to do Java web development. Also will
this training be appealing to prospective employers or just a waste of my
time and money. Any feedback I get will be greatly appreciated.
- 11
- Riddle me thisOn Mon, 07 Nov 2005 11:35:27 GMT, "Sharp Tool"
<email***@***.com> wrote, quoted or indirectly quoted someone
who said :
>All these distribution dont include negative numbers?
A normal is clustered about a mean, nominally 0, with symmetric tails
left and right.
Poisson is a distribution of positive numbers.
Just what do these numbers measure?
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
- 11
- Programatically deducing VARCHAR2 length?Hi,
I'm using WebLogic 5.1 sp12 and Oracle 8.1.7 with JDBC 1.2 drivers.
I was wondering, if I know that a column is a vARCHAR2 column, how
could i deduce the maximum length of that column, short of repeatedly
inserting larger and larger strings until I genertae an exception. I
know with SQL*Plus I can describe the table and find out lengths that
way, but I was hoping for a more general automated method.
Thanks for any help anyone can provide - Dave
- 12
- Reflection and access to type parameter?Given the SSCCE below, the need to pass A.class and B.class in
lines 25 and 25 seems redundant. However, I can find nothing in
the language that would let that be done in the constructor,
between lines 18 and 19. The obvious would be
Class<T> x = T.class;
but that of course does not work. Is there any bridge at all
between reflection and generics? I suspect the answer is no
and the code below is the best that can be done, but I'm
not sure.
1 import java.lang.reflect.Method;
2 public class TestEnums
3 {
4 public static enum A
5 {
6 V1,
7 V2;
8 }
9 public static enum B
10 {
11 X1,
12 X2,
13 X3;
14 }
15 public static class C<T extends Enum<?>>
16 {
17 public C(Class<T> x) throws Exception
18 {
19 T[] eVal = x.getEnumConstants();
20 for (Enum<?> v : eVal) System.out.println(v.toString());
21 }
22 }
23 public static void main(String[] args) throws Exception
24 {
25 C<A> ca = new C<A>(A.class);
26 C<B> cb = new C<B>(B.class);
27 }
28 }
- 14
- JTable(A few more queries )I had a couple of more queries -
1) how to prevent swapping of the columns as in, by default the columns
in the JTable are not fixed in terms of their placement. They can be
very well swapped with one another. I want to prevent this.
2) Also after feeding the JTable with the data in database, i want to
be keep one row always empty so that a row can be inserted. It's like
we have in MS-Access.
hope i was clear in explaining the query properly.
Thanx,
Ankur
- 14
- 16
- looking for a Java decompilerHello!
Is there a good byte-code de-compiler in the ports? It does not
need to be fancy/GUI -- just a straghtforward .class->.java utility.
Thanks for any pointers. Thanks!
-mi
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
|
| Author |
Message |
Eric Sosman

|
Posted: 2007-2-23 3:38:00 |
Top |
java-programmer, EMPTY_SET.iterator() and generics
In the old days, before generics, I wrote
private SortedSet onhand;
Iterator getInventoryIterator() {
return (onhand == null ? Collections.EMPTY_SET ? onhand)
.iterator();
}
... the idea being to create the SortedSet only if there are
actually some Inventory objects to store in it, and to return
a suitable Iterator whether or not the SortedSet exists.
Now, in an effort to leave prehistory behind me and adopt
generics with all their benefits, I change the SortedSet to a
SortedSet<Inventory> and change the return type of the method
to Iterator<Inventory> -- but how do I rewrite the guts of the
method to get the compiler to understand that all is well? The
problem seems to be that Collections.EMPTY_SET.iterator() returns
an Iterator<Object>, and the compiler complains when I try to
return this in place of the desired Iterator<Inventory>. I've
tried a few variations, but have only succeeded in moving the
warning message around, not in eliminating it:
return (onhand == null
? (Set<Inventory>)Collections.EMPTY_SET : onhand)
.iterator();
return (Iterator<Inventory>)
(onhand == null ? Collections.EMPTY_SET ? onhand)
.iterator();
This seems like a lot of trouble to take over the empty set,
but there ought to be *some* clean way to do it. Ideas?
--
Eric Sosman
email***@***.com
|
| |
|
| |
 |
Tor Iver Wilhelmsen

|
Posted: 2007-2-23 4:38:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
P氓 Thu, 22 Feb 2007 20:38:06 +0100, skrev Eric Sosman
<email***@***.com>:
> This seems like a lot of trouble to take over the empty set,
> but there ought to be *some* clean way to do it. Ideas?
Check the methods Collections.emptySet() etc. which return "genericified"
Set<?>
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2007-2-23 4:43:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Eric Sosman wrote:
> return (onhand == null
> ? (Set<Inventory>)Collections.EMPTY_SET : onhand)
> .iterator();
Wouldn't something like
if (onhand == null)
return Collections.emptySet().iterator();
else
return onhand.iterator();
do the trick ?
I don't know whether you'd be allowed to reduce that to a ternary conditional
expression. And I'm not even going to guess -- I haven't had a lot of luck
using ?: with the type inference stuff, and still less in understanding under
what circumstances it is supposed to work. Same goes for the circumstances
under which it is necessary to assign to an intermediate variable rather than
trusting that javac will infer the desired type from the return type of the
method it's called from.
-- chris
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2007-2-23 6:25:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Chris Uppal wrote:
> Eric Sosman wrote:
>
>> return (onhand == null
>> ? (Set<Inventory>)Collections.EMPTY_SET : onhand)
>> .iterator();
>
> Wouldn't something like
>
> if (onhand == null)
> return Collections.emptySet().iterator();
> else
> return onhand.iterator();
>
> do the trick ?
>
> I don't know whether you'd be allowed to reduce that to a ternary conditional
> expression. And I'm not even going to guess -- I haven't had a lot of luck
> using ?: with the type inference stuff, and still less in understanding under
> what circumstances it is supposed to work. Same goes for the circumstances
> under which it is necessary to assign to an intermediate variable rather than
> trusting that javac will infer the desired type from the return type of the
> method it's called from.
This didn't work, but a close variant did:
Set<Inventory> set;
if (onhand == null)
set = Collections.emptySet();
else
set = onhand;
return set.iterator();
Interestingly, the apparently equivalent
Set<Inventory> set = (onhand == null)
? Collections.emptySet() : onhand;
return set.iterator();
did not work.
My thanks to you and to Tor Iver Wilhelmsen.
--
Eric Sosman
email***@***.com
|
| |
|
| |
 |
Piotr Kobzda

|
Posted: 2007-2-23 6:36:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Eric Sosman wrote:
> This didn't work, but a close variant did:
>
> Set<Inventory> set;
> if (onhand == null)
> set = Collections.emptySet();
> else
> set = onhand;
> return set.iterator();
>
> Interestingly, the apparently equivalent
>
> Set<Inventory> set = (onhand == null)
> ? Collections.emptySet() : onhand;
> return set.iterator();
>
> did not work.
I don't really know why. But similar, without any type inference in
effect, did:
return (onhand == null
? Collections.<Inventory> emptySet() : onhand)
.iterator();
piotr
|
| |
|
| |
 |
Lew

|
Posted: 2007-2-23 6:59:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Eric Sosman wrote:
>> Interestingly, the apparently equivalent
>>
>> Set<Inventory> set = (onhand == null)
>> ? Collections.emptySet() : onhand;
>> return set.iterator();
>>
>> did not work.
Piotr Kobzda wrote:
> I don't really know why. But similar, without any type inference in
> effect, did:
>
> return (onhand == null
> ? Collections.<Inventory> emptySet() : onhand)
> .iterator();
>
Maybe because the first example used a raw type on the left of the :, and a
parametrized type on the right, and one is not a subtype of the other. This
violates the compile-time checks on the ternary operator.
The second example used parametrized types on both sides of the :, allowing
compilation.
I am still feeling my way through the maze of generics, raw types and type
erasure.
- Lew
|
| |
|
| |
 |
Eric Sosman

|
Posted: 2007-2-23 7:08:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Lew wrote:
> [...]
> I am still feeling my way through the maze of generics, raw types and
> type erasure.
The worst feature of the maze is the little dwarf who
suddenly appears, throws an axe at you, and then explains
why the compiler is right and you are wrong, taking twenty
minutes for the explanation ...
--
Eric Sosman
email***@***.com
|
| |
|
| |
 |
Lew

|
Posted: 2007-2-23 7:26:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
> Lew wrote:
>> I am still feeling my way through the maze of generics, raw types and
>> type erasure.
Eric Sosman wrote:
> The worst feature of the maze is the little dwarf who
> suddenly appears, throws an axe at you, and then explains
> why the compiler is right and you are wrong, taking twenty
> minutes for the explanation ...
Plugh!
- Lew
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2007-2-23 22:48:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Lew wrote:
> Eric Sosman wrote:
> > > Interestingly, the apparently equivalent
> > >
> > > Set<Inventory> set = (onhand == null)
> > > ? Collections.emptySet() : onhand;
> > > return set.iterator();
> > >
> > > did not work.
>
> Piotr Kobzda wrote:
> > I don't really know why. But similar, without any type inference in
> > effect, did:
> >
> > return (onhand == null
> > ? Collections.<Inventory> emptySet() : onhand)
> > .iterator();
> >
>
> Maybe because the first example used a raw type on the left of the :, and
> a parametrized type on the right,
Not sure what you mean by that ?
One branch is explicitly typed since onhand has type SortedSet<Inventory>. Why
should the inferencer come up with something different for
Collections.emptySet() ?
Is it possible that it could produce
SortedSet<? extends Inventory>
or something like that ? I don't see how/why myself, but then I've pretty much
given up on working out what the generics stuff does in tricky situations (let
alone what it /should/ do -- which I suspect is often different).
-- chris
|
| |
|
| |
 |
Lew

|
Posted: 2007-2-24 7:05:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Lew wrote:
>> Maybe because the first example used a raw type on the left of the :, and
>> a parametrized type on the right,
>
Chris Uppal wrote:
> Not sure what you mean by that ?
I take the terminology straight from the Java universe. A raw type is the type
after erasure, when used without a generic parameter. So "List" is a raw type,
"List<Object>" is not.
> One branch is explicitly typed since onhand has type SortedSet<Inventory>. Why
> should the inferencer come up with something different for
> Collections.emptySet() ?
I am not saying that this is the One Right Way, but the reason is that the
Javba language treats raw types at compile time as somewhat equivalent to
"Type<Object>", not "Type<? extends Object>" (i.e., "Type<?>").
> Is it possible that it could produce
> SortedSet<? extends Inventory>
> or something like that ?
Before Sun chose a different approach to raw types it might have been
possible, but Sun did not choose that approach. Furthermore, the style of Java
is mostly about explicit declarations; it does not do a whole lot of type
inference. The inclusion of generics is evidence that Sun favors an explicit
type system over an implicit one.
> I don't see how/why myself, but then I've pretty much given up on working out what the generics stuff does in tricky situations (let
> alone what it /should/ do -- which I suspect is often different).
When you check the rules for the ternary operator, it says that of the types
on both sides of the ':', one must be assignable (upcastable) to the other.
Set<Inventory> and Set<Object> do not fulfill that criterion.
Ergo, Set<Inventory> and the raw type Set do not, either.
Ergo, the ternary expression with a left side of the former type and right
side of the latter does not compile.
When the raw type was changed to one with the parameter <Inventory>, it made
both sides have the same non-raw type, ergo, it compiled.
- Lew
|
| |
|
| |
 |
Piotr Kobzda

|
Posted: 2007-2-28 16:58:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Lew wrote:
> Lew wrote:
>>> Maybe because the first example used a raw type on the left of the :,
>>> and
>>> a parametrized type on the right,
>>
> Chris Uppal wrote:
>> Not sure what you mean by that ?
>
> I take the terminology straight from the Java universe. A raw type is
> the type after erasure, when used without a generic parameter. So "List"
> is a raw type, "List<Object>" is not.
True. Beside of lack of raw types in "first" example...
In that example type argument inferred for Collections.emptySet() is:
<capture-of ? extends Object> (that's what the compiler is saying in
this case), which implies (regardless of what "capture-of ? extends
Object" is exact equivalent to) that a method's result type is _not a
raw type_.
In general, when the result type of a generic method (which is not
non-static member of erased type) refers to one (or more) of that
method's type variables, that result type is parameterized unless
unchecked conversion was necessary for the method to be applicable. For
such a methods the compiler always infers some type argument according
to the rules described in JLS3 (sections 15.12.2.7 and 15.12.2.8).
>
>> One branch is explicitly typed since onhand has type
>> SortedSet<Inventory>. Why
>> should the inferencer come up with something different for
>> Collections.emptySet() ?
>
> I am not saying that this is the One Right Way, but the reason is that
> the Javba language treats raw types at compile time as somewhat
> equivalent to "Type<Object>", not "Type<? extends Object>" (i.e.,
> "Type<?>").
Java treats a raw types more like "Type<?>" (equivalent to "Type<?
extends Object>") than "Type<Object>", but in fact, it's none of them.
"Raw types are closly related to wildcards. Both are based on
existential types. Raw types can be thought of as wildcards whose type
rules are deliberately unsound, to accommodate interaction with legacy
code."
[from 'Discussion' in JLS3 4.8]
>> I don't see how/why myself, but then I've pretty much given up on
>> working out what the generics stuff does in tricky situations (let
>> alone what it /should/ do -- which I suspect is often different).
>
> When you check the rules for the ternary operator, it says that of the
> types on both sides of the ':', one must be assignable (upcastable) to
> the other.
>
> Set<Inventory> and Set<Object> do not fulfill that criterion.
Set<Inventory> and Set<?> do. Which is enough to successfully compile that:
Iterator<? extends Object> getInventoryIterator() {
return (onhand == null ? Collections.emptySet() : onhand)
.iterator();
}
However, the matter here is to guess why the compiler is unable to infer
more specific type argument for ternary conditional expression operand,
when it knows /very well/ both, an expected expression result type and
type of second operand?
Unfortunately, I still can't infer satisfactory answer from thick of JLS
rules. (It appears to me currently that the answer is somewhere around
chapter 15, with all that clear inference rules together with capture
conversion etc., but I can't give precise explanation and I'm close to
give up... :) ).
piotr
|
| |
|
| |
 |
Chris Uppal

|
Posted: 2007-2-28 21:36:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Piotr Kobzda wrote:
> Unfortunately, I still can't infer satisfactory answer from thick of JLS
> rules. (It appears to me currently that the answer is somewhere around
> chapter 15, with all that clear inference rules together with capture
> conversion etc., but I can't give precise explanation and I'm close to
> give up... :) ).
I have just taken another look at sections 15.12.2.7, and I /have/ given up !
(Did get one thing out of the exercise, though. Somehow I had been under the
impression that the type inference thing only applied to static generic
methods. I don't know where I got the idea from, but it's wrong. So that's
one less thing that I don't know anout generics ;-)
-- chris
|
| |
|
| |
 |
Lew

|
Posted: 2007-3-1 14:19:00 |
Top |
java-programmer >> EMPTY_SET.iterator() and generics
Chris Uppal wrote:
> (Did get one thing out of the exercise, though. Somehow I had been under the
> impression that the type inference thing only applied to static generic
> methods. I don't know where I got the idea from, but it's wrong. So that's
> one less thing that I don't know anout generics ;-)
That's OK, I got the "raw type equals (roughly) capture-of-Object" thing wrong.
Generics in Java keep me humble. (Not really, but it's not their fault.)
-- Lew
|
| |
|
| |
 |
| |
 |
Index ‹ java-programmer |
- Next
- 1
- JMS: the confusion BEFORE writing my first Application.I read in the sun jms doc that jms is the java interface to
Middleware, like MQ series.
Does this mean I actually need MQ series? ITs to expensive. Im
already in the programming world, so this is not a school project. My
boss came to me and told me that he would like to connect to a remote
MQ series machine. With it.
Now I have taken the channel and decided to write something at my desk
with out connecting to the remote mq. I mean, even if i didnt have to
do this project, i would still like to learn it.
I really thought that j2ee already had a queing facility built in so I
didnt need to buy mq series.
If i do need a middle where queue piece, then are there any free ones.
I thought i could go into the j2ee command line tool and just set up
the queues the way they have it in the example
Can you straighten out my confusion?
jodasi
- 2
- cmr one-to-many unidirectional - jbossHas anybody been able to get a CMR one to many unidirectional
relationship working with jboss? I'm trying to get it to work but keep
getting "foreign key constraint not allowed for this type of data
store".
The relationship is simple, I have two entity beans, person and
company and I want to have one to many unidirectional relationship
between these two beans. A person has one company, but a company has
many persons.
I want to have a company_id field in my person table that refers to
the id field in my company table. Maybe I'm missing something or doing
this wrong?
If somebody could post a working example of one to many unidirectional
I'd be mighty grateful. I'm trying to use the foreign-key-mapping
rather than relation-table, can you do this with foreign-key-mapping?
Here's what I have:
/**
* @return the company the person belongs to
*
* @ejb.persistent-field
* @ejb.persistence
* column-name="COMPANY_ID"
* sql-type="integer"
* jdbc-type="integer"
*
* @ejb.interface-method
*
* @ejb.relation
* name="Person-Company"
* role-name="Person-belongs-to-Company"
* target-ejb="Company"
* target-role-name="Company-has-many-Persons"
* target-multiple="yes"
*
* @jboss.relation
* fk-constraint="true"
* fk-column="COMPANY_ID"
* related-pk-field="id"
*
*/
public abstract CompanyLocal getCompany();
- 3
- GUI program locking up...I'm using Netbeans 5.0 beta for an IDE, with swing components. The
situation is something like this:
The program is a board game - the user chooses a building from a panel,
and then is supposed to get a message to choose what resource to pay
for it with. Here's a trace of the code:
Game (main object):
....
board[i].activate():
Game.game.setPlayer(worker);
Game.game.playerMessage("Choose a wooden building
from the building panel.");
Game.game.waitForBuild(type) :
built = false;
state = type + Game.BuildWood -
1;
mainPanel.buildings.getBP().setSelectedIndex(type-1);
while(!built)
{ Thread.yield(); }
No problems yet. This works fine, unless a building that needs to call
chooseResource is selected.
So, the user clicks one of these buildings, which activates the
following code, which is where the freeze occurs:
String r = Game.game.chooseResource():
state = Game.chooseResource;
resource = "";
while(resource.length()==0)
Thread.yield();
return resource;
Now chooseResource does work in any other context - resource gets set
by a mouseClicked event handler in a panel out there. But at this
point, the GUI stops responding. The playerMessage never gets printed,
and the click event never gets triggered. I did some investigating,
printing out numbers inside the two inmost loops, and the
chooseResource loop is continually running. I know the code's ugly,
but even so, the cause of this behavior is beyond me. Any suggestions
would be greatly appreciated!
- 4
- how to set row height at runtime in a JTableHi
i am trying to set rowheight of row in a JTable using
setRowHeight(row,rowheight)
it is not affecting on Table.but if i use setRowheight(rowheight) it
applying
entire table ,please help me to solve this problem
after setRowHeight(row,rowheight), i am calling firechanged() method
also ,i t will not affecting please hemp me
- 5
- convert xnl node to xml data typeHi all,
I am new to java programming. In my application I wanted to convert xml
node to an xml data type. The reason behind doing this is: I wanted to
write this xml node (in to a column of xml data type) with in to a
sequel server 2005 database. I am using JDBC driver (version 4) to
connect to the database. My stored procedure from the database side
accepts only xml data type and not xml Node type. So I wanted to
convert this xml Node to XML data type.
Can any help me with any input.
Thanks
Nathan.
- 6
- Read contents of a web pageI need to read the entire contents of any webpage, and return it as a
String. The other part of my assignment was to read a file and return its
contents. I did that with the following code:
private String filename;
private String contents;
public TextFileReader(String aFileName){
filename = aFileName;
}
public String readText() throws IOException{
String lineSep = System.getProperty("line.separator");
BufferedReader input = new BufferedReader(new
FileReader(filename));
String nextLine = " ";
StringBuffer contents = new StringBuffer();
while((nextLine = input.readLine()) != null){
contents.append(nextLine);
contents.append(lineSep);
}
return contents.toString();
}
----------
So, what do I have to change to be able to read webpages?
- 7
- ports/71078: Update port: java/eclipse-pmd upgrade to supportSynopsis: Update port: java/eclipse-pmd upgrade to support eclipse3
State-Changed-From-To: open->feedback
State-Changed-By: linimon
State-Changed-When: Thu Sep 2 23:17:52 GMT 2004
State-Changed-Why:
Please submit port updates in diff -u format as versus the current
port. This makes it much easier for ports committers to understand
what is being changed. Thanks.
http://www.freebsd.org/cgi/query-pr.cgi?pr=71078
_______________________________________________
email***@***.com mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-java
To unsubscribe, send any mail to "email***@***.com"
- 8
- learning J2EEHi all,
I have been a java developer for around 5 years, and I think it is time to
move into the J2EE arena.
Just by looking at monster.com, it becomes very obvious how important J2EE
has become, and if anyone is planning to make Java their bread and
Given that J2EE is not used in my current job, what is the best way to learn
it on my own and in my free time?
I looked at the websites of community colleges and universities around my
area, and I found that they only offer beginner and intermediate Java
classes, with no emphasis on J2EE.
What do you guys think is a good way to achieve this goal? How do
programmers usually make the transition from Java programmers to J2EE?
I have already experimented with Tomcat and some basic jsp stuff, but i am
sure J2EE is much more than that.
Any idea is greatly appreciated, and if you have a success story, please
share it here!
Cheers
hilz
- 9
- Starting using Inversion of ControlHi
I have an existing (Java desktop) application, which I'm looking at
converting to use Inversion of Control principles. I'm just starting
to look at the Java containers - HiveMind, Pico, Spring etc.
I'm not sure about how components/services/objects always have to be
instantiated, rather than retrieved from an existing object.
In my application, I have a IHandler interface, a single instance of
which is used by a number of objects.
Currently, the instance is supplied by an Engine class, which has an
inner class implementing IHandler, and a getHandler() method which
returns an instance of the inner class.
I'm wondering how, when using Inversion of Control, I can supply this
instance of IHandler to the objects which require it.
Most of the containers seem to require that the instance is *created*.
However, in this case, the instance should be *returned* from an
existing object (which will also have been created by the container).
What's the best way to deal with this situation?
I could, for example, make the IHandler inner class to be a public
class, so it can be instantiated directly. But I'm not convinced that
exposing the class in this way is the ideal way to do this.
Thanks for your help,
Calum
- 10
- JacOrb Multihomed serverHi everybody,
we have problems running a corba-server on a multi-homed Win2k-Box.
The machine has two network-cards. JacOrb is using the wrong IPAddress
for IOR's.
I tried the property OAIAddr. Only setting the property to 127.0.0.1
and running server and client on the same machine was successful.
Using the real address failed.
Does anyone have an advise for me ?
Thanks in advance
Ruediger
- 11
- ?s about Process ClassI have a DOS program I am trying to supply input to using Java.
Reading from The Java Class Libraries, 2nd Ed. java.lang.Process class -
the material presented seems to imply that I will be able to do
this.
The program most definately uses just stdio... (in) being the keyboard and
(out) being the consol.
Well I can't get it to work and being the presistant bugger that i am I have
switch tactics so I can more up the learning curve.
I have resorted to just trying to display the output of mem.exe.
here is the source ::: test.java
import java.io.*;
import java.lang.*;
public class test
{ public static void main(String[] args)
{
int ch;
int status;
try
{
Process process = Runtime.getRuntime().exec("mem.exe");
InputStream in = process.getInputStream();
BufferedInputStream buf = new BufferedInputStream(in);
//try
//{
//status = process.waitFor();
//}
//catch (InterruptedException e) {status = -1;}
try
{
while((ch = buf.read()) != -1)
{
System.out.print((char)ch);
}
}
catch (IOException e) {System.out.println(e);}
//in.close();
//buf.close();
//process.destroy();
//Runtime.getRuntime().gc();
//Runtime.getRuntime().exit(-1);
//System.out.print('\n');
}
catch (IOException e) {System.out.println(e);}
}
}
It works the first time I run the class file with java test.
However, the next attempt hangs and requires a system restart inorder to get
the code to display the results.
The commented code in test.java are my attempts to do various things to
clean up this issue of not displaying the results.
Does anyone have a clue or suggestion...
thanks,
publius36
- 12
- jbuilder 2005 backward compatabilityHi
I have a project that created by jbuilder X, in the "design" panel,
everything work great, but when i use jbuilder 2005 to open it, it
only display gray. Do you know why?
thanks
from Peter (email***@***.com)
- 13
- Multiple Exception Definitions in One FileIn Ada I could have a package that consisted of a group of exception
declarations, and any compilation unit that "withed" in that package
could use them. On the other hand if I want to use my own customized
exceptions in Java, it looks like I have to declare each one individu-
ally in its own file. Is this really what I have to do, or is there a
way to declare a bunch of exceptions in one file so that I can use
them elsewhere?
---Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
- 14
- Hiding default console in Windows Hello. Is it possible to hide the default console window in MS-Windows
in Java? If so, how?
When writing a Swing/JFC application in Java, it would be really nice to
somehow hide the DOS window that appears.
Thanks in advance.
--
Randolf Richardson - kingpin+email***@***.com
The Lumber Cartel, local 42 (Canadian branch)
http://www.lumbercartel.ca/
- 15
- DES in javaHi,
I need to write a method in Java for
encrypt a String with DES.
the interface is:
public String encrypt(String nameofthestringtoencript);
the return String have to be DES(nameofthestringtoencript)
What is the procedure to follow and the java methods
to do it?
Thanks in advance.
|
|
|