Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   OT:News readers..so many to choose from (http://www.velocityreviews.com/forums/t390396-ot-news-readers-so-many-to-choose-from.html)

Print Dude 01-27-2007 02:47 AM

OT:News readers..so many to choose from
 
Well I've abandoned google groups for the time being and have switched
over to PAN on Linux and Gravity on Windows. What I am wondering is,
how hard would it be to write a news reader client in Java? I know it's
way beyond me, but there must be people reading this ng who have had
some degree of sucess at it. What was the process you went through to
design and build the program? How much practical experience would one
need to be able to sucessfully code such a program? If you know that
you need say, a class that will send a request to a news server, how do
you go about finding it in the API documentation? And if you don't find
one, do you write your own or simply extend one that is already there,
and is close to what you need? I have a book on OO Design coming, but
it would be interesting to know what others think. I know this is
pseudo-off topic, which is why I put the OT in the subject line. This
is my first post using Gravity so it may not work, but if it does, I
hope we can have a good discussion about this topic, if it hasn't
already been hash(tabled) before.

Cheers

Daniel Pitts 01-27-2007 05:36 AM

Re: OT:News readers..so many to choose from
 


On Jan 26, 6:47 pm, Print Dude <printerdude1...@gmail.com> wrote:
> Well I've abandoned google groups for the time being and have switched
> over to PAN on Linux and Gravity on Windows. What I am wondering is,
> how hard would it be to write a news reader client in Java? I know it's
> way beyond me, but there must be people reading this ng who have had
> some degree of sucess at it. What was the process you went through to
> design and build the program? How much practical experience would one
> need to be able to sucessfully code such a program? If you know that
> you need say, a class that will send a request to a news server, how do
> you go about finding it in the API documentation? And if you don't find
> one, do you write your own or simply extend one that is already there,
> and is close to what you need? I have a book on OO Design coming, but
> it would be interesting to know what others think. I know this is
> pseudo-off topic, which is why I put the OT in the subject line. This
> is my first post using Gravity so it may not work, but if it does, I
> hope we can have a good discussion about this topic, if it hasn't
> already been hash(tabled) before.
>
> Cheers

Actually, writing a simple newsreader probably wouldn't be too hard,
the NNTP protocol is well documented, and socket programming is "too
easy" in Java.

Out of curiousity, did you abandon Google because of their new look and
feel?
I don't like it myself, but I haven't bothered finding an alternative
yet.


Andrew Thompson 01-27-2007 06:34 AM

Re: OT:News readers..so many to choose from
 
On Jan 27, 4:36 pm, "Daniel Pitts" <googlegrou...@coloraura.com>
wrote:
> On Jan 26, 6:47 pm, Print Dude <printerdude1...@gmail.com> wrote:
>
> > Well I've abandoned google groups for the time being ..

....
> Out of curiousity, did you abandon Google because of their new look and
> feel?
> I don't like it myself, but I haven't bothered finding an alternative
> yet.- Hide quoted text -- Show quoted text -


It is ****ing me off how it ..
1) reformats text.
A good e.g. is the addition of
'- Hide quoted text -- Show quoted text -'
above. I would usually trim/reformat it.
2) Does not allow me to change thread titles
(though arguably, that is a good thing, in general)
3) Will not 'auto-text'/'bring up' past x-posts I
have made, when typing in the 'Newsgroups'
box (instead it sems to produce email
addresses from my gmail account!)

...anyway, back to the ..already off-topic
thread.

Andrew T.


Daniel Pitts 01-27-2007 08:14 AM

Re: OT:News readers..so many to choose from
 


