Local Variables Passing info between classes etc.

From: Jeffrey Spoon (JeffreySpoon_at_hotmail.com)
Date: 08/13/04


Date: Fri, 13 Aug 2004 22:46:20 +0100


Hello again. I suppose I have a sort of general question. The program I
am working on has this method (which I posted in another thread).

public void parseArticleMethod (String articleField) {

        System.out.println("Article Field: " + articleField);

      String[] data = { articleField };
         int i = 0;
         String[] field = data[i].split("\\s+");
         int len = field.length;
         System. out.println("Record " + i + " has " + len + "
fields.");
         if(len > 0) {
           // System. out.println("First field: " + field[0]); //test
         }

        if(field[0].equals("Message-ID:")) {
                System. out.println("Message-ID found: " + field[0]);

        }else if(field[0].equals("From:")){
                System. out.println("From found: " + field[0]);

        }else if(field[0].equals("Subject:")){
                System. out.println("Subject found: " + field[0]);

        }else if(field[0].equals("Newsgroups:")){
                System. out.println("Newsgroups found: " + field[0]);

        }else if(field[0].equals("")){
                System. out.println("Body found: " + field[0]);}

}//method parseArticleMethod

in a class, amongst other methods. Now it extends the class above it
which passes it the input a string at a time. Another class does the
input/output loop with the server/client. What I want to do is pass the
Message-ID etc. fields to an Article Object and initialise it with the
arguments parsed (such as the actual message-id etc.).

The trouble is, since it gets data a string at a time, that's fine for
the single line headers, but for the body it's a bit more difficult. The
parseArticleMethod needs to return to get the next line of input, by
returning itself and getting the response from the client/server
handling class. Declaring a set or array etc. inside the ParseArticle
method would simply reset it each time it is called. I think declaring
the set or array in the superclass might work, but this seems untidy as
the superclass doesn't need to know the contents of the set/array and
just generally confuses things. Am I missing something here, or should I
just declare it in the superclass (though I'm not even sure if that will
work since the class above may reset it also once it is called again).
Any help appreciated.

-- 
Jeffrey Spoon


Relevant Pages

  • Re: Dont get Array value in textbox
    ... Public Sub UT(ByVal Segment As String, ByVal BD As, ByVal ... though there's little problem with declaring it as a Function. ... USPoPA_NpaNxx = Cells(adrsX, adrsY) ... Dim test As String ...
    (microsoft.public.vb.general.discussion)
  • Re: VB 2008: Option Strict On + Infer On at class level
    ... What does the compiler prevent from declaring x As String? ... Public Sub New ...
    (microsoft.public.dotnet.languages.vb)
  • Re: problem with function
    ... Hence any attempt to write into memory past the end of oldName would ... you are declaring newName inside the ... after oldName so the compiler is not warning you when you overwrite ... If you declare a dummy string just after oldName in your second ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Working with floating point numbers.
    ... Some languages let you do this sort of thing by declaring two variables ... at the same address - e.g. a Double and an 8-byte array of Char. ... S As String * 4 ... Dim S As MyStrings ...
    (microsoft.public.access.modulesdaovba)
  • Re: Local Variables Passing info between classes etc.
    ... In message, Jeffrey Spoon ... Declaring a set or array etc. inside the ParseArticle ... >the set or array in the superclass might work, ... >work since the class above may reset it also once it is called again). ...
    (comp.lang.java.help)

Loading