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

Today's topics:

* RowSet vs Hibernate, JDO, etc. - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c29f9e526c37bb1b
* Design pattern(s) for batch processing? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d630ddc9229f91d
* Cool system icons - 4 messages, 4 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/79bb0b3e3c49fabb
* Sun download address? - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9e60af2a2c51a3
* refined 2D design question - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe2ce27adc5ec49a
* Getting Hostname in Java - 4 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a92b7b25ef233
* Cron can not start Java application as JAR file - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e3a25b5ebaa4e54
* DOMBuilder failure -- Cannot have more than one root on a DOM - 3 messages, 2 
authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9c65b28b541753d7
* Java class documentation question. <E> <T> <K,V> - 3 messages, 3 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/93e7594a1fe3a1fe
* Returning java.util.List in Axis - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/68216cf4012386bc
* java xml integration - 2 messages, 2 authors
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/94e9fe15ebbbdd80
* The use of listeners. - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a547891c4625c30
* Runtime.exec - no access to ports ? - 1 messages, 1 author
 
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/129ba54a793c2382

==============================================================================
TOPIC: RowSet vs Hibernate, JDO, etc.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c29f9e526c37bb1b
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 10:19 am
From: Chris Smith  

Ivan <[EMAIL PROTECTED]> wrote:
> Can you give me few examples of these apps for comparison between 
> JDO/Hibernate and RowSet applications?

To give a really extreme example, let's say you're writing something 
akin to MapQuest driving directions.  Although this does access large 
amounts of data in the form of the locations of various roads, the core 
task is a computational one, and data is only secondary.

> I think that I can make all with RowSet, but maybe I mistake! 

No, of course you can do all database access with RowSet.  You can also 
write all possible programs in assembly language.  You can also make do 
without databases entirely and use flat files for everything.  These 
things are all possible.  However, O/R mappers make some code easier to 
write, easier to understand and maintain, and quicker to the market than 
a lower-level interface like RowSet.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==============================================================================
TOPIC: Design pattern(s) for batch processing?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9d630ddc9229f91d
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 11:02 am
From: Chris Smith  

fishfry <[EMAIL PROTECTED]> wrote:
> I'm redesigning a bunch of batch feeds for an IT org. I was wondering if 
> there is any literature on design patterns for batch processing, ie 
> command-line programs that read a record, do something, read the next 
> record, etc.

Design patterns are mostly the same regardless of the kind of 
application you're writing.  The most significant aspect of your 
description above is not that it's batch processing, but that it doesn't 
sound much like a very complex task.  If your task lacks complexity, 
then most design patterns are pretty much irrelevant anyway.  Otherwise, 
use your existing knowledge.

> Also, where besides this newsgroup can people ask design-type questions 
> that might not even be language-specific? Most of my Java questions seem 
> to be along the lines of what's the object-oriented way to do things, 
> rather than specific language questions.

As far as most of us are concerned, any questions that are generally 
useful in Java programming are appropriate for this newsgroup.  
Unfortunately, there are an increasing number of netcops around lately 
who start every message by telling you what you should have done 
differently.  I'd just ignore them if I were you.

More abstract questions on OO design can go to comp.object, and on 
design patterns to comp.software.patterns.

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==============================================================================
TOPIC: Cool system icons
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/79bb0b3e3c49fabb
==============================================================================

== 1 of 4 ==
Date: Mon, Dec 27 2004 10:29 am
From: "Arun"  

Does anyone know of a site that has free cool high-color icons?

I have looked far and wide but to no avail.

I'm looking for something like the apple icons. Need the usual open new
close etc




== 2 of 4 ==
Date: Mon, Dec 27 2004 7:03 pm
From: Carl  

Arun wrote:
> Does anyone know of a site that has free cool high-color icons?
> 
> I have looked far and wide but to no avail.
> 
> I'm looking for something like the apple icons. Need the usual open new
> close etc
> 

You'll need to check the license for whichever set you are interested 
in, but a good place to start is...

http://kdelook.org/index.php?xsortmode=high&page=0



== 3 of 4 ==
Date: Mon, Dec 27 2004 1:51 pm
From: Jon Caldwell  

Arun wrote:
> Does anyone know of a site that has free cool high-color icons?
> 
> I have looked far and wide but to no avail.
> 
> I'm looking for something like the apple icons. Need the usual open new
> close etc
> 
There are a couple of nice sites listed here:
http://jcaldwel.blogspot.com/2004/12/free-icons.html



== 4 of 4 ==
Date: Mon, Dec 27 2004 11:56 pm
From: "Tony Morris"  

"Arun" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Does anyone know of a site that has free cool high-color icons?
>
> I have looked far and wide but to no avail.
>
> I'm looking for something like the apple icons. Need the usual open new
> close etc
>