On Jan 26, 9:36 pm, "Daniel Pitts" <googlegrou...@coloraura.com> wrote:
> On Jan 26, 6:47 pm, Print Dude <printerdude1...@gmail.com> wrote:
>
> > Well I've abandoned google groups for the time being and have switched
> > over to PAN on Linux and Gravity on Windows. What I am wondering is,
> > how hard would it be to write a news reader client in Java? I know it's
> > way beyond me, but there must be people reading this ng who have had
> > some degree of sucess at it. What was the process you went through to
> > design and build the program? How much practical experience would one
> > need to be able to sucessfully code such a program? If you know that
> > you need say, a class that will send a request to a news server, how do
> > you go about finding it in the API documentation? And if you don't find
> > one, do you write your own or simply extend one that is already there,
> > and is close to what you need? I have a book on OO Design coming, but
> > it would be interesting to know what others think. I know this is
> > pseudo-off topic, which is why I put the OT in the subject line. This
> > is my first post using Gravity so it may not work, but if it does, I
> > hope we can have a good discussion about this topic, if it hasn't
> > already been hash(tabled) before.

>
> > Cheers

> Actually, writing a simple newsreader probably wouldn't be too hard,
> the NNTP protocol is well documented, and socket programming is "too
> easy" in Java.


To follow up. in the last 30 minuts, I wrote a simple Swing application
that will download a list of newsgroups from my local provider, and
display them in a JTree.

It wouldn't be hard to "extend" this to download messages for a
particular group.
My only references were: <http://tools.ietf.org/html/rfc977> and of
course the JDK javadoc.

Less than 100 lines of code too:
<sscce file="GroupSSCCE.java" javac="GroupSSCCE.java" run="java
GroupSSCCE">
import javax.swing.*;
import javax.swing.tree.DefaultTreeModel;
import java.awt.*;
import java.io.*;
import java.util.*;

class GroupSSCCE {
static final String MESSAGE = "Please enter your nntp server
address";

public static void main(String[] args) throws Throwable {

UIManager.setLookAndFeel(UIManager.getSystemLookAn dFeelClassName());
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
String host = getHost();

final GroupNode root = new GroupNode(host);

final DefaultTreeModel model = new DefaultTreeModel(root);
final JLabel countLabel = new JLabel("");
initMainFrame(model, countLabel, host);

java.net.Socket socket = new java.net.Socket(host, 119);

BufferedReader in = getIn(socket);
PrintWriter out = getOut(socket);

System.out.println(in.readLine());
out.println("list");
out.flush();
System.out.println(in.readLine());

long count = 0;
for (String line = in.readLine();
line.trim().length() > 1;
line = in.readLine()) {
addGroup(root,new StringTokenizer(getGroupName(line),
"."),model);
countLabel.setText("Groups: " + ++count);
}
System.out.println("Done!");
}

static void addGroup(GroupNode node,
StringTokenizer tokenizer, DefaultTreeModel model)
{
while (tokenizer.hasMoreTokens()) {
node = node.walkTo(model, tokenizer.nextToken());
}
}

static String getHost() {
return JOptionPane.showInputDialog(MESSAGE, "news.astound.net");
}

static PrintWriter getOut(java.net.Socket socket) throws Throwable {
return new PrintWriter(socket.getOutputStream());
}

static BufferedReader getIn(java.net.Socket socket) throws Throwable
{
return new BufferedReader(
new InputStreamReader(socket.getInputStream()));
}

static void initMainFrame(final DefaultTreeModel model,
final JLabel countLabel, final String
host){
SwingUtilities.invokeLater(new Runnable() {
public void run() {
final JFrame jframe = new JFrame("Groups: " + host);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
jframe.getContentPane().add(new JScrollPane(new JTree(model)),
BorderLayout.CENTER);
jframe.getContentPane().add(countLabel, BorderLayout.SOUTH);
jframe.setLocationRelativeTo(null);
jframe.pack();
jframe.setVisible(true);
}
});
}

static String getGroupName(String line) {
return new StringTokenizer(line).nextToken();
}
}

class GroupNode extends javax.swing.tree.DefaultMutableTreeNode {
HashMap<String, GroupNode> kids = new HashMap<String, GroupNode>();
GroupNode(String name) {
super(name, true);
}
GroupNode walkTo(DefaultTreeModel model, String child) {
GroupNode node = kids.get(child);
if (node == null) {
node = new GroupNode(child);
kids.put(child, node);
add(node);
model.nodesWereInserted(this, new int[] {children.size()-1});
}
return node;
}
}
</sscce>


