Java Args Parse getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)

Here you can find the source of getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)

Description

get Possible Completions For Given Args

License

Open Source License

Declaration

public static List<String> getPossibleCompletionsForGivenArgs(String[] args,
            String[] possibilitiesOfCompletion) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {
    public static List<String> getPossibleCompletionsForGivenArgs(String[] args,
            String[] possibilitiesOfCompletion) {
        final String argumentToFindCompletionFor = args[args.length - 1];

        final List<String> listOfPossibleCompletions = new ArrayList<String>();
        for (int i = 0; i < possibilitiesOfCompletion.length; i++) {
            final String[] foundString = possibilitiesOfCompletion;
            try {
                if (foundString[i] != null && foundString[i].regionMatches(true, 0, argumentToFindCompletionFor, 0,
                        argumentToFindCompletionFor.length())) {
                    listOfPossibleCompletions.add(foundString[i]);
                }/*from   www.j a  v  a 2  s .co m*/
            } catch (final Exception e) {
                e.printStackTrace();
            }
        }
        Collections.sort(listOfPossibleCompletions);

        return listOfPossibleCompletions;
    }
}

Related

  1. getPossibleCompletionsForGivenArgs(String[] args, String[] possibilitiesOfCompletion)
  2. parse(String[] args)
  3. parse(String[] args)
  4. parseAndFillFittingValues(String[] prefixes, String[] values)