The "Java look and feel Graphics Repository" is conventional, not
necessarily designed to be "cool", but consistent.
Personally, I prefer consistency over coolness; you might choose otherwise.
http://java.sun.com/developer/techDocs/hi/repository/

-- 
Tony Morris
http://xdweb.net/~dibblego/







==============================================================================
TOPIC: Sun download address?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9a9e60af2a2c51a3
==============================================================================

== 1 of 2 ==
Date: Mon, Dec 27 2004 7:27 pm
From: "Ann"  


"Robert kebernet Cooper" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> http://java.com/en/download/manual.jsp

I just went to that page, it is version 4 not version 5.





== 2 of 2 ==
Date: Mon, Dec 27 2004 12:16 pm
From: Steve Sobol  

Ann wrote:
> "Robert kebernet Cooper" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> 
>>http://java.com/en/download/manual.jsp
> 
> 
> I just went to that page, it is version 4 not version 5.

That's fine with me. 1.4.2 is a stable version. There is probably a reason Sun 
doesn't have 1.5 out there yet.

-- 
JustThe.net Internet & New Media Services, http://JustThe.net/
Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED]
PGP Key available from your friendly local key server (0xE3AE35ED)
Apple Valley, California     Nothing scares me anymore. I have three kids.




==============================================================================
TOPIC: refined 2D design question
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/fe2ce27adc5ec49a
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 12:41 pm
From: Chris Smith  

Jeff <[EMAIL PROTECTED]> wrote:
> The best solution I can think of is to extend Vector to implement the 
> Comparable interface, creating a class called ComparableVector for each row. 
> In ComparableVector's compareTo() method, I'll compare the float value of 
> each row.  Then I can use the Arrays.sort() method to perform the sort.  A 
> Vector of ComparableVectors will provide the 2nd dimension.
> 
> Does someone see a better solution?

Yes.  You're entirely missing the concept of abstraction.  You should 
really have something like this:

public class MyDataRecord implements Comparable<MyDataRecord>
{
    private String name;
    private float value;
    private int i1, i2;

    ...

    public int compareTo(MyDataRecord other)
    {
        return Float.compare(value, other.value);
    }
}

That use a Vector of those.  You mentioned that the display of this data 
in a Swing table is in another program, and there's nothing wrong with 
using different data models for the same data in different programs.  
However, if you would like to use a JTable to display the data in this 
form, just define a subclass of AbstractTableModel to define a mapping 
from a Vector<MyDataRecord> to the TableModel interface.  You'll define 
what field goes into what column by your implementation of getValueAt 
(and probably getColumnName and getColumnClass as well).

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

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation




==============================================================================
TOPIC: Getting Hostname in Java
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5a92b7b25ef233
==============================================================================

== 1 of 4 ==
Date: Mon, Dec 27 2004 11:53 am
From: "[EMAIL PROTECTED]"  

I need to get the hostname from a Java application. java.lang.System
doesn't seem to have a method for that.
Any hints ?




== 2 of 4 ==
Date: Mon, Dec 27 2004 8:36 pm
From: Dov Wasserman  

[EMAIL PROTECTED] wrote:

>I need to get the hostname from a Java application. java.lang.System
>doesn't seem to have a method for that.
>Any hints ?
>  
>
The java.net package has the methods you want. From 
http://www.devx.com/tips/Tip/13284:

|try {
        java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();
        System.out.println("Hostname of local machine: " + 
localMachine.getHostName());
}
catch (java.net.UnknownHostException uhe) { // [beware typo in code sample -dmw]
        // handle exception
}|

An alternate method listed at 
http://javaalmanac.com/egs/java.net/GetHostname.html:

try {
        // Get hostname by textual representation of IP address
        InetAddress addr = InetAddress.getByName(/"127.0.0.1"/);
        // /[127.0.0.1 is always localhost -dmw]/

        // Get hostname by a byte array containing the IP address
        byte[] ipAddr = new byte[]{/127/, /0/, /0/, /1/};
        addr = InetAddress.getByAddress(ipAddr);
    
        // Get the host name from the address
        String hostname = addr.getHostName();
    
        // Get canonical host name
        String hostnameCanonical = addr.getCanonicalHostName();
    }
    catch (UnknownHostException e) {
        // handle exception
    }

Note that any such method will first check Java's Security Manager to 
see if the hostname/address lookup is permitted. It should be allowed by 
default on most standard environments, though.

Good luck,

-Dov Wasserman



== 3 of 4 ==
Date: Mon, Dec 27 2004 9:40 pm
From: "Wim Hoogendam"  


