Example usage for org.apache.commons.lang3 StringUtils split

List of usage examples for org.apache.commons.lang3 StringUtils split

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils split.

Prototype

public static String[] split(final String str, final String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:com.google.mr4c.config.execution.DirectoryConfig.java

private static List<String> loadList(Properties props, String name) {
    String data = props.getProperty(name);
    if (data == null) {
        throw new IllegalArgumentException("Missing " + name);
    }// w w  w .  j av a  2s.c om
    data = StringUtils.strip(data);
    if (StringUtils.isEmpty(data)) {
        return Collections.emptyList();
    }
    String[] vals = StringUtils.split(data, ", ");
    return Arrays.asList(vals);
}

From source file:de.micromata.tpsb.doc.parser.JavaDocUtil.java

/**
 * Extrahiert alle Tags aus dem JavaDoc/* ww  w .  j a v a 2 s.  co  m*/
 * 
 * @param cleanedContent bereinigter Inhalt
 * @return Tupel Tagname auf Liste von Key-Value Paaren
 */
private static Map<String, List<Pair<String, String>>> extractTags(String cleanedContent) {
    Map<String, List<Pair<String, String>>> tagMap = new HashMap<String, List<Pair<String, String>>>();
    String[] lines = StringUtils.split(cleanedContent, LINE_FEED);
    if (lines == null) {
        return tagMap;
    }
    // Tag-Bereich aus Javadoc extrahieren
    List<String> tagContent = new ArrayList<String>();
    boolean found = false;
    for (String line : lines) {
        String trimmedLine = line.trim();
        if (trimmedLine.startsWith("@") == false && found == false) {
            continue;
        }
        tagContent.add(trimmedLine);
        found = true;
    }

    for (int i = 0; i < tagContent.size();) {
        String tag = tagContent.get(i++);
        if (StringUtils.trimToNull(tag) == null) {
            continue;
        }
        // Prfen ob nchste Zeile noch zum aktuellen Tag gehrt
        for (int j = i; j < tagContent.size(); j++) {
            i = j;
            String t = tagContent.get(j);
            if (t.startsWith("@") == false && StringUtils.isNotBlank(t) == true) {
                tag += " " + t;
            } else {
                break;
            }
        }
        parseTag(tag, tagMap);
    }
    return tagMap;
}

From source file:de.micromata.genome.gwiki.plugin.rogmp3_1_0.Mp3Db.java

public Map<Integer, TimeLineEl> getComposerTimeLine(String country) {
    Map<Integer, TimeLineEl> ret = new TreeMap<Integer, TimeLineEl>();
    List<String[]> recs = composers.getUniqueSorted(Composer.NAME);
    for (String[] rec : recs) {

        Composer composer = new Composer(this, rec);
        String composerCountry = composer.get(Composer.COUNTRY);
        List<String> ccl = Arrays.asList(StringUtils.split(composerCountry, ";"));
        if (StringUtils.isNotBlank(country) == true && ccl.contains(country) == false) {
            continue;
        }/*  ww  w  .  j  av  a 2s .c  om*/
        int by = composer.getBornYear();
        int dy = composer.getDiedYear();
        TimeLineEl tl = ret.get(by);
        if (tl == null) {
            tl = new TimeLineEl(by);
            ret.put(by, tl);
        }
        tl.start.add(composer);
        tl = ret.get(dy);
        if (tl == null) {
            tl = new TimeLineEl(dy);
            ret.put(dy, tl);
        }
        tl.end.add(composer);

    }
    return ret;

}

From source file:net.minecrell.ice.launch.transformers.DeobfuscationTransformer.java

public DeobfuscationTransformer() throws Exception {
    Path path = (Path) Launch.blackboard.get("ice.deobf-srg");
    String name = path.getFileName().toString();
    boolean gzip = name.endsWith(".gz");

    ImmutableBiMap.Builder<String, String> classes = ImmutableBiMap.builder();
    ImmutableTable.Builder<String, String, String> fields = ImmutableTable.builder();
    ImmutableTable.Builder<String, String, String> methods = ImmutableTable.builder();

    try (BufferedReader reader = new BufferedReader(new InputStreamReader(
            gzip ? new GZIPInputStream(Files.newInputStream(path)) : Files.newInputStream(path),
            StandardCharsets.UTF_8))) {
        String line;// www.  j a  v a  2 s  .c o m
        while ((line = reader.readLine()) != null) {
            if ((line = line.trim()).isEmpty())
                continue;

            String[] parts = StringUtils.split(line, ' ');
            if (parts.length < 3) {
                System.out.println("Invalid line: " + line);
                continue;
            }

            MappingType type = MappingType.of(parts[0]);
            if (type == null) {
                System.out.println("Invalid mapping: " + line);
                continue;
            }

            String[] source, dest;
            switch (type) {
            case CLASS:
                classes.put(parts[1], parts[2]);
                break;
            case FIELD:
                source = getSignature(parts[1]);
                dest = getSignature(parts[2]);
                String fieldType = getFieldType(source[0], source[1]);
                fields.put(source[0], source[1] + ':' + fieldType, dest[1]);
                if (fieldType != null)
                    fields.put(source[0], source[1] + ":null", dest[1]);
                break;
            case METHOD:
                source = getSignature(parts[1]);
                dest = getSignature(parts[3]);
                methods.put(source[0], source[1] + parts[2], dest[1]);
                break;
            }
        }
    }

    this.classes = classes.build();
    this.rawFields = fields.build();
    this.rawMethods = methods.build();

    this.fields = Maps.newHashMapWithExpectedSize(rawFields.size());
    this.methods = Maps.newHashMapWithExpectedSize(rawMethods.size());
}

From source file:com.github.rvesse.airline.io.printers.TroffPrinter.java

public void print(String value) {
    if (StringUtils.isEmpty(value))
        return;/* w w w.  java2 s  .  c  om*/

    String[] lines = StringUtils.split(value, '\n');
    if (lines.length == 0)
        return;
    if (lines.length == 1) {
        // Append some text value directly
        if (newline)
            prepareLine();
        writer.print(escape(value));
    } else {
        // Append a series of lines
        for (String line : lines) {
            this.appendLine(line);
        }
    }
}

From source file:dk.dma.ais.bus.provider.TcpClientProvider.java

@Override
public synchronized void init() {
    for (String hostPort : hostsPorts) {
        String[] parts = StringUtils.split(hostPort, ':');
        hostnames.add(parts[0]);/*from ww  w. j  a v  a 2  s . co m*/
        ports.add(Integer.parseInt(parts[1]));
    }
    super.init();
}

From source file:com.mirth.connect.client.ui.Mirth.java

/**
 * Application entry point. Sets up the login panel and its layout as well.
 * /*  w  w  w.  ja v a  2 s.  co m*/
 * @param args
 *            String[]
 */
public static void main(String[] args) {
    String server = "https://localhost:8443";
    String version = "";
    String username = "";
    String password = "";
    String protocols = "";
    String cipherSuites = "";

    if (args.length > 0) {
        server = args[0];
    }
    if (args.length > 1) {
        version = args[1];
    }
    if (args.length > 2) {
        if (StringUtils.equalsIgnoreCase(args[2], "-ssl")) {
            // <server> <version> -ssl [<protocols> [<ciphersuites> [<username> [<password>]]]]
            if (args.length > 3) {
                protocols = args[3];
            }
            if (args.length > 4) {
                cipherSuites = args[4];
            }
            if (args.length > 5) {
                username = args[5];
            }
            if (args.length > 6) {
                password = args[6];
            }
        } else {
            // <server> <version> <username> [<password> [-ssl [<protocols> [<ciphersuites>]]]]
            username = args[2];
            if (args.length > 3) {
                password = args[3];
            }
            if (args.length > 4 && StringUtils.equalsIgnoreCase(args[4], "-ssl")) {
                if (args.length > 5) {
                    protocols = args[5];
                }
                if (args.length > 6) {
                    cipherSuites = args[6];
                }
            }
        }
    }

    if (StringUtils.isNotBlank(protocols)) {
        PlatformUI.HTTPS_PROTOCOLS = StringUtils.split(protocols, ',');
    }
    if (StringUtils.isNotBlank(cipherSuites)) {
        PlatformUI.HTTPS_CIPHER_SUITES = StringUtils.split(cipherSuites, ',');
    }

    start(server, version, username, password);
}

From source file:com.neatresults.mgnltweaks.ui.action.CreateAppAction.java

@Override
public void execute() throws ActionExecutionException {
    // First Validate
    validator.showValidation(true);/* ww w  . jav a2 s.c  o m*/
    if (validator.isValid()) {

        // we support only JCR item adapters
        if (!(item instanceof JcrItemAdapter)) {
            return;
        }

        // don't save if no value changes occurred on adapter
        if (!((JcrItemAdapter) item).hasChangedProperties()) {
            return;
        }

        if (item instanceof AbstractJcrNodeAdapter) {
            // Saving JCR Node, getting updated node first
            AbstractJcrNodeAdapter nodeAdapter = (AbstractJcrNodeAdapter) item;
            try {
                Node node = nodeAdapter.getJcrItem();

                Context originalCtx = MgnlContext.getInstance();
                InputStream inputStream = null;
                MgnlGroovyConsoleContext groovyCtx = null;
                try {

                    groovyCtx = new MgnlGroovyConsoleContext(originalCtx);
                    groovyCtx.put("appName", item.getItemProperty("appName").getValue());
                    String[] pathArray = StringUtils.split(node.getPath(), "/");
                    if (pathArray.length < 2) {
                        throw new ActionExecutionException(
                                "Can't create app on selected path: " + node.getPath());
                    }
                    groovyCtx.put("appLocation", pathArray[1]);

                    groovyCtx.put("appGroup", item.getItemProperty("appGroup").getValue());
                    groovyCtx.put("appIcon", StringUtils
                            .defaultIfBlank((String) item.getItemProperty("appIcon").getValue(), "icon-items"));
                    groovyCtx.put("appRepository", StringUtils.defaultIfBlank(
                            (String) item.getItemProperty("appRepository").getValue(), "magnolia"));
                    groovyCtx.put("appFolderSupport", item.getItemProperty("appFolderSupport").getValue());

                    MgnlContext.setInstance(groovyCtx);
                    MgnlGroovyConsole console = new MgnlGroovyConsole(new Binding());

                    String inputFile = "/neat-tweaks-developers/appCreationScript.groovy";
                    // First Check
                    URL inFile = ClasspathResourcesUtil.getResource(inputFile);
                    if (inFile == null) {
                        throw new ActionExecutionException("Can't find resource file at " + inputFile);
                    }
                    // Get Input Stream
                    inputStream = ClasspathResourcesUtil.getResource(inputFile).openStream();
                    if (inputStream == null) {
                        throw new ActionExecutionException("Can't find resource file at " + inFile.getFile());
                    }

                    Writer writer = new StringWriter();

                    Object result = console.evaluate(inputStream, console.generateScriptName(), writer);

                    StringBuilder sb = new StringBuilder().append(writer.toString()).append("\n")
                            .append(result);
                    uiContext.openNotification(MessageStyleTypeEnum.INFO, true, sb.toString());

                } finally {
                    // close jcr sessions
                    groovyCtx.release();
                    // close files
                    IOUtils.closeQuietly(inputStream);
                    // restore context
                    MgnlContext.setInstance(originalCtx);
                }
            } catch (RepositoryException | IOException e) {
                log.error("Could not save changes to node", e);
            }
            callback.onSuccess(getDefinition().getName());
        } else if (item instanceof JcrPropertyAdapter) {
            super.execute();
        }
    } else {
        log.debug("Validation error(s) occurred. No save performed.");
    }
}

From source file:org.meruvian.yama.core.application.Application.java

@Transient
public Set<String> getAuthorizedGrantTypes() {
    String[] authorizedGrantTypes = StringUtils.split(this.authorizedGrantTypes, ',');
    if (authorizedGrantTypes == null)
        return new LinkedHashSet<String>();

    return new LinkedHashSet<String>(Arrays.asList(authorizedGrantTypes));
}

From source file:com.adguard.android.db.DbHelper.java

private void executeSql(SQLiteDatabase db, String script) {
    for (String sql : StringUtils.split(script, ";")) {
        if (!StringUtils.isWhitespace(sql)) {
            LOG.info("Execute sql: {}", sql);
            db.execSQL(sql);//from  w  w  w  .  ja v  a2 s.  co m
        }
    }
}