Print Dude 01-27-2007 01:58 PM

Re: OT:News readers..so many to choose from
 
In article <1169876201.931541.123800@q2g2000cwa.googlegroups. com>,
googlegroupie@coloraura.com says...
> Out of curiousity, did you abandon Google because of their new look and
> feel?
> I don't like it myself, but I haven't bothered finding an alternative
> yet.
>
>

Pretty much my reasoning. I'm not sure I like Gravity all that much
either. PAN on Linux is great so far.

As I expected, the code you show later is way beyond me but it looks
like someone with a fair amount of experience with Swing and networking
and sockets could do it. I've got a long way to go...

Print Dude 01-27-2007 02:01 PM

Re: OT:News readers..so many to choose from
 
In article <1169879682.329090.300080@p10g2000cwp.googlegroups .com>,
andrewthommo@gmail.com says...
> ..anyway, back to the ..already off-topic
> thread.
>

.....which you never did respond to :-) I know it's off topic, which is
why I added OT to the subject line (isn't this the correct way to start
a discussion which may be considered off-topic). Do you have anything
that you can add to the discussion about newsreader client construction,
in particular the process you would go through to come up with such a
product?

Andrew Thompson 01-27-2007 02:52 PM

Re: OT:News readers..so many to choose from
 
On Jan 28, 1:01 am, Print Dude <printerdude1...@gmail.com> wrote:
> In article <1169879682.329090.300...@p10g2000cwp.googlegroups .com>,
> andrewtho...@gmail.com says...
> > ..anyway, back to the ..already off-topic
> > thread.....

> which you never did respond to :-) I know it's off topic, which is
> why I added OT to the subject line (isn't this the correct way to start
> a discussion which may be considered off-topic).


(shrugs) Yeah.. hey I was just going with your
flow*, usually I do not even bother to mention
when /I/ begin to take a conversation OT.

(* Not that I regard discussions on posting
tools to be off-topic for any NG.)

>.. Do you have anything
> that you can add to the discussion about newsreader client construction,
> in particular the process you would go through to come up with such a
> product?


No. It is not my particular area of specialty, and
it looks like Daniel has already posted code that
would get you further than my sum total of
knowledge of writing a news client.

Andrew T.


Lew 01-27-2007 03:30 PM

Re: OT:News readers..so many to choose from
 
I am partial to Mozilla Thunderbird.

BTW, how is writing a newsgroup reader in Java OT for this group? Seems pretty
on topic to me, but, hey.

- Lew

Print Dude 01-27-2007 03:38 PM

Re: OT:News readers..so many to choose from
 
Hi, I copied and pasted your code into Eclipse but it won't run.
Here's the error dump I get:

java.lang.UnsupportedClassVersionError: Bad version number in .class
file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
at java.security.SecureClassLoader.defineClass
(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:260)
at java.net.URLClassLoader.access$100(URLClassLoader. java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
Exception in thread "main"

Any ideas? I've set the jdk to 1.6 and rebuilt the project a couple of
times, to no avail.

Print Dude 01-27-2007 03:47 PM

Re: OT:News readers..so many to choose from
 
In article <F_KdnY-6CemH7SbYnZ2dnUVZ_t_inZ2d@comcast.com>,
lew@nowhere.com says...
> I am partial to Mozilla Thunderbird.
>
> BTW, how is writing a newsgroup reader in Java OT for this group? Seems pretty
> on topic to me, but, hey.
>
> - Lew
>

Not sure. The idea of OO Design (the process, not the end result) may
be considered Off-Topic by some. The FAQ (which I have read extensivly)
talks about what is considered verboten and not, but it seemed to me as
I was trying to formulate my question, that this would be the best forum
to post in. It's not exactly a plea for help, so c.l.j.h would not
work, neither would c.l.j.g And since these are the only 3 forums I
subscribe to, the process of elimination left c.l.j.p


All times are GMT. The time now is 05:16 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.