<[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
>I need to get the hostname from a Java application. java.lang.System
> doesn't seem to have a method for that.
> Any hints ?
>

Hi,

try this:
java.net.InetAddress.getLocalHost().getHostName() 





== 4 of 4 ==
Date: Mon, Dec 27 2004 8:41 pm
From: Dov Wasserman  

Sorry about poor formatting. HTML -> text converter ;-(   Should be 
fixed here.

The java.net package has the methods you want. From 
http://www.devx.com/tips/Tip/13284:

    try {
        java.net.InetAddress localMachine = 
java.net.InetAddress.getLocalHost();
        System.out.println("Hostname of local machine: " + 
localMachine.getHostName());
    }
        catch (java.net.UnknownHostException uhe) { // [beware typo in 
code sample -dmw]
            // handle exception
    }

An alternate method listed at 
http://javaalmanac.com/egs/java.net/GetHostname.html:

    try {
        // Get hostname by textual representation of IP address
        InetAddress addr = InetAddress.getByName("127.0.0.1"); // 
[127.0.0.1 is always localhost -dmw]/
   
        // Get hostname by a byte array containing the IP address
        byte[] ipAddr = new byte[]{127, 0, 0, 1};
        addr = InetAddress.getByAddress(ipAddr);

        // Get the host name from the address
        String hostname = addr.getHostName();

        // Get canonical host name
        String hostnameCanonical = addr.getCanonicalHostName();
    }
    catch (UnknownHostException e) {
        // handle exception
    }

Note that any such method will first check Java's Security Manager to 
see if the hostname/address lookup is permitted. It should be allowed by 
default on most standard environments, though.

Good luck,

-Dov Wasserman

> [EMAIL PROTECTED] wrote:
>
>> I need to get the hostname from a Java application. java.lang.System
>> doesn't seem to have a method for that.
>> Any hints ?
>




==============================================================================
TOPIC: Cron can not start Java application as JAR file
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9e3a25b5ebaa4e54
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 8:34 pm
From: Lee Fesperman  

Grzegorz Wrazen wrote:
> 
> Hello
> 
> I've a problem with cron and Java application.
> Env: linux debian
> I have installed jdk1.4 as local user in my home catalog.
> When I try start simple class that is no problem, but
> the problem is when I try start jar application
> my script looks like:
> 
> #! /bin/bash
> 
> PATH=${PATH}:"/home/grzegorz/jdk1.4/bin"
> export PATH
> java -jar -cp %CLASSHPATH%:/home/grzegorz/cron_test/  Test.jar >
> /home/grzegorz/cron_test/log.txt 2>/home/grzegorz/cron_test/errors.txt &

Remove the '-cp' following the -jar toggle and the spaces before Test.jar. -jar 
must be 
followed by the filename (with path) of a jar file. Also note that -cp will be 
ignored 
when using -jar. Check the docs.

-- 
Lee Fesperman, FFE Software, Inc. (http://www.firstsql.com)
==============================================================
* The Ultimate DBMS is here!
* FirstSQL/J Object/Relational DBMS  (http://www.firstsql.com)




==============================================================================
TOPIC: DOMBuilder failure -- Cannot have more than one root on a DOM
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9c65b28b541753d7
==============================================================================

== 1 of 3 ==
Date: Mon, Dec 27 2004 9:33 pm
From: Collin VanDyck  

I've been using org.apache.xml.utils.DOMBuilder to build an 
org.w3c.dom.Document object from a stream of SAX2 events in my application.

I encounter serious problems when I try and build the document using any 
DOCTYPE preset.

My algorithm, should a DOCTYPE be needed in the final Document, is to

1. Create a DocumentBuilder from a DocumentFactory
2. Get the DOMImplementation from the DocumentBuilder
3. Ask the DOMImplementation to create a DocumentType object with some 
presets.
4. Use that DocumentType to help create a new Document using the 
DOMImplementation
5. Create a DOMBuilder on that Document, using the root Node of the 
Document as the current Node so that any further events are built from 
that node.

The problem I'm getting is that the DOMBuilder seems to think that I am 
appending multiple elements to the root of the Document instead of the 
root Node.

To illustrate this, I'm inserting some source that should be runnable 
using standard J2SE 1.4.2 runtime libraries.  This example will 
illustrate my frustration.

Also, John Bollinger, I read your posts on DOCTYPEs, which helped to get 
me to this point -- thanks.


The output from my program I get is:

Starting body element failed: Can't have more than one root on a DOM!
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html><head /></html>

But I believe it should be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
<html><head /><body/></html>

Any ideas on this, anyone?

thanks,
Collin

----------starting source code-------------------------------


package run;

import java.io.BufferedWriter;
import java.io.StringWriter;
import java.io.Writer;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.xalan.templates.OutputProperties;
import org.apache.xml.utils.DOMBuilder;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
import org.xml.sax.helpers.AttributesImpl;

/**
  * Test of the DOMBuilder
  *
  * @author Collin VanDyck
  */
public class DOMBuilderTest {

     public static void main(String[] args)
     {
         try
         {
             ////////////////////////
             // set up the dombuilder
             ////////////////////////

             final DocumentBuilderFactory factory = 
DocumentBuilderFactory.newInstance();

             factory.setValidating(false);
             factory.setNamespaceAware(false);
             factory.setExpandEntityReferences(false);
             factory.setIgnoringComments(false);
             factory.setIgnoringElementContentWhitespace(false);

             final DocumentBuilder builder = factory.newDocumentBuilder();
             final DOMImplementation domImplementation = 
builder.getDOMImplementation();
             final DocumentType documentType =
                 domImplementation.createDocumentType(
                         "html",
                         "-//W3C//DTD XHTML 1.0 Strict//EN",
 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";);

             // this document is created with a root node already in place.
             final Document document = domImplementation.createDocument(
                     "",
                     documentType.getName(),
                     documentType);
             final Element documentElement = document.getDocumentElement();

             // create the DOMBuilder with the current node to be the 
document element.
             final DOMBuilder domBuilder = new DOMBuilder(document, 
documentElement);


             ////////////////////////
             // add elements to my document
             ////////////////////////

             // this works
             domBuilder.startElement("","head","head",new AttributesImpl());
             domBuilder.endElement("","head","head");

             // this fails -- why, when we are not appending this 
element to the document root but
             // instead the root node of the document?
             try
             {
               domBuilder.startElement("","body","body",new 
AttributesImpl());
               domBuilder.endElement("","body","body");
             }
             catch (Exception e)
             {
                 System.err.println("Starting body element failed: " + 
e.getMessage());
             }

             ////////////////////////
             // print it out
             ////////////////////////

             printDocument(document);

         }
         catch (Exception e)
         {
             throw new RuntimeException(e);
         }

     }

     /**
      * Prints a Document.
      *
      * @param document
      * @throws Exception
      */
     private static void printDocument(Document document) throws Exception
     {
         final DOMSource domSource = new DOMSource(document);
         final Writer stringWriter = new StringWriter();
         final Result result = new StreamResult(new 
BufferedWriter(stringWriter));

         final TransformerFactory factory = 
TransformerFactory.newInstance();
         // produce an identity transform to copy from the source to the 
result.
         final Transformer transformer = factory.newTransformer();

transformer.setOutputProperties(OutputProperties.getDefaultMethodProperties("xml"));

         final DocumentType doctype = document.getDoctype();
         if (doctype != null)
         {
             transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, 
doctype.getPublicId());
             transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, 
doctype.getSystemId());
         }

         // let her rip
         transformer.transform(domSource, result);
         final String output = stringWriter.toString();
         System.out.println(output);
     }

}



== 2 of 3 ==
Date: Mon, Dec 27 2004 9:49 pm
From: "SPG"  

Hi,

Forgive me as I do not have the documentation in front of me, but from my 
recollection, I think you are in fact appending two elements tot he root 
from the looks fo your code..

Try this:

             domBuilder.startElement("","head","head",new AttributesImpl());

             domBuilder.startElement("","body","body",new AttributesImpl());
             domBuilder.endElement("","body","body");

             domBuilder.endElement("","head","head");



"Collin VanDyck" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> I've been using org.apache.xml.utils.DOMBuilder to build an 
> org.w3c.dom.Document object from a stream of SAX2 events in my 
> application.
>
> I encounter serious problems when I try and build the document using any 
> DOCTYPE preset.
>
> My algorithm, should a DOCTYPE be needed in the final Document, is to
>
> 1. Create a DocumentBuilder from a DocumentFactory
> 2. Get the DOMImplementation from the DocumentBuilder
> 3. Ask the DOMImplementation to create a DocumentType object with some 
> presets.
> 4. Use that DocumentType to help create a new Document using the 
> DOMImplementation
> 5. Create a DOMBuilder on that Document, using the root Node of the 
> Document as the current Node so that any further events are built from 
> that node.
>
> The problem I'm getting is that the DOMBuilder seems to think that I am 
> appending multiple elements to the root of the Document instead of the 
> root Node.
>
> To illustrate this, I'm inserting some source that should be runnable 
> using standard J2SE 1.4.2 runtime libraries.  This example will illustrate 
> my frustration.
>
> Also, John Bollinger, I read your posts on DOCTYPEs, which helped to get 
> me to this point -- thanks.
>
>
> The output from my program I get is:
>
> Starting body element failed: Can't have more than one root on a DOM!
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> <html><head /></html>
>
> But I believe it should be:
>
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> <html><head /><body/></html>
>
> Any ideas on this, anyone?
>
> thanks,
> Collin
>
> ----------starting source code-------------------------------
>
>
> package run;
>
> import java.io.BufferedWriter;
> import java.io.StringWriter;
> import java.io.Writer;
>
> import javax.xml.parsers.DocumentBuilder;
> import javax.xml.parsers.DocumentBuilderFactory;
> import javax.xml.transform.OutputKeys;
> import javax.xml.transform.Result;
> import javax.xml.transform.Transformer;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.dom.DOMSource;
> import javax.xml.transform.stream.StreamResult;
>
> import org.apache.xalan.templates.OutputProperties;
> import org.apache.xml.utils.DOMBuilder;
> import org.w3c.dom.DOMImplementation;
> import org.w3c.dom.Document;
> import org.w3c.dom.DocumentType;
> import org.w3c.dom.Element;
> import org.xml.sax.helpers.AttributesImpl;
>
> /**
>  * Test of the DOMBuilder
>  *
>  * @author Collin VanDyck
>  */
> public class DOMBuilderTest {
>
>     public static void main(String[] args)
>     {
>         try
>         {
>             ////////////////////////
>             // set up the dombuilder
>             ////////////////////////
>
>             final DocumentBuilderFactory factory = 
> DocumentBuilderFactory.newInstance();
>
>             factory.setValidating(false);
>             factory.setNamespaceAware(false);
>             factory.setExpandEntityReferences(false);
>             factory.setIgnoringComments(false);
>             factory.setIgnoringElementContentWhitespace(false);
>
>             final DocumentBuilder builder = factory.newDocumentBuilder();
>             final DOMImplementation domImplementation = 
> builder.getDOMImplementation();
>             final DocumentType documentType =
>                 domImplementation.createDocumentType(
>                         "html",
>                         "-//W3C//DTD XHTML 1.0 Strict//EN",
>
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";);
>
>             // this document is created with a root node already in place.
>             final Document document = domImplementation.createDocument(
>                     "",
>                     documentType.getName(),
>                     documentType);
>             final Element documentElement = document.getDocumentElement();
>
>             // create the DOMBuilder with the current node to be the 
> document element.
>             final DOMBuilder domBuilder = new DOMBuilder(document, 
> documentElement);
>
>
>             ////////////////////////
>             // add elements to my document
>             ////////////////////////
>
>             // this works
>             domBuilder.startElement("","head","head",new 
> AttributesImpl());
>             domBuilder.endElement("","head","head");
>
>             // this fails -- why, when we are not appending this element 
> to the document root but
>             // instead the root node of the document?
>             try
>             {
>               domBuilder.startElement("","body","body",new 
> AttributesImpl());
>               domBuilder.endElement("","body","body");
>             }
>             catch (Exception e)
>             {
>                 System.err.println("Starting body element failed: " + 
> e.getMessage());
>             }
>
>             ////////////////////////
>             // print it out
>             ////////////////////////
>
>             printDocument(document);
>
>         }
>         catch (Exception e)
>         {
>             throw new RuntimeException(e);
>         }
>
>     }
>
>     /**
>      * Prints a Document.
>      *
>      * @param document
>      * @throws Exception
>      */
>     private static void printDocument(Document document) throws Exception
>     {
>         final DOMSource domSource = new DOMSource(document);
>         final Writer stringWriter = new StringWriter();
>         final Result result = new StreamResult(new 
> BufferedWriter(stringWriter));
>
>         final TransformerFactory factory = 
> TransformerFactory.newInstance();
>         // produce an identity transform to copy from the source to the 
> result.
>         final Transformer transformer = factory.newTransformer();
>
> transformer.setOutputProperties(OutputProperties.getDefaultMethodProperties("xml"));
>
>         final DocumentType doctype = document.getDoctype();
>         if (doctype != null)
>         {
>             transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, 
> doctype.getPublicId());
>             transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, 
> doctype.getSystemId());
>         }
>
>         // let her rip
>         transformer.transform(domSource, result);
>         final String output = stringWriter.toString();
>         System.out.println(output);
>     }
>
> } 





== 3 of 3 ==
Date: Mon, Dec 27 2004 9:51 pm
From: "SPG"  

Also..

It seems you may be making life a bit hard for yourself, when there is a 
nice wrapper for XML generation and manipulation provided by JDOM ( 
www.jdom.org )

Steve
"SPG" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi,
>
> Forgive me as I do not have the documentation in front of me, but from my 
> recollection, I think you are in fact appending two elements tot he root 
> from the looks fo your code..
>
> Try this:
>
>             domBuilder.startElement("","head","head",new 
> AttributesImpl());
>
>             domBuilder.startElement("","body","body",new 
> AttributesImpl());
>             domBuilder.endElement("","body","body");
>
>             domBuilder.endElement("","head","head");
>
>
>
> "Collin VanDyck" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
>> I've been using org.apache.xml.utils.DOMBuilder to build an 
>> org.w3c.dom.Document object from a stream of SAX2 events in my 
>> application.
>>
>> I encounter serious problems when I try and build the document using any 
>> DOCTYPE preset.
>>
>> My algorithm, should a DOCTYPE be needed in the final Document, is to
>>
>> 1. Create a DocumentBuilder from a DocumentFactory
>> 2. Get the DOMImplementation from the DocumentBuilder
>> 3. Ask the DOMImplementation to create a DocumentType object with some 
>> presets.
>> 4. Use that DocumentType to help create a new Document using the 
>> DOMImplementation
>> 5. Create a DOMBuilder on that Document, using the root Node of the 
>> Document as the current Node so that any further events are built from 
>> that node.
>>
>> The problem I'm getting is that the DOMBuilder seems to think that I am 
>> appending multiple elements to the root of the Document instead of the 
>> root Node.
>>
>> To illustrate this, I'm inserting some source that should be runnable 
>> using standard J2SE 1.4.2 runtime libraries.  This example will 
>> illustrate my frustration.
>>
>> Also, John Bollinger, I read your posts on DOCTYPEs, which helped to get 
>> me to this point -- thanks.
>>
>>
>> The output from my program I get is:
>>
>> Starting body element failed: Can't have more than one root on a DOM!
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>> <html><head /></html>
>>
>> But I believe it should be:
>>
>> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
>> <html><head /><body/></html>
>>
>> Any ideas on this, anyone?
>>
>> thanks,
>> Collin
>>
>> ----------starting source code-------------------------------
>>
>>
>> package run;
>>
>> import java.io.BufferedWriter;
>> import java.io.StringWriter;
>> import java.io.Writer;
>>
>> import javax.xml.parsers.DocumentBuilder;
>> import javax.xml.parsers.DocumentBuilderFactory;
>> import javax.xml.transform.OutputKeys;
>> import javax.xml.transform.Result;
>> import javax.xml.transform.Transformer;
>> import javax.xml.transform.TransformerFactory;
>> import javax.xml.transform.dom.DOMSource;
>> import javax.xml.transform.stream.StreamResult;
>>
>> import org.apache.xalan.templates.OutputProperties;
>> import org.apache.xml.utils.DOMBuilder;
>> import org.w3c.dom.DOMImplementation;
>> import org.w3c.dom.Document;
>> import org.w3c.dom.DocumentType;
>> import org.w3c.dom.Element;
>> import org.xml.sax.helpers.AttributesImpl;
>>
>> /**
>>  * Test of the DOMBuilder
>>  *
>>  * @author Collin VanDyck
>>  */
>> public class DOMBuilderTest {
>>
>>     public static void main(String[] args)
>>     {
>>         try
>>         {
>>             ////////////////////////
>>             // set up the dombuilder
>>             ////////////////////////
>>
>>             final DocumentBuilderFactory factory = 
>> DocumentBuilderFactory.newInstance();
>>
>>             factory.setValidating(false);
>>             factory.setNamespaceAware(false);
>>             factory.setExpandEntityReferences(false);
>>             factory.setIgnoringComments(false);
>>             factory.setIgnoringElementContentWhitespace(false);
>>
>>             final DocumentBuilder builder = factory.newDocumentBuilder();
>>             final DOMImplementation domImplementation = 
>> builder.getDOMImplementation();
>>             final DocumentType documentType =
>>                 domImplementation.createDocumentType(
>>                         "html",
>>                         "-//W3C//DTD XHTML 1.0 Strict//EN",
>>
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";);
>>
>>             // this document is created with a root node already in 
>> place.
>>             final Document document = domImplementation.createDocument(
>>                     "",
>>                     documentType.getName(),
>>                     documentType);
>>             final Element documentElement = 
>> document.getDocumentElement();
>>
>>             // create the DOMBuilder with the current node to be the 
>> document element.
>>             final DOMBuilder domBuilder = new DOMBuilder(document, 
>> documentElement);
>>
>>
>>             ////////////////////////
>>             // add elements to my document
>>             ////////////////////////
>>
>>             // this works
>>             domBuilder.startElement("","head","head",new 
>> AttributesImpl());
>>             domBuilder.endElement("","head","head");
>>
>>             // this fails -- why, when we are not appending this element 
>> to the document root but
>>             // instead the root node of the document?
>>             try
>>             {
>>               domBuilder.startElement("","body","body",new 
>> AttributesImpl());
>>               domBuilder.endElement("","body","body");
>>             }
>>             catch (Exception e)
>>             {
>>                 System.err.println("Starting body element failed: " + 
>> e.getMessage());
>>             }
>>
>>             ////////////////////////
>>             // print it out
>>             ////////////////////////
>>
>>             printDocument(document);
>>
>>         }
>>         catch (Exception e)
>>         {
>>             throw new RuntimeException(e);
>>         }
>>
>>     }
>>
>>     /**
>>      * Prints a Document.
>>      *
>>      * @param document
>>      * @throws Exception
>>      */
>>     private static void printDocument(Document document) throws Exception
>>     {
>>         final DOMSource domSource = new DOMSource(document);
>>         final Writer stringWriter = new StringWriter();
>>         final Result result = new StreamResult(new 
>> BufferedWriter(stringWriter));
>>
>>         final TransformerFactory factory = 
>> TransformerFactory.newInstance();
>>         // produce an identity transform to copy from the source to the 
>> result.
>>         final Transformer transformer = factory.newTransformer();
>>
>> transformer.setOutputProperties(OutputProperties.getDefaultMethodProperties("xml"));
>>
>>         final DocumentType doctype = document.getDoctype();
>>         if (doctype != null)
>>         {
>>             transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, 
>> doctype.getPublicId());
>>             transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, 
>> doctype.getSystemId());
>>         }
>>
>>         // let her rip
>>         transformer.transform(domSource, result);
>>         final String output = stringWriter.toString();
>>         System.out.println(output);
>>     }
>>
>> }
>
> 






