Package java.util.regex

Examples of java.util.regex.Matcher


   * @param filter range expression
   * @return list of matched DownloadManager objects
   */
  private List matchRange( List torrents, String filter )
  {
    Matcher matcher = rangePattern.matcher(filter);
    List list = new ArrayList();
    if( matcher.matches() )
    {
      int minId = Integer.parseInt(matcher.group(1));
      if( minId == 0 )
        throw new AzureusCoreException("lower range must be greater than 0");
      if( minId > torrents.size() )
        throw new AzureusCoreException("lower range specified (" + minId + ") is outside number of torrents (" + torrents.size() + ")");
      if( matcher.group(2) == null )
      {       
        // received a single number. eg: 3
        list.add(torrents.get(minId-1));
        return list;
      }
      int maxId;
      if( matcher.group(3) == null )
        // received bound range. eg: 3-5
        maxId = Integer.parseInt(matcher.group(5));
      else
        // received open ended range. eg: 3-
        maxId = torrents.size();
     
      if( minId > maxId )


    //       Restart doesn't include azureus.script.version yet, so we
    //       would normally prompt again.  This fix reads the version
    //       from the file if we don't have a version yet, thus preventing
    //       the second restart message
    if (version == 0) {
      Matcher matcher = pat.matcher(oldStartupScript);
      if (matcher.find()) {
        String sScriptVersion = matcher.group(1);
        try {
          version = Integer.parseInt(sScriptVersion);
        } catch (Throwable t) {
        }
      }
    }
   
    if (version <= lastAskedVersion) {
      return;
    }

    InputStream stream = getClass().getResourceAsStream("startupScript");
    try {
      String startupScript = FileUtil.readInputStreamAsString(stream, 65535,
          "utf8");
      Matcher matcher = pat.matcher(startupScript);
      if (matcher.find()) {
        String sScriptVersion = matcher.group(1);
        int latestVersion = 0;
        try {
          latestVersion = Integer.parseInt(sScriptVersion);
        } catch (Throwable t) {
        }

        File file = new File(confList[i]);
        if (file.isFile() && file.canRead()) {
          log("  checking " + file + " for GRE_PATH");
          String fileText = FileUtil.readFileAsString(file, 16384);
          if (fileText != null) {
            Matcher matcher = pat.matcher(fileText);
            if (matcher.find()) {
              String possibleGrePath = matcher.group(1);
              if (isValidGrePath(new File(possibleGrePath))) {
                grePath = possibleGrePath;
                break;
              }
            }

  }
 
  public static String expandValue(String value) {
    // Replace {*} with a lookup of *
    if (value != null && value.indexOf('}') > 0) {
      Matcher matcher = PAT_PARAM_ALPHA.matcher(value);
      while (matcher.find()) {
        String key = matcher.group(1);
        try {
          String text = getResourceBundleString(key);
          if (text != null) {
            value = value.replaceAll("\\Q{" + key + "}\\E", text);
          }

          String startIp = null;
          String endIp = null;
          int level = 0;

          if (parseMode <= 0 || parseMode == 1) {
            Matcher matcher = pattern.matcher(line);
            if (matcher.find()) {
              if (parseMode != 1) {
                parseMode = 1;
              }
              description = matcher.group(1);
              startIp = matcher.group(2);
              endIp = matcher.group(3);
            } else {
              Logger.log(new LogEvent(LOGID, LogEvent.LT_WARNING,
                  "unrecognized line while reading ip filter: " + line));
            }
          }

  {
    StringBuffer sb = new StringBuffer();
    sb.append(comp.getSequence());
    List ret = new ArrayList();

    Matcher m = urlPattern.matcher(sb);
    int txtStart = 0;
    while(m.find())
    {
      int urlStart = m.start();
      int urlEnd = m.end();
      if(txtStart <= urlStart - 1)
        ret.add(new TextComponent(sb.substring(txtStart, urlStart)));
      String linkText = sb.substring(urlStart, urlEnd);
      try
      {

    }
    return UnmodifiableList.create(ret);
  }
 
  private static AbstractCanvasObject createPath(Element elt) {
    Matcher patt = PATH_REGEX.matcher(elt.getAttribute("d"));
    List<String> tokens = new ArrayList<String>();
    int type = -1; // -1 error, 0 start, 1 curve, 2 polyline
    while (patt.find()) {
      String token = patt.group();
      tokens.add(token);
      if (Character.isLetter(token.charAt(0))) {
        switch (token.charAt(0)) {
        case 'M':
          if (type == -1) type = 0;

  {
    StringBuffer sb = new StringBuffer();
    sb.append(comp.getSequence());
    List ret = new ArrayList();

    Matcher m = urlPattern.matcher(sb);
    int txtStart = 0;
    while(m.find())
    {
      int urlStart = m.start();
      int urlEnd = m.end();
      if(txtStart <= urlStart - 1)
        ret.add(new TextComponent(sb.substring(txtStart, urlStart)));
      String linkText = sb.substring(urlStart, urlEnd);
      try
      {

    List ret = new ArrayList();
    StringBuffer sb = new StringBuffer();
    sb.append(comp.getSequence());

    Matcher m = fontColorPattern.matcher(sb);
    int txtStart = 0;
    while(m.find())
    {
      int txtEnd = m.end();
      if(txtStart < txtEnd)
      {
        String text = sb.substring(txtStart, txtEnd);
        ret.add(new TextComponent(text, currentFont, currentColor));
      }
      txtStart = txtEnd;

      String fontFace = m.group(3);
      String fontSize = m.group(4);
      String colorCodeStr = m.group(7);
      String colorStr = m.group(9);

      if(fontFace != null)
        currentFont = new Font(fontFace, currentFontStyle, currentFontSize);
      if(fontSize != null)
      {

   {
      //jdbc:hsqldb:mem:jbosscache
      Properties toReturn = (Properties) realProps.clone();
      String jdbcUrl = toReturn.getProperty("cache.jdbc.url");
      Pattern pattern = Pattern.compile("jbosscache");
      Matcher matcher = pattern.matcher(jdbcUrl);
      boolean found = matcher.find();
      assert found;
      String newJdbcUrl = matcher.replaceFirst(extractTestName() + userIndex.incrementAndGet());
      toReturn.put("cache.jdbc.url", newJdbcUrl);
      return toReturn;
   }

TOP

Related Classes of java.util.regex.Matcher

Copyright © 2015 www.massapicom. 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.