All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class mesquite.lib.ParseUtil

java.lang.Object
   |
   +----mesquite.lib.StringUtil
           |
           +----mesquite.lib.ParseUtil

public class ParseUtil
extends mesquite.lib.StringUtil
A set of string parsing methods. Should be renamed StringParser or NEXUSParser.


Constructor Index

 o ParseUtil()

Method Index

 o charOnDeck(String, MesquiteInteger, int)
 o darkBeginsWithIgnoreCase(String, String)
returns token from line starting at startChar; keeps track of pending square bracket closure, etc.* public static String getToken(String line, MesquiteInteger startChar, MesquiteInteger pendingBrackets, StringBuffer comment) { if (line==null) return null; else if (line.equals("")) return ""; if (startChar.getValue() >= line.length()) return null; StringBuffer temp = new StringBuffer(100); //better to pass from outside char c; try { boolean continu = true; while (whitespace(c=getNextChar(line, startChar, pendingBrackets, comment), null)) //skipping whitespace in front ; if (punctuation(c, null)) { continu = false; if (c == defaultQuote) { temp.setLength(0); temp.append(getQuoted(line, startChar)); } else if (c == '-') { char cod = charOnDeck(line, startChar, 1); char cod2 = charOnDeck(line, startChar, 2); if (("0123456789".indexOf(cod)>=0)||(cod=='.' && ("0123456789".indexOf(cod2)>=0))) { temp.append(c); c=getNextChar(line, startChar, pendingBrackets, comment); continu = true; } else { temp.append(c); } } else temp.append(c); } if (continu) { while ((!whitespace(c, null) && !punctuation(c, null)) && c !=0) { if (c=='_') c = ' '; temp.append(c); c=getNextChar(line, startChar, pendingBrackets, comment); } if (punctuation(c, null)) { startChar.decrement(); } } } catch (StringIndexOutOfBoundsException e) { System.out.println("string bounds exceeded 1"); startChar.setValue(line.length()); } return temp.toString(); } /*.................................................................................................................
 o firstDarkChar(String)
 o getFirstToken(String, MesquiteInteger)
returns first token from string; sets pos to end of token; excluding square bracket comments
 o getRemaining(String, MesquiteInteger)
returns remainder of line starting at startChar; including square bracket comments
 o getSubcommands(String, MesquiteInteger)
 o getToken(String, MesquiteInteger)
returns token from line starting at startChar; excluding square bracket comments
 o getToken(String, MesquiteInteger, String, String)
returns token from line starting at startChar; excluding square bracket comments
 o getTokenNumber(String, MesquiteInteger, int)
 o getTokens(String, MesquiteInteger, int, int)
 o nextDarkChar(String, MesquiteInteger)
 o skipComment(String, MesquiteInteger)
 o skipToDarkspace(String, MesquiteInteger)

Constructors

 o ParseUtil
 public ParseUtil()

Methods

 o getRemaining
 public static java.lang.String getRemaining(java.lang.String line,
                                             mesquite.lib.MesquiteInteger startChar)
returns remainder of line starting at startChar; including square bracket comments

 o getFirstToken
 public static java.lang.String getFirstToken(java.lang.String line,
                                              mesquite.lib.MesquiteInteger pos)
returns first token from string; sets pos to end of token; excluding square bracket comments

 o getToken
 public static java.lang.String getToken(java.lang.String line,
                                         mesquite.lib.MesquiteInteger startChar)
returns token from line starting at startChar; excluding square bracket comments

 o charOnDeck
 public static char charOnDeck(java.lang.String line,
                               mesquite.lib.MesquiteInteger pos,
                               int ahead)
 o getToken
 public static java.lang.String getToken(java.lang.String line,
                                         mesquite.lib.MesquiteInteger startChar,
                                         java.lang.String whitespaceString,
                                         java.lang.String punctuationString)
returns token from line starting at startChar; excluding square bracket comments

 o darkBeginsWithIgnoreCase
 public static boolean darkBeginsWithIgnoreCase(java.lang.String s,
                                                java.lang.String find)
returns token from line starting at startChar; keeps track of pending square bracket closure, etc.* public static String getToken(String line, MesquiteInteger startChar, MesquiteInteger pendingBrackets, StringBuffer comment) { if (line==null) return null; else if (line.equals("")) return ""; if (startChar.getValue() >= line.length()) return null; StringBuffer temp = new StringBuffer(100); //better to pass from outside char c; try { boolean continu = true; while (whitespace(c=getNextChar(line, startChar, pendingBrackets, comment), null)) //skipping whitespace in front ; if (punctuation(c, null)) { continu = false; if (c == defaultQuote) { temp.setLength(0); temp.append(getQuoted(line, startChar)); } else if (c == '-') { char cod = charOnDeck(line, startChar, 1); char cod2 = charOnDeck(line, startChar, 2); if (("0123456789".indexOf(cod)>=0)||(cod=='.' && ("0123456789".indexOf(cod2)>=0))) { temp.append(c); c=getNextChar(line, startChar, pendingBrackets, comment); continu = true; } else { temp.append(c); } } else temp.append(c); } if (continu) { while ((!whitespace(c, null) && !punctuation(c, null)) && c !=0) { if (c=='_') c = ' '; temp.append(c); c=getNextChar(line, startChar, pendingBrackets, comment); } if (punctuation(c, null)) { startChar.decrement(); } } } catch (StringIndexOutOfBoundsException e) { System.out.println("string bounds exceeded 1"); startChar.setValue(line.length()); } return temp.toString(); } /*.................................................................................................................

 o getTokenNumber
 public static java.lang.String getTokenNumber(java.lang.String s,
                                               mesquite.lib.MesquiteInteger startChar,
                                               int tokenNumber)
 o getTokens
 public static java.lang.String getTokens(java.lang.String s,
                                          mesquite.lib.MesquiteInteger startChar,
                                          int first,
                                          int last)
 o getSubcommands
 public static java.lang.String[][] getSubcommands(java.lang.String s,
                                                   mesquite.lib.MesquiteInteger startChar)
 o skipComment
 public static void skipComment(java.lang.String line,
                                mesquite.lib.MesquiteInteger startChar)
 o skipToDarkspace
 public static void skipToDarkspace(java.lang.String line,
                                    mesquite.lib.MesquiteInteger startChar)
 o nextDarkChar
 public static char nextDarkChar(java.lang.String line,
                                 mesquite.lib.MesquiteInteger startChar)
 o firstDarkChar
 public static char firstDarkChar(java.lang.String line)

All Packages  Class Hierarchy  This Package  Previous  Next  Index