==============================================================================
TOPIC: Java class documentation question. <E> <T> <K,V>
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/93e7594a1fe3a1fe
==============================================================================

== 1 of 3 ==
Date: Mon, Dec 27 2004 2:53 pm
From: "PatFan15"  

I am new to Java and I am reviewing the online class documentation from
Sun.  I have come across something that I cannot decipher.

I am sure I probably overlooked something and will feel stupid for
asking this once I hear the answer, but I can't seem to find an
explanation.

In the documentation for the java.lang package, there are the following
classes/interfaces listed.
Comparable<T>
Iterable<T>
ThreadLocal<T>

java.util has these among others
Collection<E>
Comparator<T>


What do the <T> and the <E> and the <K,V> mean?

They look like parameters, but I do not recognize the format.  If this
is part of a standard documentation format, please feel free to point
me to some documentation on the format and I can read up on it myself.
Thanks.




== 2 of 3 ==
Date: Mon, Dec 27 2004 3:04 pm
From: "Robert kebernet Cooper"  

Those are part of the new Generics system. They really don't mean
anything except are shortand to let you know of the application of
Generics in the current class. The only ones that are really meaningful
are the <K, V> for key type and value type.
http://www.fawcette.com/javapro/2004_03/online/j2ee_kkreft_03_10_04/




