Examples of StringTokenizer


Examples of java.util.StringTokenizer

  public static Hashtable sortClassesByRoot(String classes) {
    Hashtable                 roots;
    Hashtable                 result;
    Enumeration               enm;
    int                       i;
    StringTokenizer           tok;
    String                    clsname;
    Vector                    list;
    HierarchyPropertyParser   hpp;
    String                    separator;
    String                    root;
    String                    tmpStr;
   
    if (classes == null)
      return null;
   
    roots     = new Hashtable();
    hpp       = new HierarchyPropertyParser();
    separator = hpp.getSeperator();
   
    // go over all classnames and store them in the hashtable, with the
    // root element as the key
    tok   = new StringTokenizer(classes, ", ");
    while (tok.hasMoreElements()) {
      clsname = tok.nextToken();
      root    = getRootFromClass(clsname, separator);
      if (root == null)
        continue;
     
      // already stored?
View Full Code Here

Examples of java.util.StringTokenizer

    // existing MD5 keys become invalid
    removeHeader(HttpHeader.CONTENT_MD5);
  }
 
  public void setHttpCode(String httpCode) {
    StringTokenizer st = new StringTokenizer(httpCode," ");
    // an HTTP answer must have at least 2 fields
    if (st.countTokens() < 2) {
      return;
    }
  
    st.nextToken();
    String codeStr = st.nextToken();
   
    try {
      httpReturnCode = Integer.parseInt(codeStr);
    } catch (NumberFormatException e) {
      // something is wrong !!!
View Full Code Here

Examples of java.util.StringTokenizer

      lineno++;

      if ((line != null) &&
          (! line.trim().equals("")) &&
          (! line.startsWith("#"))) {
        StringTokenizer st = new StringTokenizer(line);
        // did we get 2 tokens ?
        if (st.countTokens() != 2) {
          throw new IOException("line "+lineno+" don't consists of 2 fields");
        }

        String allowStr = st.nextToken();
        boolean allow = true;
        String expression = st.nextToken();

        // allow or deny ?
        if (allowStr.equalsIgnoreCase("allow")) {
          allow=true;
        } else if (allowStr.equalsIgnoreCase("deny")) {
View Full Code Here

Examples of java.util.StringTokenizer

      lineno++;

      if ((line != null) &&
    (! line.trim().equals("")) &&
    (! line.startsWith("#"))) {
  StringTokenizer st = new StringTokenizer(line);
  // we need at least 2 tokens
  if (st.countTokens() < 2) {
    throw new IOException("line "+lineno+" has less then 2 fields");
  }

  String allowStr = st.nextToken();
  boolean allow = true;
  String mime = st.nextToken();

  // allow or deny ?
  if (allowStr.equalsIgnoreCase("allow")) {
    allow=true;
  } else if (allowStr.equalsIgnoreCase("deny")) {
    allow=false;
  } else {
    throw new IOException("first token in line "+lineno+
        " has to be allow or deny");
  }
   
 
  DownloadRule r = new DownloadRule();
  r.setAllow(allow);
  try {
    r.setMimeType(mime);
  } catch (IllegalArgumentException e) {
    throw new IOException(e.getMessage());
  }
 

  // parse < and > rules
  while (st.hasMoreTokens()) {
    boolean isMin=true;

    String descr=st.nextToken();
   
    if (descr.startsWith("<")) {
      // it is a maximum value
      isMin=false;
    } else if (descr.startsWith(">")) {
View Full Code Here

Examples of java.util.StringTokenizer

   
    // modified Dominic Betts 28/5/02
    // mimetype like:
    // Content-Type: text/html; Charset=iso-8859-1
    if (mimeType.indexOf(";") > 0) {
        StringTokenizer st = new StringTokenizer(mimeType, ";");
        mimeType = st.nextToken();
    }

    String basetype = null;
    String subtype = null;
    StringTokenizer st = new StringTokenizer(mimeType,"/");
    basetype = st.nextToken();
    subtype = st.nextToken();

    for (int i=0; i<rules.size(); i++) {
      DownloadRule rule = (DownloadRule)rules.elementAt(i);
      if (rule.matches(basetype,subtype,size)) {
  return rule;
View Full Code Here

Examples of java.util.StringTokenizer

        iRandomSelection = properties.getPropertyBoolean("HillClimber.Random", iRandomSelection);
        iUpdatePoints = properties.getPropertyBoolean("HillClimber.Update", iUpdatePoints);
        String neighbours = properties.getProperty("HillClimber.Neighbours",
                ItcSwapMove.class.getName()+"@1;"+
                ItcNotConflictingMove.class.getName()+"@1");
        for (StringTokenizer s=new StringTokenizer(neighbours,";");s.hasMoreTokens();) {
            String nsClassName = s.nextToken();
            double bonus = 1.0;
            if (nsClassName.indexOf('@')>=0) {
                bonus = Double.parseDouble(nsClassName.substring(nsClassName.indexOf('@')+1));
                nsClassName = nsClassName.substring(0, nsClassName.indexOf('@'));
            }
View Full Code Here

Examples of java.util.StringTokenizer

          parameters = urlString.substring(questionMark+1,restPosition);
          rest = urlString.substring(restPosition);
        }
         
        StringBuffer filteredUrl = new StringBuffer(urlString.substring(0,questionMark));
        StringTokenizer tokenizer = new StringTokenizer(parameters, "&");
        String and = "?";
        boolean changed = false;
        while (tokenizer.hasMoreTokens()) {
          String token = tokenizer.nextToken();
          boolean keep = true;
          for (int w=0; w<wasteParameters.size(); w++) {
            String wasteParameter = (String) wasteParameters.elementAt(w);
            if (token.startsWith(wasteParameter + "=")) {
              keep = false;
View Full Code Here

Examples of java.util.StringTokenizer

   private void getArchiveArray(String archiveList)
   {
      if (archiveList != null)
      {
         StringTokenizer st = new StringTokenizer(archiveList, ", ");
         archives = new String[st.countTokens()];

         for (int i = 0; i < archives.length; i++)
            archives[i] = st.nextToken();
      }
   }
View Full Code Here

Examples of java.util.StringTokenizer

  {
    this();

    String cookieHeader = null;
    String host = "";
    StringTokenizer tokens = null;

    // does is start with "Set-Cookie" ?
    if (setCookie.substring(0,HEADER_SETCOOKIE.length()).equalsIgnoreCase(HEADER_SETCOOKIE)) {
      cookieHeader = setCookie.substring(HEADER_SETCOOKIE.length());
    } else {
      throw new CookieException("Not a Set-Cookie header");
    }

    // set defaults from the URL
    if (u != null) {
      this.domain = u.getHost().toLowerCase();
      host = this.domain;
    } else {
      this.domain = "";
    }

    // tokenize setcookie request
    tokens = new StringTokenizer(cookieHeader,";");

    // there must be at least ONE token (name=value)
    if (tokens.countTokens() < 1) {
      throw new CookieException("Cookie contains no data");
    } else {
      String field = tokens.nextToken();
      int pos = field.indexOf('=');
      if (pos <= 0) {
  throw new CookieException("First field not in the format NAME=VALUE"
          +" but got "+field);
      } else {
  name = field.substring(0,pos).trim();
  value = field.substring(pos+1);
      }
    }

    // parse all other fields
    while (tokens.hasMoreTokens()) {
      String field = tokens.nextToken();
      String fieldname="";
      String fieldvalue="";

      int pos = field.indexOf('=');
      if (pos <= 0) {
View Full Code Here

Examples of java.util.StringTokenizer

      if (drivers == null) {
        throw new Exception("No database drivers (JDBC) specified");
      }
      // The call to newInstance() is necessary on some platforms
      // (with some java VM implementations)
      StringTokenizer st = new StringTokenizer(drivers, ", ");
      while (st.hasMoreTokens()) {
        String driver = st.nextToken();
        boolean result;
        try {
          Class.forName(driver);
          DRIVERS.addElement(driver);
          result = true;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.