Java String Split splitAuthors(String source)

Here you can find the source of splitAuthors(String source)

Description

split Authors

License

Apache License

Declaration

static public ArrayList<String> splitAuthors(String source) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    static public ArrayList<String> splitAuthors(String source) {
        ArrayList<String> authors = new ArrayList<String>();
        int idx = source.indexOf("_and_");
        if (idx > -1) {
            String[] fields = source.split("_and_");
            for (int i = 0; i < fields.length; i++) {
                String field = cleanAuthor(fields[i]);
                if (i > 0) {
                    field = "author:" + field;
                }/*from   w  w w.  ja va 2 s .  co m*/
                authors.add(field);
            }
        }
        // System.out.println(authors.toString());
        return authors;
    }

    public static String cleanAuthor(String author) {
        String cleanAuthor = author;
        int idx = author.indexOf("_in_");
        if (idx > -1) {
            cleanAuthor = author.substring(0, idx);
        }
        idx = cleanAuthor.indexOf("_at_");
        if (idx > -1) {
            cleanAuthor = cleanAuthor.substring(0, idx);
        }
        idx = cleanAuthor.indexOf("?_");
        if (idx > -1) {
            cleanAuthor = cleanAuthor.substring(0, idx);
        }
        return cleanAuthor;
    }
}

Related

  1. splitArray(byte[] src, int size)
  2. splitArray(String[] srcArr, int start, int end)
  3. splitAt(final String input, final String seperator)
  4. splitAtLastBlank(String s, int width)
  5. splitAttributes(final String dname)
  6. splitBreaks(String text)
  7. splitByTypeAndName(final String s)
  8. splitCamelback(String s)
  9. splitCQLStatements(String source)