Example usage for java.util StringTokenizer hasMoreTokens

List of usage examples for java.util StringTokenizer hasMoreTokens

Introduction

In this page you can find the example usage for java.util StringTokenizer hasMoreTokens.

Prototype

public boolean hasMoreTokens() 

Source Link

Document

Tests if there are more tokens available from this tokenizer's string.

Usage

From source file:de.petendi.ethereum.secure.proxy.Application.java

public static void main(String[] args) {

    try {// w w w  .ja  va 2s  . c  om
        cmdLineResult = new CmdLineResult();
        cmdLineResult.parseArguments(args);
    } catch (CmdLineException e) {
        System.out.println(e.getMessage());
        System.out.println("Usage:");
        cmdLineResult.printExample();
        System.exit(-1);
        return;
    }

    File workingDirectory = new File(System.getProperty("user.home"));
    if (cmdLineResult.getWorkingDirectory().length() > 0) {
        workingDirectory = new File(cmdLineResult.getWorkingDirectory()).getAbsoluteFile();
    }

    ArgumentList argumentList = new ArgumentList();
    argumentList.setWorkingDirectory(workingDirectory);
    File certificate = new File(workingDirectory, "seccoco-secured/cert.p12");
    if (certificate.exists()) {
        char[] passwd = null;
        if (cmdLineResult.getPassword() != null) {
            System.out.println("Using password from commandline argument - DON'T DO THIS IN PRODUCTION !!");
            passwd = cmdLineResult.getPassword().toCharArray();
        } else {
            Console console = System.console();
            if (console != null) {
                passwd = console.readPassword("[%s]", "Enter application password:");
            } else {
                System.out.print("No suitable console found for entering password");
                System.exit(-1);
            }
        }
        argumentList.setTokenPassword(passwd);
    }
    try {
        SeccocoFactory seccocoFactory = new SeccocoFactory("seccoco-secured", argumentList);
        seccoco = seccocoFactory.create();
    } catch (InitializationException e) {
        System.out.println(e.getMessage());
        System.exit(-1);
    }
    try {
        System.out.println("Connecting to Ethereum RPC at " + cmdLineResult.getUrl());
        URL url = new URL(cmdLineResult.getUrl());
        HashMap<String, String> headers = new HashMap<String, String>();
        headers.put("Content-Type", "application/json");
        String additionalHeaders = cmdLineResult.getAdditionalHeaders();
        if (additionalHeaders != null) {
            StringTokenizer tokenizer = new StringTokenizer(additionalHeaders, ",");
            while (tokenizer.hasMoreTokens()) {
                String keyValue = tokenizer.nextToken();
                StringTokenizer innerTokenizer = new StringTokenizer(keyValue, ":");
                headers.put(innerTokenizer.nextToken(), innerTokenizer.nextToken());
            }
        }
        settings = new Settings(cmdLineResult.isExposeWhisper(), headers);
        jsonRpcHttpClient = new JsonRpcHttpClient(url);
        jsonRpcHttpClient.setRequestListener(new JsonRpcRequestListener());

        jsonRpcHttpClient.invoke("eth_protocolVersion", null, Object.class, headers);
        if (cmdLineResult.isExposeWhisper()) {
            jsonRpcHttpClient.invoke("shh_version", null, Object.class, headers);
        }
        System.out.println("Connection succeeded");
    } catch (Throwable e) {
        System.out.println("Connection failed: " + e.getMessage());
        System.exit(-1);
    }
    SpringApplication app = new SpringApplication(Application.class);
    app.setBanner(new Banner() {
        @Override
        public void printBanner(Environment environment, Class<?> aClass, PrintStream printStream) {
            //send the Spring Boot banner to /dev/null
        }
    });
    app.run(new String[] {});
}

From source file:com.glaf.jbpm.action.MultiPooledTaskInstanceAction.java