== 3 of 3 ==
Date: Mon, Dec 27 2004 11:56 pm
From: "Tony Morris"  

"PatFan15" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I am new to Java and I am reviewing the online class documentation from
> Sun.  I have come across something that I cannot decipher.
>
> I am sure I probably overlooked something and will feel stupid for
> asking this once I hear the answer, but I can't seem to find an
> explanation.
>
> In the documentation for the java.lang package, there are the following
> classes/interfaces listed.
> Comparable<T>
> Iterable<T>
> ThreadLocal<T>
>
> java.util has these among others
> Collection<E>
> Comparator<T>
>
>
> What do the <T> and the <E> and the <K,V> mean?
>
> They look like parameters, but I do not recognize the format.  If this
> is part of a standard documentation format, please feel free to point
> me to some documentation on the format and I can read up on it myself.
> Thanks.
>

They are 'parameterized types'.
http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf

-- 
Tony Morris
http://xdweb.net/~dibblego/







==============================================================================
TOPIC: Returning java.util.List in Axis
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/68216cf4012386bc
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 2:58 pm
From: [EMAIL PROTECTED] 

Here's a little more info on this subject:

I am using apache axis 1.1

Java interface used to generate WSDL.
//**** iDAO.java
import java.util.List;

public interface iDAO {
public List executeQuery(String s);
public int executeUpdate(String s);
}


