Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static boolean matches(String[] filters, Matcher matcher) {
        for (String filter : filters) {
            // Is logcat filter?
            if (filter.matches("(\\w+|\\*):[\\w|\\*]")) {
                String[] matches = filter.split(":");
                // Tag and level match?
                if ((matches[0].equals("*") || matches[0].equals(matcher.group(6)))
                        && (matches[1].equals("*") || matches[1].equals(matcher.group(5)))) {
                    return true;
                }
            } else {
                Pattern pattern = Pattern.compile(".*" + Pattern.quote(filter) + ".*", Pattern.CASE_INSENSITIVE);
                for (int i = 1; i < 8; i++) {
                    if (pattern.matcher(matcher.group(i)).matches()) {
                        return true;
                    }
                }
            }
        }
        return false;
    }
}