private void checkConstr(String str, String delim, String res[], Collection seps) {
    MyTokenizer tokenizer = new MyTokenizer(str, delim, seps);
    String tok;
    int i;
    int idx = 0;

    for (i = 0; i < res.length; i++) {
      assertTrue(
          "MyTokenizer(\"" + str + "\", \"" + delim + "\") lacks tokens",
          tokenizer.hasMoreTokens());
      tok = tokenizer.nextToken();
      assertTrue("tokenIndex broken", idx == tokenizer.getTokenIndex());
      idx += tok.length();
      assertTrue(
          "MyTokenizer(\""
              + str
              + "\", \""
              + delim
              + "\") has wrong token \""
              + tok
              + "\" != \""
              + res[i]
              + "\"",
          res[i].equals(tok));
    }
    assertTrue(
        "MyTokenizer(\"" + str + "\", \"" + delim + "\") has too many tokens",
        !tokenizer.hasMoreTokens());
  }
  /** Test putToken(). */
  public void testPutToken() {
    MyTokenizer st = new MyTokenizer("Hello old friend", " ");
    int oidx;

    assertTrue("Token 1", "Hello".equals(st.nextToken()));

    oidx = st.getTokenIndex();
    st.putToken(",");
    assertTrue("PutToken 1", ",".equals(st.nextToken()));
    assertTrue("PutTokenIndex 1", oidx == st.getTokenIndex());

    assertTrue("Token 2", " ".equals(st.nextToken()));
    assertTrue("Token 3", "old".equals(st.nextToken()));

    oidx = st.getTokenIndex();
    st.putToken(",");
    st.putToken(";");
    assertTrue("PutToken 2", ";".equals(st.nextToken()));
    assertTrue("PutTokenIndex 2", oidx == st.getTokenIndex());

    st.putToken("?");
    assertTrue("PutToken 3", "?".equals(st.nextToken()));
    assertTrue("PutTokenIndex 3", oidx == st.getTokenIndex());

    assertTrue("Token 4", " ".equals(st.nextToken()));
    assertTrue("Token 5", "friend".equals(st.nextToken()));

    assertTrue("MoreTokens 1", !st.hasMoreTokens());
    st.putToken("?");
    assertTrue("MoreTokens 2", st.hasMoreTokens());
    assertTrue("PutToken 4", "?".equals(st.nextToken()));
    assertTrue("MoreTokens 3", !st.hasMoreTokens());

    try {
      st.putToken(null);
      assertTrue("Allows nulls", false);
    } catch (NullPointerException npe) {
    }
  }
  /** Test lineseparators. */
  public void testLineSeparator() {
    MyTokenizer st = new MyTokenizer("str1\nstr2\r\nstr3\rstr4", "", MyTokenizer.LINE_SEPARATOR);
    MyTokenizer st2 = new MyTokenizer("\n\n\r\n\r\n\r\r", "", MyTokenizer.LINE_SEPARATOR);

    assertEquals(st.nextElement(), "str1");
    assertEquals(st.nextElement(), "\n");
    assertEquals(st.nextElement(), "str2");
    assertEquals(st.nextElement(), "\r\n");
    assertEquals(st.nextElement(), "str3");
    assertEquals(st.nextElement(), "\r");
    assertEquals(st.nextElement(), "str4");
    assertTrue(!st.hasMoreElements());

    assertEquals(st2.nextElement(), "\n");
    assertEquals(st2.nextElement(), "\n");
    assertEquals(st2.nextElement(), "\r\n");
    assertEquals(st2.nextElement(), "\r\n");
    assertEquals(st2.nextElement(), "\r");
    assertEquals(st2.nextElement(), "\r");
    assertTrue(!st2.hasMoreElements());
  }
  protected void parseEnumerationLiteral(String text, Object literal) throws ParseException {
    text = text.trim();
    if (text.length() == 0) {
      return;
    }
    // strip any trailing semi-colons
    if (text.charAt(text.length() - 1) == ';') {
      text = text.substring(0, text.length() - 2);
    }
    MyTokenizer st;

    String name = null;
    StringBuilder stereotype = null;
    String token;

    try {
      st = new MyTokenizer(text, "<<,\u00AB,\u00BB,>>");
      while (st.hasMoreTokens()) {
        token = st.nextToken();

        if ("<<".equals(token) || "\u00AB".equals(token)) {
          if (stereotype != null) {
            String msg = "parsing.error.model-element-name.twin-stereotypes";
            throw new ParseException(Translator.localize(msg), st.getTokenIndex());
          }

          stereotype = new StringBuilder();
          while (true) {
            token = st.nextToken();
            if (">>".equals(token) || "\u00BB".equals(token)) {
              break;
            }
            stereotype.append(token);
          }
        } else {
          if (name != null) {
            String msg = "parsing.error.model-element-name.twin-names";
            throw new ParseException(Translator.localize(msg), st.getTokenIndex());
          }

          name = token;
        }
      }
    } catch (NoSuchElementException nsee) {
      String msg = "parsing.error.model-element-name.unexpected-name-element";
      throw new ParseException(Translator.localize(msg), text.length());
    } catch (ParseException pre) {
      throw pre;
    }

    if (name != null) {
      name = name.trim();
    }
    if (name != null) {
      Model.getCoreHelper().setName(literal, name);
    }

    StereotypeUtility.dealWithStereotypes(literal, stereotype, false);

    return;
  }