Example usage for android.content IntentFilter authoritiesIterator

List of usage examples for android.content IntentFilter authoritiesIterator

Introduction

In this page you can find the example usage for android.content IntentFilter authoritiesIterator.

Prototype

public final Iterator<AuthorityEntry> authoritiesIterator() 

Source Link

Document

Return an iterator over the filter's data authorities.

Usage

From source file:com.java2s.intents4.IntentsDemo4Activity.java

String filterToString(IntentFilter filter) {
    StringBuffer buffer = new StringBuffer("IntentFilter { ");

    Iterator<String> actionsIter = filter.actionsIterator();
    if (actionsIter != null) {
        buffer.append("act=[");
        while (actionsIter.hasNext()) {
            String temp = actionsIter.next().trim();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter action: >" + temp + "<");
        }//from ww w .ja  v a  2 s. c  om
        if (buffer.lastIndexOf(",") >= 0) {
            buffer.setCharAt(buffer.lastIndexOf(","), ']');
        } else {
            buffer.append(']');
        }
        buffer.append(" ");
    }

    Iterator<String> schemesIter = filter.schemesIterator();
    if (schemesIter != null) {
        buffer.append("sche=[");
        while (schemesIter.hasNext()) {
            String temp = schemesIter.next().trim();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter scheme: >" + temp + "<");
        }
        buffer.setCharAt(buffer.lastIndexOf(","), ']');
        buffer.append(" ");
    }

    Iterator<IntentFilter.AuthorityEntry> authsIter = filter.authoritiesIterator();
    if (authsIter != null) {
        buffer.append("auth=[");
        while (authsIter.hasNext()) {
            IntentFilter.AuthorityEntry entry = authsIter.next();
            String temp = entry.getHost() + ":" + entry.getPort();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter authority: >" + temp + "<");
        }
        buffer.setCharAt(buffer.lastIndexOf(","), ']');
        buffer.append(" ");
    }

    Iterator<PatternMatcher> pathsIter = filter.pathsIterator();
    if (pathsIter != null) {
        buffer.append("path=[");
        while (pathsIter.hasNext()) {
            PatternMatcher entry = pathsIter.next();
            String temp = entry.toString();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter path: >" + temp + "<");
        }
        buffer.setCharAt(buffer.lastIndexOf(","), ']');
        buffer.append(" ");
    }

    Iterator<String> typesIter = filter.typesIterator();
    if (typesIter != null) {
        buffer.append("typ=[");
        while (typesIter.hasNext()) {
            String temp = typesIter.next().trim();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter type: >" + temp + "<");
        }
        buffer.setCharAt(buffer.lastIndexOf(","), ']');
        buffer.append(" ");
    }

    Iterator<String> catsIter = filter.categoriesIterator();
    if (catsIter != null) {
        buffer.append("cat=[");
        while (catsIter.hasNext()) {
            String temp = catsIter.next().trim();
            buffer.append(temp + ",");
            Log.i(CLASSNAME, "Filter category: >" + temp + "<");
        }
        buffer.setCharAt(buffer.lastIndexOf(","), ']');
        buffer.append(" ");
    }

    buffer.append('}');
    return buffer.toString();
}