Java String Split splitDomains(String domains)

Here you can find the source of splitDomains(String domains)

Description

split Domains

License

Open Source License

Declaration

private static String[] splitDomains(String domains) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

public class Main {
    private static String[] splitDomains(String domains) {
        ArrayList<String> list = new ArrayList<String>();

        int count = domains.length();
        int start = -1;

        for (int i = 0; i < count; ++i) {
            char c = domains.charAt(i);

            switch (c) {
            case '(':
                // Ignore attribute domains such as "a(props new)".
                if (i == 0 || domains.charAt(i - 1) != 'a') {
                    start = i;/*from   w  ww.j  a  v  a2 s .c  o  m*/
                }
                break;
            case ')':
                if (start >= 0) {
                    if (i - start > 1) {
                        list.add(domains.substring(start, i + 1));
                    }
                    start = -1;
                }
                break;
            }
        }

        String[] parts = new String[list.size()];
        list.toArray(parts);

        return parts;
    }
}

Related

  1. splitByTypeAndName(final String s)
  2. splitCamelback(String s)
  3. splitCQLStatements(String source)
  4. splitDateText(String text)
  5. splitDigits(long input)
  6. splitElements(String values)
  7. splitEx(String str, String spilter)
  8. splitFields(String fieldsString, int minNum)
  9. splitForIndexMatching(String string)