WSDL file generate by running Java2WSDL using iDAO.class (above)
//****daoservice.wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://Interface.daopackage";
xmlns:impl="http://Interface.daopackage";
xmlns:intf="http://Interface.daopackage";
xmlns:apachesoap="http://xml.apache.org/xml-soap";
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/";
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/";
xmlns:xsd="http://www.w3.org/2001/XMLSchema";
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
xmlns="http://schemas.xmlsoap.org/wsdl/";>
<wsdl:message name="executeUpdateResponse">
<wsdl:part name="executeUpdateReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="executeQueryResponse">
<wsdl:part name="executeQueryReturn" type="soapenc:Array"/>
</wsdl:message>
<wsdl:message name="executeQueryRequest">
<wsdl:part name="in0" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="executeUpdateRequest">
<wsdl:part name="in0" type="xsd:string"/>
</wsdl:message>
<wsdl:portType name="iDAO">
<wsdl:operation name="executeQuery" parameterOrder="in0">
<wsdl:input name="executeQueryRequest"
message="impl:executeQueryRequest"/>
<wsdl:output name="executeQueryResponse"
message="impl:executeQueryResponse"/>
</wsdl:operation>
<wsdl:operation name="executeUpdate" parameterOrder="in0">
<wsdl:input name="executeUpdateRequest"
message="impl:executeUpdateRequest"/>
<wsdl:output name="executeUpdateResponse"
message="impl:executeUpdateResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DAOServiceSoapBinding" type="impl:iDAO">
<wsdlsoap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="executeQuery">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="executeQueryRequest">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://Interface.daopackage"/>
</wsdl:input>
<wsdl:output name="executeQueryResponse">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://Interface.daopackage"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="executeUpdate">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="executeUpdateRequest">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://Interface.daopackage"/>
</wsdl:input>
<wsdl:output name="executeUpdateResponse">
<wsdlsoap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";
namespace="http://Interface.daopackage"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="iDAOService">
<wsdl:port name="DAOService"
binding="impl:DAOServiceSoapBinding">
<wsdlsoap:address
location="http://thehost:8082/axis/services/DAOService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>


