Class GIT.GVU.IMAP.Util
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class GIT.GVU.IMAP.Util

java.lang.Object
   |
   +----GIT.GVU.IMAP.Util

public class Util
extends Object
Class to hold some miscellaneous utility routines.

Constructor Index

 o Util()

Method Index

 o buildList(String, int)
This function walks over a string to build up a list
 o getLine()
Utility function to read a line of text from the terminal.
 o lookingAt(String, String)
Checks to see if the string s2 is the prefix of s1
 o makeWidth(String, int)
formats a string to a particular width
 o parseAddresses(Vector)
This function takes a Vector which it assumes is a vector of vectors.
 o parseString(String, int)
Given a string and a position, return the string (atom or quoted string) or list (as a vector) that this string parses into.
 o parseStringList(String)
This function takes in a list (q.v.
 o removeParsingData(Vector)
This function strips out the extra elements a list that are created by the parsing routines.
 o replyToken(Vector, String)
Checks a vector to see if the last element in the vector has a string as the second token in the vector's last element.
 o stringInVector(Vector, String)
This function determines if a given string is in a list of strings that are encoded in a vector.

Constructors

 o Util
  public Util()

Methods

 o lookingAt
  public static boolean lookingAt(String s1,
                                  String s2)
Checks to see if the string s2 is the prefix of s1
Parameters:
s1 - string to check for a prefix
s2 - prefix string
Returns:
true if the s2 string is the prefix of s1
 o replyToken
  public static boolean replyToken(Vector v,
                                   String s)
Checks a vector to see if the last element in the vector has a string as the second token in the vector's last element. This is generally to determine if the round trip reply is OK.
Parameters:
v - the vector of results returned from the server
s - the string to check for
Returns:
true if the string s is the second token in the last element of v
 o parseStringList
  public static Vector parseStringList(String val)
This function takes in a list (q.v. RFC1730) of strings and returns a list of the strings in the list. It assumes you have already removed the trailing ')' but have not removed the initial '(' (which this code does remove).
Parameters:
a - list of strings formatted as in RFC 1730
Returns:
a vector with those strings parsed out
 o stringInVector
  public static boolean stringInVector(Vector v,
                                       String s)
This function determines if a given string is in a list of strings that are encoded in a vector. This is useful if you consider Vector as a set, and then this function tests for membership in the set.
Parameters:
v - vector of strings
s - is this string in the vector?
Returns:
true if string is in the list of strings, false otherwise
 o makeWidth
  public static String makeWidth(String s,
                                 int w)
formats a string to a particular width
Parameters:
s - string to format
w - integer width
Returns:
new string of the specified width
 o parseString
  public static Vector parseString(String s,
                                   int pos) throws InternalErr
Given a string and a position, return the string (atom or quoted string) or list (as a vector) that this string parses into. If there are no more tokens in the string, it returns null. Note: What is actually returned is a vector of two elements. The first is the token (string or vector), the second is an Integer which is the next character position to process. If the returned value's first slot is null, the second slot might be -1. If so, there is no more input.
Parameters:
s - string to parse
n - starting position to start parsing at
Returns:
a string or a vector which is the parsed result of the input
Throws: InternalErr
is thrown if the we unable to successfully parse a token
 o buildList
  public static Vector buildList(String s,
                                 int p) throws InternalErr
This function walks over a string to build up a list
Parameters:
string - s the string to walk over
int - p where to start walking
Returns:
a vector of two elements: the first a vector with the list in it, the second is the next position to check
Throws: InternalErr
is propagated
 o removeParsingData
  public static Object removeParsingData(Vector v)
This function strips out the extra elements a list that are created by the parsing routines.
Parameters:
vector - v of 2 elements returned from the parsing routines
Returns:
new object which is the first element of the two that came in plus a recursive decent of all children
 o parseAddresses
  public static Vector parseAddresses(Vector v) throws InternalErr
This function takes a Vector which it assumes is a vector of vectors. The inner vectors should be made of strings which are mail addresses in RFC1730 format. It returns a vector of MailAddress objects.
Parameters:
Vector - v vector of mail address vectors
Returns:
a vector of mail address objects
Throws: InternalErr
is thrown if you pass in a vector which is not the right size to be a mail address
 o getLine
  public static String getLine() throws IOException
Utility function to read a line of text from the terminal.
Returns:
the string with the line of text read

All Packages  Class Hierarchy  This Package  Previous  Next  Index