public static void main(String[] args) throws Exception {
    String actorIdxy = "{joy,sam},{pp,qq},{kit,cora},{eyb2000,huangcw}";
    StringTokenizer st2 = new StringTokenizer(actorIdxy, ";");
    while (st2.hasMoreTokens()) {
        String elem2 = st2.nextToken();
        if (StringUtils.isNotEmpty(elem2)) {
            elem2 = elem2.trim();//  w  w  w  .j av a2s.  co  m
            if ((elem2.length() > 0 && elem2.charAt(0) == '{') && elem2.endsWith("}")) {
                elem2 = elem2.substring(elem2.indexOf("{") + 1, elem2.indexOf("}"));
                Set<String> actorIds = new HashSet<String>();
                StringTokenizer st4 = new StringTokenizer(elem2, ",");
                while (st4.hasMoreTokens()) {
                    String elem4 = st4.nextToken();
                    elem4 = elem4.trim();
                    if (elem4.length() > 0) {
                        actorIds.add(elem4);
                    }
                }
                System.out.println(actorIds);
            }
        }
    }
}

From source file:ISMAGS.CommandLineInterface.java

public static void main(String[] args) throws IOException {
    String folder = null, files = null, motifspec = null, output = null;

    Options opts = new Options();
    opts.addOption("folder", true, "Folder name");
    opts.addOption("linkfiles", true,
            "Link files seperated by spaces (format: linktype[char] directed[d/u] filename)");
    opts.addOption("motif", true, "Motif description by two strings (format: linktypes)");
    opts.addOption("output", true, "Output file name");

    CommandLineParser parser = new PosixParser();
    try {/*ww w  .  j av a2  s  .  c  o  m*/
        CommandLine cmd = parser.parse(opts, args);
        if (cmd.hasOption("folder")) {
            folder = cmd.getOptionValue("folder");
        }
        if (cmd.hasOption("linkfiles")) {
            files = cmd.getOptionValue("linkfiles");
        }
        if (cmd.hasOption("motif")) {
            motifspec = cmd.getOptionValue("motif");
        }
        if (cmd.hasOption("output")) {
            output = cmd.getOptionValue("output");
        }
    } catch (ParseException e) {
        Die("Error: Parsing error");
    }

    if (print) {
        printBanner(folder, files, motifspec, output);
    }

    if (folder == null || files == null || motifspec == null || output == null) {
        Die("Error: not all options are provided");
    } else {
        ArrayList<String> linkfiles = new ArrayList<String>();
        ArrayList<String> linkTypes = new ArrayList<String>();
        ArrayList<String> sourcenetworks = new ArrayList<String>();
        ArrayList<String> destinationnetworks = new ArrayList<String>();
        ArrayList<Boolean> directed = new ArrayList<Boolean>();
        StringTokenizer st = new StringTokenizer(files, " ");
        while (st.hasMoreTokens()) {
            linkTypes.add(st.nextToken());
            directed.add(st.nextToken().equals("d"));
            sourcenetworks.add(st.nextToken());
            destinationnetworks.add(st.nextToken());
            linkfiles.add(folder + st.nextToken());
        }
        ArrayList<LinkType> allLinkTypes = new ArrayList<LinkType>();
        HashMap<Character, LinkType> typeTranslation = new HashMap<Character, LinkType>();
        for (int i = 0; i < linkTypes.size(); i++) {
            String n = linkTypes.get(i);
            char nn = n.charAt(0);
            LinkType t = typeTranslation.get(nn);
            if (t == null) {
                t = new LinkType(directed.get(i), n, i, nn, sourcenetworks.get(i), destinationnetworks.get(i));
            }
            allLinkTypes.add(t);
            typeTranslation.put(nn, t);
        }
        if (print) {
            System.out.println("Reading network..");
        }
        Network network = Network.readNetworkFromFiles(linkfiles, allLinkTypes);

        Motif motif = getMotif(motifspec, typeTranslation);

        if (print) {
            System.out.println("Starting the search..");
        }
        MotifFinder mf = new MotifFinder(network);
        long tijd = System.nanoTime();
        Set<MotifInstance> motifs = mf.findMotif(motif, false);
        tijd = System.nanoTime() - tijd;
        if (print) {
            System.out.println("Completed search in " + tijd / 1000000 + " milliseconds");
        }
        if (print) {
            System.out.println("Found " + motifs.size() + " instances of " + motifspec + " motif");
        }
        if (print) {
            System.out.println("Writing instances to file: " + output);
        }
        printMotifs(motifs, output);
        if (print) {
            System.out.println("Done.");
        }
        //            Set<MotifInstance> motifs=null;
        //            MotifFinder mf=null;
        //            System.out.println("Starting the search..");
        //            long tstart = System.nanoTime();
        //            for (int i = 0; i < it; i++) {
        //
        //                mf = new MotifFinder(network, allLinkTypes, true);
        //                motifs = mf.findMotif(motif);
        //            }
        //
        //            long tend = System.nanoTime();
        //            double time_in_ms = (tend - tstart) / 1000000.0;
        //            System.out.println("Found " + mf.totalFound + " motifs, " + time_in_ms + " ms");
        ////        System.out.println("Evaluated " + mf.totalNrMappedNodes+ " search nodes");
        ////        System.out.println("Found " + motifs.size() + " motifs, " + time_in_ms + " ms");
        //            printMotifs(motifs, output);

    }

}

