Here you can find the source of splitNames(final String string)
Parameter | Description |
---|---|
string | qualified name |
private static String[] splitNames(final String string)
//package com.java2s; /**// www.java 2s.c o m * Copyright 2006 StartNet s.r.o. * * Distributed under MIT license */ import java.util.ArrayList; import java.util.List; public class Main { /** * Splits qualified names by dots. If names are quoted then quotes are * removed. * * @param string qualified name * * @return array of names */ private static String[] splitNames(final String string) { if (string.indexOf('"') == -1) { return string.split("\\."); } else { final List<String> strings = new ArrayList<String>(2); int startPos = 0; while (true) { if (string.charAt(startPos) == '"') { final int endPos = string.indexOf('"', startPos + 1); strings.add(string.substring(startPos + 1, endPos)); if (endPos + 1 == string.length()) { break; } else if (string.charAt(endPos + 1) == '.') { startPos = endPos + 2; } else { startPos = endPos + 1; } } else { final int endPos = string.indexOf('.', startPos); if (endPos == -1) { strings.add(string.substring(startPos)); break; } else { strings.add(string.substring(startPos, endPos)); startPos = endPos + 1; } } } return strings.toArray(new String[strings.size()]); } } }