aeron-client/src/main/java/io/aeron/ChannelUri.java
public static ChannelUri parse(final CharSequence cs)
    {
        int position = 0;
        final String prefix;
        if (startsWith(cs, 0, SPY_PREFIX))
        {
            prefix = SPY_QUALIFIER;
            position = SPY_PREFIX.length();
        }
        else
        {
            prefix = "";
        }

        if (!startsWith(cs, position, AERON_PREFIX))
        {
            throw new IllegalArgumentException("Aeron URIs must start with 'aeron:', found: '" + cs + "'");
        }
        else
        {
            position += AERON_PREFIX.length();
        }

        final StringBuilder builder = new StringBuilder();
        final Map<String, String> params = new Object2ObjectHashMap<>();
        String media = null;
        String key = null;

        State state = State.MEDIA;
        for (int i = position; i < cs.length(); i++)
        {
            final char c = cs.charAt(i);

            switch (state)
            {
                case MEDIA:
                    switch (c)
                    {
                        case '?':
                            media = builder.toString();
                            builder.setLength(0);
                            state = State.PARAMS_KEY;
                            break;

                        case ':':
                            throw new IllegalArgumentException("encountered ':' within media definition");

                        default:
                            builder.append(c);
                    }
                    break;

                case PARAMS_KEY:
                    if (c == '=')
                    {
                        key = builder.toString();
                        builder.setLength(0);
                        state = State.PARAMS_VALUE;
                    }
                    else
                    {
                        builder.append(c);
                    }
                    break;

                case PARAMS_VALUE:
                    if (c == '|')
                    {
                        params.put(key, builder.toString());
                        builder.setLength(0);
                        state = State.PARAMS_KEY;
                    }
                    else
                    {
                        builder.append(c);
                    }
                    break;

                default:
                    throw new IllegalStateException("unexpected state=" + state);
            }
        }

        switch (state)
        {
            case MEDIA:
                media = builder.toString();
                break;

            case PARAMS_VALUE:
                params.put(key, builder.toString());
                break;

            default:
                throw new IllegalArgumentException("no more input found, state=" + state);
        }

        return new ChannelUri(prefix, media, params);
    }
public static ChannelUri parse(final CharSequence cs)
    {
        int position = 0;
        final String prefix;
        if (startsWith(cs, 0, SPY_PREFIX))
        {
            prefix = SPY_QUALIFIER;
            position = SPY_PREFIX.length();
        }
        else
        {
            prefix = "";
        }

        if (!startsWith(cs, position, AERON_PREFIX))
        {
            throw new IllegalArgumentException("Aeron URIs must start with 'aeron:', found: '" + cs + "'");
        }
        else
        {
            position += AERON_PREFIX.length();
        }

        final StringBuilder builder = new StringBuilder();
        final Map<String, String> params = new Object2ObjectHashMap<>();
        String media = null;
        String key = null;

        State state = State.MEDIA;
        for (int i = position; i < cs.length(); i++)
        {
            final char c = cs.charAt(i);

            switch (state)
            {
                case MEDIA:
                    switch (c)
                    {
                        case '?':
                            media = builder.toString();
                            builder.setLength(0);
                            state = State.PARAMS_KEY;
                            break;

                        case ':':
                            throw new IllegalArgumentException("encountered ':' within media definition");

                        default:
                            builder.append(c);
                    }
                    break;

                case PARAMS_KEY:
                    if (c == '=')
                    {
                        key = builder.toString();
                        builder.setLength(0);
                        state = State.PARAMS_VALUE;
                    }
                    else
                    {
                        builder.append(c);
                    }
                    break;

                case PARAMS_VALUE:
                    if (c == '|')
                    {
                        params.put(key, builder.toString());
                        builder.setLength(0);
                        state = State.PARAMS_KEY;
                    }
                    else
                    {
                        builder.append(c);
                    }
                    break;

                default:
                    throw new IllegalStateException("unexpected state=" + state);
            }
        }

        switch (state)
        {
            case MEDIA:
                media = builder.toString();
                break;

            case PARAMS_VALUE:
                params.put(key, builder.toString());
                break;

            default:
                throw new IllegalArgumentException("no more input found, state=" + state);
        }

        return new ChannelUri(prefix, media, params);
    }
public static ChannelUri parse ( final CharSequence cs ) { int position = 0 ; final String prefix ; if ( startsWith ( cs , 0 , SPY_PREFIX ) ) { prefix = SPY_QUALIFIER ; position = SPY_PREFIX . length ( ) ; } else { prefix = "" ; } if ( ! startsWith ( cs , position , AERON_PREFIX ) ) { throw new IllegalArgumentException ( "Aeron URIs must start with 'aeron:', found: '" + cs + "'" ) ; } else { position += AERON_PREFIX . length ( ) ; } final StringBuilder builder = new StringBuilder ( ) ; final Map < String , String > params = new Object2ObjectHashMap <> ( ) ; String media = null ; String key = null ; State state = State . MEDIA ; for ( int i = position ; i < cs . length ( ) ; i ++ ) { final char c = cs . charAt ( i ) ; switch ( state ) { case MEDIA : switch ( c ) { case ' ' : media = builder . toString ( ) ; builder . setLength ( 0 ) ; state = State . PARAMS_KEY ; break ; case ' ' : throw new IllegalArgumentException ( "encountered ':' within media definition" ) ; default : builder . append ( c ) ; } break ; case PARAMS_KEY : if ( c == ' ' ) { key = builder . toString ( ) ; builder . setLength ( 0 ) ; state = State . PARAMS_VALUE ; } else { builder . append ( c ) ; } break ; case PARAMS_VALUE : if ( c == ' ' ) { params . put ( key , builder . toString ( ) ) ; builder . setLength ( 0 ) ; state = State . PARAMS_KEY ; } else { builder . append ( c ) ; } break ; default : throw new IllegalStateException ( "unexpected state=" + state ) ; } } switch ( state ) { case MEDIA : media = builder . toString ( ) ; break ; case PARAMS_VALUE : params . put ( key , builder . toString ( ) ) ; break ; default : throw new IllegalArgumentException ( "no more input found, state=" + state ) ; } return new ChannelUri ( prefix , media , params ) ; }
Parse a {@link CharSequence} which contains an Aeron URI.

@param cs to be parsed.
@return a new {@link ChannelUri} representing the URI string.
Parse a { @link CharSequence } which contains an Aeron URI .