IDAO.java generated by running WSDL2Java using above WSDL.
/**
* IDAO.java
*
* This file was auto-generated from WSDL
* by the Apache Axis WSDL2Java emitter.
*/

package com.rf3labs.services.dbconn.dao.ws;

public interface IDAO extends java.rmi.Remote {
public java.lang.Object[] executeQuery(java.lang.String in0) throws
java.rmi.RemoteException;
public int executeUpdate(java.lang.String in0) throws
java.rmi.RemoteException;
}

You will notice that the return type of executeQuery method is
java.lang.Object[] rather than what was defined in iDAO.java interface
which is java.util.List.






[EMAIL PROTECTED] wrote:
> Hi,
>
> When I generate the classes using a WSDL I get a return type of
> Object[] instead of the java.util.List object. From what I understand
> List is serializable.
> Any reason why it is changing the return type to Object[]?
> 
> Thanks,
> 
> -R





==============================================================================
TOPIC: java xml integration
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/94e9fe15ebbbdd80
==============================================================================

== 1 of 2 ==
Date: Mon, Dec 27 2004 4:01 pm
From: [EMAIL PROTECTED] 

It occurs to me that there should be some tools out there that will
allow to easily create a configuration data structure that is backed by
XML.  Anyone know of any tools that would allow me to either create an
XML schema and generate code from that including the XML parsing code?
Or even better would be to do this the other way.  Write a series of
classes and have an XML schema created for me.