From source file:com.cloud.test.utils.SubmitCert.java

public static void main(String[] args) {
    // Parameters
    List<String> argsList = Arrays.asList(args);
    Iterator<String> iter = argsList.iterator();
    while (iter.hasNext()) {
        String arg = iter.next();

        if (arg.equals("-c")) {
            certFileName = iter.next();/*from  www .ja  v a  2s  . co  m*/
        }

        if (arg.equals("-s")) {
            secretKey = iter.next();
        }

        if (arg.equals("-a")) {
            apiKey = iter.next();
        }

        if (arg.equals("-action")) {
            url = "Action=" + iter.next();
        }
    }

    Properties prop = new Properties();
    try {
        prop.load(new FileInputStream("conf/tool.properties"));
    } catch (IOException ex) {
        s_logger.error("Error reading from conf/tool.properties", ex);
        System.exit(2);
    }

    host = prop.getProperty("host");
    port = prop.getProperty("port");

    if (url.equals("Action=SetCertificate") && certFileName == null) {
        s_logger.error("Please set path to certificate (including file name) with -c option");
        System.exit(1);
    }

    if (secretKey == null) {
        s_logger.error("Please set secretkey  with -s option");
        System.exit(1);
    }

    if (apiKey == null) {
        s_logger.error("Please set apikey with -a option");
        System.exit(1);
    }

    if (host == null) {
        s_logger.error("Please set host in tool.properties file");
        System.exit(1);
    }

    if (port == null) {
        s_logger.error("Please set port in tool.properties file");
        System.exit(1);
    }

    TreeMap<String, String> param = new TreeMap<String, String>();

    String req = "GET\n" + host + ":" + prop.getProperty("port") + "\n/" + prop.getProperty("accesspoint")
            + "\n";
    String temp = "";

    if (certFileName != null) {
        cert = readCert(certFileName);
        param.put("cert", cert);
    }

    param.put("AWSAccessKeyId", apiKey);
    param.put("Expires", prop.getProperty("expires"));
    param.put("SignatureMethod", prop.getProperty("signaturemethod"));
    param.put("SignatureVersion", "2");
    param.put("Version", prop.getProperty("version"));

    StringTokenizer str1 = new StringTokenizer(url, "&");
    while (str1.hasMoreTokens()) {
        String newEl = str1.nextToken();
        StringTokenizer str2 = new StringTokenizer(newEl, "=");
        String name = str2.nextToken();
        String value = str2.nextToken();
        param.put(name, value);
    }

    //sort url hash map by key
    Set c = param.entrySet();
    Iterator it = c.iterator();
    while (it.hasNext()) {
        Map.Entry me = (Map.Entry) it.next();
        String key = (String) me.getKey();
        String value = (String) me.getValue();
        try {
            temp = temp + key + "=" + URLEncoder.encode(value, "UTF-8") + "&";
        } catch (Exception ex) {
            s_logger.error("Unable to set parameter " + value + " for the command " + param.get("command"), ex);
        }

    }
    temp = temp.substring(0, temp.length() - 1);
    String requestToSign = req + temp;
    String signature = UtilsForTest.signRequest(requestToSign, secretKey);
    String encodedSignature = "";
    try {
        encodedSignature = URLEncoder.encode(signature, "UTF-8");
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    String url = "http://" + host + ":" + prop.getProperty("port") + "/" + prop.getProperty("accesspoint") + "?"
            + temp + "&Signature=" + encodedSignature;
    s_logger.info("Sending request with url:  " + url + "\n");
    sendRequest(url);
}

From source file:com.ibm.crail.storage.StorageServer.java

public static void main(String[] args) throws Exception {
    Logger LOG = CrailUtils.getLogger();
    CrailConfiguration conf = new CrailConfiguration();
    CrailConstants.updateConstants(conf);
    CrailConstants.printConf();/*  w ww  .ja  v  a  2  s.  co m*/
    CrailConstants.verify();

    int splitIndex = 0;
    for (String param : args) {
        if (param.equalsIgnoreCase("--")) {
            break;
        }
        splitIndex++;
    }

    //default values
    StringTokenizer tokenizer = new StringTokenizer(CrailConstants.STORAGE_TYPES, ",");
    if (!tokenizer.hasMoreTokens()) {
        throw new Exception("No storage types defined!");
    }
    String storageName = tokenizer.nextToken();
    int storageType = 0;
    HashMap<String, Integer> storageTypes = new HashMap<String, Integer>();
    storageTypes.put(storageName, storageType);
    for (int type = 1; tokenizer.hasMoreElements(); type++) {
        String name = tokenizer.nextToken();
        storageTypes.put(name, type);
    }
    int storageClass = -1;

    //custom values
    if (args != null) {
        Option typeOption = Option.builder("t").desc("storage type to start").hasArg().build();
        Option classOption = Option.builder("c").desc("storage class the server will attach to").hasArg()
                .build();
        Options options = new Options();
        options.addOption(typeOption);
        options.addOption(classOption);
        CommandLineParser parser = new DefaultParser();

        try {
            CommandLine line = parser.parse(options, Arrays.copyOfRange(args, 0, splitIndex));
            if (line.hasOption(typeOption.getOpt())) {
                storageName = line.getOptionValue(typeOption.getOpt());
                storageType = storageTypes.get(storageName).intValue();
            }
            if (line.hasOption(classOption.getOpt())) {
                storageClass = Integer.parseInt(line.getOptionValue(classOption.getOpt()));
            }
        } catch (ParseException e) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Storage tier", options);
            System.exit(-1);
        }
    }
    if (storageClass < 0) {
        storageClass = storageType;
    }

    StorageTier storageTier = StorageTier.createInstance(storageName);
    if (storageTier == null) {
        throw new Exception("Cannot instantiate datanode of type " + storageName);
    }

    String extraParams[] = null;
    splitIndex++;
    if (args.length > splitIndex) {
        extraParams = new String[args.length - splitIndex];
        for (int i = splitIndex; i < args.length; i++) {
            extraParams[i - splitIndex] = args[i];
        }
    }
    storageTier.init(conf, extraParams);
    storageTier.printConf(LOG);

    RpcClient rpcClient = RpcClient.createInstance(CrailConstants.NAMENODE_RPC_TYPE);
    rpcClient.init(conf, args);
    rpcClient.printConf(LOG);

    ConcurrentLinkedQueue<InetSocketAddress> namenodeList = CrailUtils.getNameNodeList();
    ConcurrentLinkedQueue<RpcConnection> connectionList = new ConcurrentLinkedQueue<RpcConnection>();
    while (!namenodeList.isEmpty()) {
        InetSocketAddress address = namenodeList.poll();
        RpcConnection connection = rpcClient.connect(address);
        connectionList.add(connection);
    }
    RpcConnection rpcConnection = connectionList.peek();
    if (connectionList.size() > 1) {
        rpcConnection = new RpcDispatcher(connectionList);
    }
    LOG.info("connected to namenode(s) " + rpcConnection.toString());

    StorageServer server = storageTier.launchServer();
    StorageRpcClient storageRpc = new StorageRpcClient(storageType, CrailStorageClass.get(storageClass),
            server.getAddress(), rpcConnection);

    HashMap<Long, Long> blockCount = new HashMap<Long, Long>();
    long sumCount = 0;
    while (server.isAlive()) {
        StorageResource resource = server.allocateResource();
        if (resource == null) {
            break;
        } else {
            storageRpc.setBlock(resource.getAddress(), resource.getLength(), resource.getKey());
            DataNodeStatistics stats = storageRpc.getDataNode();
            long newCount = stats.getFreeBlockCount();
            long serviceId = stats.getServiceId();

            long oldCount = 0;
            if (blockCount.containsKey(serviceId)) {
                oldCount = blockCount.get(serviceId);
            }
            long diffCount = newCount - oldCount;
            blockCount.put(serviceId, newCount);
            sumCount += diffCount;
            LOG.info("datanode statistics, freeBlocks " + sumCount);
        }
    }

    while (server.isAlive()) {
        DataNodeStatistics stats = storageRpc.getDataNode();
        long newCount = stats.getFreeBlockCount();
        long serviceId = stats.getServiceId();

        long oldCount = 0;
        if (blockCount.containsKey(serviceId)) {
            oldCount = blockCount.get(serviceId);
        }
        long diffCount = newCount - oldCount;
        blockCount.put(serviceId, newCount);
        sumCount += diffCount;

        LOG.info("datanode statistics, freeBlocks " + sumCount);
        Thread.sleep(2000);
    }
}