Any ideas?

Dave




== 2 of 2 ==
Date: Mon, Dec 27 2004 4:13 pm
From: "Tony Morris"  


<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> It occurs to me that there should be some tools out there that will
> allow to easily create a configuration data structure that is backed by
> XML.  Anyone know of any tools that would allow me to either create an
> XML schema and generate code from that including the XML parsing code?
> Or even better would be to do this the other way.  Write a series of
> classes and have an XML schema created for me.
>
> Any ideas?
>
> Dave
>

http://java.sun.com/xml/jaxb/index.jsp

-- 
Tony Morris
http://xdweb.net/~dibblego/






==============================================================================
TOPIC: The use of listeners.
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2a547891c4625c30
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 4:16 pm
From: "Arun"  

Hi.

I am developing a GUI.
I'm not quite sure what to do when i encounter listeners. To keep
things tidy, i create a new class which implements a listener that i
want to use, then join that listener to a component.

For example, a listener that is called when a JTree node is selected is
called BuildTreeSelectionListener (implementing treeselectionlistener).

Then i use buildTree.addSelectionListener(new
BuildTreeSelectionListener).

What i dont get is this...

BuildTreeSelectionListener is called, and gets the node that has just
been selected. I now want this class to reference a method
onNodeSelection in my gui class (SwingMainView).

To do this, i have to set that method to static, then call
SwingMainView.onNodeSelection(). To me this doesnt seem like good code?

What do people usually do? Do they just implement the listener in the
class that it has been called from, instead of creating a new class for
it?

On a totally different point, has anyone got a good resource for the
proper use of keyword 'super'. I cannot find one.





==============================================================================
TOPIC: Runtime.exec - no access to ports ?
http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/129ba54a793c2382
==============================================================================

== 1 of 1 ==
Date: Mon, Dec 27 2004 3:27 pm
From: Darek Danielewski  

I'm running a simple Java class utilizing Runtime.getRuntime().exec(String) 
to execute an external application. During execution process, the app will 
eventually attempt to communicate with some port on same machine, say 
51002. Unfortunatelly, this attempt is denied, I'd have to assume by JVM 
itself, as the external app works perfectly fine from a DOS prompt. 

Am I missing something in the permissions? I've used an allow all policy 
file like this:

grant {
    permission java.security.AllPermission "", "";
};


Help would be greatly appreciated.

Darek



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

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

To post to this group, send email to [EMAIL PROTECTED] or
visit http://groups-beta.google.com/group/comp.lang.java.programmer

To unsubscribe from this group, send email to
[EMAIL PROTECTED]

To change the way you get mail from this group, visit:
http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe

To report abuse, send email explaining the problem to [EMAIL PROTECTED]

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

Reply via email to