From source file:com.cloud.sample.UserCloudAPIExecutor.java

public static void main(String[] args) {
    // Host/* ww  w. j a  va  2  s .c  om*/
    String host = null;

    // Fully qualified URL with http(s)://host:port
    String apiUrl = null;

    // ApiKey and secretKey as given by your CloudStack vendor
    String apiKey = null;
    String secretKey = null;

    try {
        Properties prop = new Properties();
        prop.load(new FileInputStream("usercloud.properties"));

        // host
        host = prop.getProperty("host");
        if (host == null) {
            System.out.println(
                    "Please specify a valid host in the format of http(s)://:/client/api in your usercloud.properties file.");
        }

        // apiUrl
        apiUrl = prop.getProperty("apiUrl");
        if (apiUrl == null) {
            System.out.println(
                    "Please specify a valid API URL in the format of command=&param1=&param2=... in your usercloud.properties file.");
        }

        // apiKey
        apiKey = prop.getProperty("apiKey");
        if (apiKey == null) {
            System.out.println(
                    "Please specify your API Key as provided by your CloudStack vendor in your usercloud.properties file.");
        }

        // secretKey
        secretKey = prop.getProperty("secretKey");
        if (secretKey == null) {
            System.out.println(
                    "Please specify your secret Key as provided by your CloudStack vendor in your usercloud.properties file.");
        }

        if (apiUrl == null || apiKey == null || secretKey == null) {
            return;
        }

        System.out.println("Constructing API call to host = '" + host + "' with API command = '" + apiUrl
                + "' using apiKey = '" + apiKey + "' and secretKey = '" + secretKey + "'");

        // Step 1: Make sure your APIKey is URL encoded
        String encodedApiKey = URLEncoder.encode(apiKey, "UTF-8");

        // Step 2: URL encode each parameter value, then sort the parameters and apiKey in
        // alphabetical order, and then toLowerCase all the parameters, parameter values and apiKey.
        // Please note that if any parameters with a '&' as a value will cause this test client to fail since we are using
        // '&' to delimit
        // the string
        List<String> sortedParams = new ArrayList<String>();
        sortedParams.add("apikey=" + encodedApiKey.toLowerCase());
        StringTokenizer st = new StringTokenizer(apiUrl, "&");
        String url = null;
        boolean first = true;
        while (st.hasMoreTokens()) {
            String paramValue = st.nextToken();
            String param = paramValue.substring(0, paramValue.indexOf("="));
            String value = URLEncoder
                    .encode(paramValue.substring(paramValue.indexOf("=") + 1, paramValue.length()), "UTF-8");
            if (first) {
                url = param + "=" + value;
                first = false;
            } else {
                url = url + "&" + param + "=" + value;
            }
            sortedParams.add(param.toLowerCase() + "=" + value.toLowerCase());
        }
        Collections.sort(sortedParams);

        System.out.println("Sorted Parameters: " + sortedParams);

        // Step 3: Construct the sorted URL and sign and URL encode the sorted URL with your secret key
        String sortedUrl = null;
        first = true;
        for (String param : sortedParams) {
            if (first) {
                sortedUrl = param;
                first = false;
            } else {
                sortedUrl = sortedUrl + "&" + param;
            }
        }
        System.out.println("sorted URL : " + sortedUrl);
        String encodedSignature = signRequest(sortedUrl, secretKey);

        // Step 4: Construct the final URL we want to send to the CloudStack Management Server
        // Final result should look like:
        // http(s)://://client/api?&apiKey=&signature=
        String finalUrl = host + "?" + url + "&apiKey=" + apiKey + "&signature=" + encodedSignature;
        System.out.println("final URL : " + finalUrl);

        // Step 5: Perform a HTTP GET on this URL to execute the command
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod(finalUrl);
        int responseCode = client.executeMethod(method);
        if (responseCode == 200) {
            // SUCCESS!
            System.out.println("Successfully executed command");
        } else {
            // FAILED!
            System.out.println("Unable to execute command with response code: " + responseCode);
        }

    } catch (Throwable t) {
        System.out.println(t);
    }
}

From source file:hepple.postag.POSTagger.java

/**
 * Main method. Runs the tagger using the arguments to find the resources
 * to be used for initialisation and the input file.
 *//* w  ww .  j ava2 s . c  o m*/
public static void main(String[] args) {
    if (args.length == 0)
        help();
    try {
        LongOpt[] options = new LongOpt[] { new LongOpt("help", LongOpt.NO_ARGUMENT, null, 'h'),
                new LongOpt("lexicon", LongOpt.NO_ARGUMENT, null, 'l'),
                new LongOpt("rules", LongOpt.NO_ARGUMENT, null, 'r') };
        Getopt getopt = new Getopt("HepTag", args, "hl:r:", options);
        String lexiconUrlString = null;
        String rulesUrlString = null;
        int opt;
        while ((opt = getopt.getopt()) != -1) {
            switch (opt) {
            // -h
            case 'h': {
                help();
                System.exit(0);
                break;
            }
            // -l new lexicon
            case 'l': {
                lexiconUrlString = getopt.getOptarg();
                break;
            }
            // -l new lexicon
            case 'r': {
                rulesUrlString = getopt.getOptarg();
                break;
            }
            default: {
                System.err.println("Invalid option " + args[getopt.getOptind() - 1] + "!");
                System.exit(1);
            }
            }//switch(opt)
        } //while( (opt = g.getopt()) != -1 )
        String[] fileNames = new String[args.length - getopt.getOptind()];
        for (int i = getopt.getOptind(); i < args.length; i++) {
            fileNames[i - getopt.getOptind()] = args[i];
        }

        URL lexiconURL = (lexiconUrlString == null)
                ? POSTagger.class.getResource("/hepple/resources/sample_lexicon")
                : new File(lexiconUrlString).toURI().toURL();

        URL rulesURL = (rulesUrlString == null)
                ? POSTagger.class.getResource("/hepple/resources/sample_ruleset.big")
                : new File(rulesUrlString).toURI().toURL();

        POSTagger tagger = new POSTagger(lexiconURL, rulesURL);

        for (int i = 0; i < fileNames.length; i++) {
            String file = fileNames[i];
            BufferedReader reader = null;

            try {
                reader = new BufferedReader(new FileReader(file));

                String line = reader.readLine();

                while (line != null) {
                    StringTokenizer tokens = new StringTokenizer(line);
                    List<String> sentence = new ArrayList<String>();
                    while (tokens.hasMoreTokens())
                        sentence.add(tokens.nextToken());
                    List<List<String>> sentences = new ArrayList<List<String>>();
                    sentences.add(sentence);
                    List<List<String[]>> result = tagger.runTagger(sentences);

                    Iterator<List<String[]>> iter = result.iterator();
                    while (iter.hasNext()) {
                        List<String[]> sentenceFromTagger = iter.next();
                        Iterator<String[]> sentIter = sentenceFromTagger.iterator();
                        while (sentIter.hasNext()) {
                            String[] tag = sentIter.next();
                            System.out.print(tag[0] + "/" + tag[1]);
                            if (sentIter.hasNext())
                                System.out.print(" ");
                            else
                                System.out.println();
                        } //while(sentIter.hasNext())
                    } //while(iter.hasNext())
                    line = reader.readLine();
                } //while(line != null)
            } finally {
                IOUtils.closeQuietly(reader);
            }
            //
            //
            //
            //        List result = tagger.runTagger(readInput(file));
            //        Iterator iter = result.iterator();
            //        while(iter.hasNext()){
            //          List sentence = (List)iter.next();
            //          Iterator sentIter = sentence.iterator();
            //          while(sentIter.hasNext()){
            //            String[] tag = (String[])sentIter.next();
            //            System.out.print(tag[0] + "/" + tag[1]);
            //            if(sentIter.hasNext()) System.out.print(" ");
            //            else System.out.println();
            //          }//while(sentIter.hasNext())
            //        }//while(iter.hasNext())
        } //for(int i = 0; i < fileNames.length; i++)
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:IndexService.Indexer.java

public static void main(String[] args) throws IOException {
    System.out.println("input cmd:   indexdir  idx  type  startvalue  endvalue");
    String str = new BufferedReader(new InputStreamReader(System.in)).readLine();
    StringTokenizer st = new StringTokenizer(str);
    String indexdir = st.nextToken();
    int idx = Integer.parseInt(st.nextToken());
    String type = st.nextToken();
    String startvalue = st.nextToken();
    String endvalue = null;//from w  w w  . ja  v  a  2s  .co  m
    if (st.hasMoreTokens())
        endvalue = st.nextToken();
    else
        endvalue = startvalue;
    ArrayList<IRecord.IFValue> values = new ArrayList<IRecord.IFValue>();
    if (type.equalsIgnoreCase("byte"))
        values.add(new IRecord.IFValue(Byte.parseByte(startvalue), idx));
    if (type.equalsIgnoreCase("short"))
        values.add(new IRecord.IFValue(Short.parseShort(startvalue), idx));
    if (type.equalsIgnoreCase("int"))
        values.add(new IRecord.IFValue(Integer.parseInt(startvalue), idx));
    if (type.equalsIgnoreCase("long"))
        values.add(new IRecord.IFValue(Long.parseLong(startvalue), idx));
    if (type.equalsIgnoreCase("float"))
        values.add(new IRecord.IFValue(Float.parseFloat(startvalue), idx));
    if (type.equalsIgnoreCase("double"))
        values.add(new IRecord.IFValue(Double.parseDouble(startvalue), idx));
    if (type.equalsIgnoreCase("string"))
        values.add(new IRecord.IFValue(startvalue, idx));
    ArrayList<IRecord.IFValue> values1 = new ArrayList<IRecord.IFValue>();
    if (type.equalsIgnoreCase("byte"))
        values1.add(new IRecord.IFValue(Byte.parseByte(endvalue), idx));
    if (type.equalsIgnoreCase("short"))
        values1.add(new IRecord.IFValue(Short.parseShort(endvalue), idx));
    if (type.equalsIgnoreCase("int"))
        values1.add(new IRecord.IFValue(Integer.parseInt(endvalue), idx));
    if (type.equalsIgnoreCase("long"))
        values1.add(new IRecord.IFValue(Long.parseLong(endvalue), idx));
    if (type.equalsIgnoreCase("float"))
        values1.add(new IRecord.IFValue(Float.parseFloat(endvalue), idx));
    if (type.equalsIgnoreCase("double"))
        values1.add(new IRecord.IFValue(Double.parseDouble(endvalue), idx));
    if (type.equalsIgnoreCase("string"))
        values1.add(new IRecord.IFValue(endvalue, idx));
    Indexer indexer = new Indexer();
    List<IRecord> recs = indexer.getRange(indexdir, null, values, values1, 100, null, -1);
    for (IRecord rec : recs) {
        rec.show();
    }

}

From source file:com.sun.faces.generate.HtmlComponentGenerator.java

public static void main(String args[]) throws Exception {

    try {//from   ww  w  . ja  v  a  2 s  . com

        // Perform setup operations
        if (log.isDebugEnabled()) {
            log.debug("Processing command line options");
        }
        Map options = options(args);
        String dtd = (String) options.get("--dtd");
        if (log.isDebugEnabled()) {
            log.debug("Configuring digester instance with public identifiers and DTD '" + dtd + "'");
        }
        StringTokenizer st = new StringTokenizer(dtd, "|");
        int arrayLen = st.countTokens();
        if (arrayLen == 0) {
            // PENDING I18n
            throw new Exception("No DTDs specified");
        }
        String[] dtds = new String[arrayLen];
        int i = 0;
        while (st.hasMoreTokens()) {
            dtds[i] = st.nextToken();
            i++;
        }

        copyright((String) options.get("--copyright"));
        directories((String) options.get("--dir"));
        Digester digester = digester(dtds, false, true, false);
        String config = (String) options.get("--config");
        if (log.isDebugEnabled()) {
            log.debug("Parsing configuration file '" + config + "'");
        }
        digester.push(new FacesConfigBean());
        fcb = parse(digester, config);
        if (log.isInfoEnabled()) {
            log.info("Generating HTML component classes");
        }

        // Generate concrete HTML component classes
        ComponentBean cbs[] = fcb.getComponents();
        for (i = 0; i < cbs.length; i++) {
            String componentClass = cbs[i].getComponentClass();
            if (componentClass.startsWith("javax.faces.component.html.")) {
                cb = cbs[i];
                generate();
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
    }
    System.exit(0);

}

From source file:gov.nih.nci.caintegrator.application.gpvisualizer.CaIntegratorRunVisualizer.java

/**
 * args[0] = visualizer task name args[1] = command line args[2] = debug
 * flag args[3] = OS required for running args[4] = CPU type required for
 * running args[5] = libdir on server for this task args[6] = CSV list of
 * downloadable files for inputs args[7] = CSV list of input parameter names
 * args[8] = CSV list of support file names args[9] = CSV list of support
 * file modification dates args[10] = server URL args[11] = LSID of task
 * args[12...n] = optional input parameter arguments
 *///from w  ww  . j a  v  a2 s  .  c o  m
public static void main(String[] args) {
    String[] wellKnownNames = { RunVisualizerConstants.NAME, RunVisualizerConstants.COMMAND_LINE,
            RunVisualizerConstants.DEBUG, RunVisualizerConstants.OS, RunVisualizerConstants.CPU_TYPE,
            RunVisualizerConstants.LIBDIR, RunVisualizerConstants.DOWNLOAD_FILES, RunVisualizerConstants.LSID };
    int PARAM_NAMES = 7;
    int SUPPORT_FILE_NAMES = PARAM_NAMES + 1;
    int SUPPORT_FILE_DATES = SUPPORT_FILE_NAMES + 1;
    int SERVER = SUPPORT_FILE_DATES + 1;
    int LSID = SERVER + 1;
    int TASK_ARGS = LSID + 1;

    try {
        HashMap params = new HashMap();
        for (int i = 0; i < wellKnownNames.length; i++) {
            params.put(wellKnownNames[i], args[i]);
        }

        String name = (String) params.get(RunVisualizerConstants.NAME);
        StringTokenizer stParameterNames = new StringTokenizer(args[PARAM_NAMES], ", ");
        int argNum = TASK_ARGS;
        // when pulling parameters from the command line, don't assume that
        // all were provided.
        // some could be missing!
        while (stParameterNames.hasMoreTokens()) {
            String paramName = stParameterNames.nextToken();
            if (argNum < args.length) {
                String paramValue = args[argNum++];
                params.put(paramName, paramValue);
            } else {
                System.err.println("No value specified for " + paramName);
            }
        }
        URL source = new URL(args[SERVER]);

        StringTokenizer stFileNames = new StringTokenizer(args[SUPPORT_FILE_NAMES], ",");
        StringTokenizer stFileDates = new StringTokenizer(args[SUPPORT_FILE_DATES], ",");
        String[] supportFileNames = new String[stFileNames.countTokens()];
        long[] supportFileDates = new long[supportFileNames.length];
        String filename = null;
        String fileDate = null;
        int f = 0;
        while (stFileNames.hasMoreTokens()) {
            supportFileNames[f] = stFileNames.nextToken();
            if (stFileDates.hasMoreTokens()) {
                supportFileDates[f] = Long.parseLong(stFileDates.nextToken());
            } else {
                supportFileDates[f] = -1;
            }
            f++;
        }

        CaIntegratorRunVisualizer visualizer = new CaIntegratorRunVisualizer(params, supportFileNames,
                supportFileDates, new Applet());
        visualizer.run();
    } catch (Throwable t) {
        t.printStackTrace();
    }
}