Example usage for java.lang String toLowerCase

List of usage examples for java.lang String toLowerCase

Introduction

In this page you can find the example usage for java.lang String toLowerCase.

Prototype

public String toLowerCase() 

Source Link

Document

Converts all of the characters in this String to lower case using the rules of the default locale.

Usage

From source file:com.smartmarmot.dbforbix.DBforBix.java

public static void main(final String[] args) {

    Config config = Config.getInstance();
    String action = "";

    options = new Options();
    options.addOption("v", false, "display version and exit");
    options.addOption("t", false, "test configuration");
    options.addOption("h", false, "display help");

    options.addOption("b", true, "base directory");
    options.addOption("c", true, "config file location");

    //      options.addOption("d", false, "enable debugging");
    options.addOption("C", false, "enable console output");

    options.addOption("a", true, "action (start/stop/status)");

    // handle command line parameters
    try {//w  ww.  j av a 2s.co m
        CommandLineParser cmdparser = new DefaultParser();
        CommandLine cmd = cmdparser.parse(options, args);

        if (cmd.hasOption("v")) {
            System.out.println(Constants.BANNER);
            System.exit(0);
        }

        if (cmd.hasOption("t")) {
            System.out.println("not implemented");
            System.exit(0);
        }

        if (args.length == 0 || cmd.hasOption("h")) {
            displayUsage();
            System.exit(0);
        }

        //         if (cmd.hasOption("d")) {
        //            debug = true;
        //            Logger.getRootLogger().setLevel(Level.ALL);
        //         }

        if (cmd.hasOption("C"))
            Logger.getRootLogger().addAppender(new ConsoleAppender(new SimpleLayout()));

        action = cmd.getOptionValue("a", "help");

        /**
         * set config file path
         */
        config.setBasedir(cmd.getOptionValue("b", "."));
        config.setConfigFile(cmd.getOptionValue("c",
                config.getBasedir() + File.separator + "conf" + File.separator + "config.properties"));
    } catch (ParseException e) {
        System.err.println("Error in parameters: " + e.getLocalizedMessage());
        System.exit(-1);
    }

    //autoupdate cycle
    while (true) {
        try {
            switch (action.toLowerCase()) {
            case "start": {
                reinit();

                LOG.info("Starting " + Constants.BANNER);
                // writePid(_pid, _pidfile);

                _zabbixSender = new ZabbixSender(ZabbixSender.PROTOCOL.V32);
                _zabbixSender.updateServerList(config.getZabbixServers().toArray(new ZabbixServer[0]));
                _zabbixSender.start();

                //persSender = new PersistentDBSender(PersistentDBSender.PROTOCOL.V18);
                //persSender.updateServerList(config.getZabbixServers().toArray(new ZServer[0]));
                //persSender.start();

                config.startChecks();
                action = "update";
            }
                break;
            case "update": {
                LOG.info("Sleeping before configuration update...");
                Thread.sleep(config.getUpdateConfigTimeout() * 1000);
                LOG.info("Updating DBforBix configuration...");
                if (config.checkConfigChanges())
                    action = "stop";
            }
                break;
            case "stop": {
                LOG.info("Stopping DBforBix...");
                config = config.reset();
                if (_zabbixSender != null) {
                    _zabbixSender.terminate();
                    while (_zabbixSender.isAlive())
                        Thread.yield();
                }
                //workTimers=new HashMap<String, Timer>();
                _zabbixSender = null;

                if (persSender != null) {
                    persSender.terminate();
                    while (persSender.isAlive())
                        Thread.yield();
                }

                DBManager dbman = DBManager.getInstance();
                dbman = dbman.cleanAll();

                action = "start";
            }
                break;
            default: {
                LOG.error("Unknown action " + action);
                System.exit(-5);
            }
                break;
            }
        } catch (Throwable th) {
            LOG.fatal("DBforBix crashed!", th);
        }
    }
}

From source file:javazoom.jlgui.player.amp.Player.java

/**
 * Entry point./* w ww .  jav  a  2s .c  o m*/
 */
public static void main(String[] args) {
    Player theGUI;
    String currentArg = null;
    String currentValue = null;
    String skin = null;
    for (int i = 0; i < args.length; i++) {
        currentArg = args[i];
        if (currentArg.startsWith("-")) {
            if (currentArg.toLowerCase().equals("-init")) {
                i++;
                if (i >= args.length)
                    usage("init value missing");
                currentValue = args[i];
                if (Config.startWithProtocol(currentValue))
                    initConfig = currentValue;
                else
                    initConfig = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
            } else if (currentArg.toLowerCase().equals("-song")) {
                i++;
                if (i >= args.length)
                    usage("song value missing");
                currentValue = args[i];
                if (Config.startWithProtocol(currentValue))
                    initSong = currentValue;
                else
                    initSong = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
            } else if (currentArg.toLowerCase().equals("-start")) {
                autoRun = true;
            } else if (currentArg.toLowerCase().equals("-showplaylist")) {
                showPlaylist = "true";
            } else if (currentArg.toLowerCase().equals("-showequalizer")) {
                showEqualizer = "true";
            } else if (currentArg.toLowerCase().equals("-skin")) {
                i++;
                if (i >= args.length)
                    usage("skin value missing");
                currentValue = args[i];
                if (Config.startWithProtocol(currentValue))
                    skin = currentValue;
                else
                    skin = currentValue.replace('\\', '/').replace('/', java.io.File.separatorChar);
            } else if (currentArg.toLowerCase().equals("-v")) {
                i++;
                if (i >= args.length)
                    usage("skin version value missing");
                skinVersion = args[i];
            } else
                usage("Unknown parameter : " + currentArg);
        } else {
            usage("Invalid parameter :" + currentArg);
        }
    }
    // Instantiate AWT front-end.      
    theGUI = new Player(skin, new Frame(TITLETEXT));
    // Instantiate low-level player.
    BasicPlayer bplayer = new BasicPlayer();
    // Register the front-end to low-level player events.
    bplayer.addBasicPlayerListener(theGUI);
    // Adds controls for front-end to low-level player.
    theGUI.setController(bplayer);
    // Display.
    theGUI.show();
    if (autoRun == true)
        theGUI.pressStart();
}

From source file:com.moviejukebox.MovieJukebox.java

public static void main(String[] args) throws Throwable {
    JukeboxStatistics.setTimeStart(System.currentTimeMillis());

    // Create the log file name here, so we can change it later (because it's locked
    System.setProperty("file.name", LOG_FILENAME);
    PropertyConfigurator.configure("properties/log4j.properties");

    LOG.info("Yet Another Movie Jukebox {}", GitRepositoryState.getVersion());
    LOG.info("~~~ ~~~~~~~ ~~~~~ ~~~~~~~ {}", StringUtils.repeat("~", GitRepositoryState.getVersion().length()));
    LOG.info("https://github.com/YAMJ/yamj-v2");
    LOG.info("Copyright (c) 2004-2016 YAMJ Members");
    LOG.info("");
    LOG.info("This software is licensed under the GNU General Public License v3+");
    LOG.info("See this page: https://github.com/YAMJ/yamj-v2/wiki/License");
    LOG.info("");
    LOG.info(" Revision SHA: {} {}", GIT.getCommitId(), GIT.getDirty() ? "(Custom Build)" : "");
    LOG.info("  Commit Date: {}", GIT.getCommitTime());
    LOG.info("   Build Date: {}", GIT.getBuildTime());
    LOG.info("");
    LOG.info(" Java Version: {}", GitRepositoryState.getJavaVersion());
    LOG.info("");

    if (!SystemTools.validateInstallation()) {
        LOG.info("ABORTING.");
        return;//from  w w w .jav  a  2  s.  c  om
    }

    String movieLibraryRoot = null;
    String jukeboxRoot = null;
    Map<String, String> cmdLineProps = new LinkedHashMap<>();

    try {
        for (int i = 0; i < args.length; i++) {
            String arg = args[i];
            if ("-v".equalsIgnoreCase(arg)) {
                // We've printed the version, so quit now
                return;
            } else if ("-t".equalsIgnoreCase(arg)) {
                String pin = args[++i];

                // load the apikeys.properties file
                if (!setPropertiesStreamName("./properties/apikeys.properties", Boolean.TRUE)) {
                    return;
                }

                // authorize to Trakt.TV
                TraktTV.getInstance().initialize().authorizeWithPin(pin);

                // We've authorized access to Trakt.TV, so quit now
                return;
            } else if ("-o".equalsIgnoreCase(arg)) {
                jukeboxRoot = args[++i];
                PropertiesUtil.setProperty("mjb.jukeboxRoot", jukeboxRoot);
            } else if ("-c".equalsIgnoreCase(arg)) {
                jukeboxClean = Boolean.TRUE;
                PropertiesUtil.setProperty("mjb.jukeboxClean", TRUE);
            } else if ("-k".equalsIgnoreCase(arg)) {
                setJukeboxPreserve(Boolean.TRUE);
            } else if ("-p".equalsIgnoreCase(arg)) {
                userPropertiesName = args[++i];
            } else if ("-i".equalsIgnoreCase(arg)) {
                skipIndexGeneration = Boolean.TRUE;
                PropertiesUtil.setProperty("mjb.skipIndexGeneration", TRUE);
            } else if ("-h".equalsIgnoreCase(arg)) {
                skipHtmlGeneration = Boolean.TRUE;
                PropertiesUtil.setProperty("mjb.skipHtmlGeneration", Boolean.TRUE);
            } else if ("-dump".equalsIgnoreCase(arg)) {
                dumpLibraryStructure = Boolean.TRUE;
            } else if ("-memory".equalsIgnoreCase(arg)) {
                showMemory = Boolean.TRUE;
                PropertiesUtil.setProperty("mjb.showMemory", Boolean.TRUE);
            } else if (arg.startsWith("-D")) {
                String propLine = arg.length() > 2 ? arg.substring(2) : args[++i];
                int propDiv = propLine.indexOf('=');
                if (-1 != propDiv) {
                    cmdLineProps.put(propLine.substring(0, propDiv), propLine.substring(propDiv + 1));
                }
            } else if (arg.startsWith("-")) {
                help();
                return;
            } else {
                movieLibraryRoot = args[i];
            }
        }
    } catch (Exception error) {
        LOG.error("Wrong arguments specified");
        help();
        return;
    }

    // Save the name of the properties file for use later
    setProperty("userPropertiesName", userPropertiesName);

    LOG.info("Processing started at {}", new Date());
    LOG.info("");

    // Load the moviejukebox-default.properties file
    if (!setPropertiesStreamName("./properties/moviejukebox-default.properties", Boolean.TRUE)) {
        return;
    }

    // Load the user properties file "moviejukebox.properties"
    // No need to abort if we don't find this file
    // Must be read before the skin, because this may contain an override skin
    setPropertiesStreamName(userPropertiesName, Boolean.FALSE);

    // Grab the skin from the command-line properties
    if (cmdLineProps.containsKey(SKIN_DIR)) {
        setProperty(SKIN_DIR, cmdLineProps.get(SKIN_DIR));
    }

    // Load the skin.properties file
    if (!setPropertiesStreamName(getProperty(SKIN_DIR, SKIN_DEFAULT) + "/skin.properties", Boolean.TRUE)) {
        return;
    }

    // Load the skin-user.properties file (ignore the error)
    setPropertiesStreamName(getProperty(SKIN_DIR, SKIN_DEFAULT) + "/skin-user.properties", Boolean.FALSE);

    // Load the overlay.properties file (ignore the error)
    String overlayRoot = getProperty("mjb.overlay.dir", Movie.UNKNOWN);
    overlayRoot = (PropertiesUtil.getBooleanProperty("mjb.overlay.skinroot", Boolean.TRUE)
            ? (getProperty(SKIN_DIR, SKIN_DEFAULT) + File.separator)
            : "") + (StringTools.isValidString(overlayRoot) ? (overlayRoot + File.separator) : "");
    setPropertiesStreamName(overlayRoot + "overlay.properties", Boolean.FALSE);

    // Load the apikeys.properties file
    if (!setPropertiesStreamName("./properties/apikeys.properties", Boolean.TRUE)) {
        return;
    }

    // This is needed to update the static reference for the API Keys in the pattern formatter
    // because the formatter is initialised before the properties files are read
    FilteringLayout.addApiKeys();

    // Load the rest of the command-line properties
    for (Map.Entry<String, String> propEntry : cmdLineProps.entrySet()) {
        setProperty(propEntry.getKey(), propEntry.getValue());
    }

    // Read the information about the skin
    SkinProperties.readSkinVersion();
    // Display the information about the skin
    SkinProperties.printSkinVersion();

    StringBuilder properties = new StringBuilder("{");
    for (Map.Entry<Object, Object> propEntry : PropertiesUtil.getEntrySet()) {
        properties.append(propEntry.getKey());
        properties.append("=");
        properties.append(propEntry.getValue());
        properties.append(",");
    }
    properties.replace(properties.length() - 1, properties.length(), "}");

    // Print out the properties to the log file.
    LOG.debug("Properties: {}", properties.toString());

    // Check for mjb.skipIndexGeneration and set as necessary
    // This duplicates the "-i" functionality, but allows you to have it in the property file
    skipIndexGeneration = PropertiesUtil.getBooleanProperty("mjb.skipIndexGeneration", Boolean.FALSE);

    if (PropertiesUtil.getBooleanProperty("mjb.people", Boolean.FALSE)) {
        peopleScan = Boolean.TRUE;
        peopleScrape = PropertiesUtil.getBooleanProperty("mjb.people.scrape", Boolean.TRUE);
        peopleMax = PropertiesUtil.getIntProperty("mjb.people.maxCount", 10);
        popularity = PropertiesUtil.getIntProperty("mjb.people.popularity", 5);

        // Issue 1947: Cast enhancement - option to save all related files to a specific folder
        peopleFolder = PropertiesUtil.getProperty("mjb.people.folder", "");
        if (isNotValidString(peopleFolder)) {
            peopleFolder = "";
        } else if (!peopleFolder.endsWith(File.separator)) {
            peopleFolder += File.separator;
        }
        StringTokenizer st = new StringTokenizer(
                PropertiesUtil.getProperty("photo.scanner.photoExtensions", "jpg,jpeg,gif,bmp,png"), ",;| ");
        while (st.hasMoreTokens()) {
            PHOTO_EXTENSIONS.add(st.nextToken());
        }
    }

    // Check for mjb.skipHtmlGeneration and set as necessary
    // This duplicates the "-h" functionality, but allows you to have it in the property file
    skipHtmlGeneration = PropertiesUtil.getBooleanProperty("mjb.skipHtmlGeneration", Boolean.FALSE);

    // Look for the parameter in the properties file if it's not been set on the command line
    // This way we don't overwrite the setting if it's not found and defaults to FALSE
    showMemory = PropertiesUtil.getBooleanProperty("mjb.showMemory", Boolean.FALSE);

    // This duplicates the "-c" functionality, but allows you to have it in the property file
    jukeboxClean = PropertiesUtil.getBooleanProperty("mjb.jukeboxClean", Boolean.FALSE);

    MovieFilenameScanner.setSkipKeywords(
            tokenizeToArray(getProperty("filename.scanner.skip.keywords", ""), ",;| "),
            PropertiesUtil.getBooleanProperty("filename.scanner.skip.caseSensitive", Boolean.TRUE));
    MovieFilenameScanner.setSkipRegexKeywords(
            tokenizeToArray(getProperty("filename.scanner.skip.keywords.regex", ""), ","),
            PropertiesUtil.getBooleanProperty("filename.scanner.skip.caseSensitive.regex", Boolean.TRUE));
    MovieFilenameScanner.setExtrasKeywords(
            tokenizeToArray(getProperty("filename.extras.keywords", "trailer,extra,bonus"), ",;| "));
    MovieFilenameScanner.setMovieVersionKeywords(tokenizeToArray(
            getProperty("filename.movie.versions.keywords", "remastered,directors cut,extended cut,final cut"),
            ",;|"));
    MovieFilenameScanner.setLanguageDetection(
            PropertiesUtil.getBooleanProperty("filename.scanner.language.detection", Boolean.TRUE));
    final KeywordMap languages = PropertiesUtil.getKeywordMap("filename.scanner.language.keywords", null);
    if (!languages.isEmpty()) {
        MovieFilenameScanner.clearLanguages();
        for (String lang : languages.getKeywords()) {
            String values = languages.get(lang);
            if (values != null) {
                MovieFilenameScanner.addLanguage(lang, values, values);
            } else {
                LOG.info("No values found for language code '{}'", lang);
            }
        }
    }
    final KeywordMap sourceKeywords = PropertiesUtil.getKeywordMap("filename.scanner.source.keywords",
            "HDTV,PDTV,DVDRip,DVDSCR,DSRip,CAM,R5,LINE,HD2DVD,DVD,DVD5,DVD9,HRHDTV,MVCD,VCD,TS,VHSRip,BluRay,HDDVD,D-THEATER,SDTV");
    MovieFilenameScanner.setSourceKeywords(sourceKeywords.getKeywords(), sourceKeywords);

    String temp = getProperty("sorting.strip.prefixes");
    if (temp != null) {
        StringTokenizer st = new StringTokenizer(temp, ",");
        while (st.hasMoreTokens()) {
            String token = st.nextToken().trim();
            if (token.startsWith("\"") && token.endsWith("\"")) {
                token = token.substring(1, token.length() - 1);
            }
            Movie.addSortIgnorePrefixes(token.toLowerCase());
        }
    }

    enableWatchScanner = PropertiesUtil.getBooleanProperty("watched.scanner.enable", Boolean.TRUE);
    enableWatchTraktTv = PropertiesUtil.getBooleanProperty("watched.trakttv.enable", Boolean.FALSE);
    enableCompleteMovies = PropertiesUtil.getBooleanProperty("complete.movies.enable", Boolean.TRUE);

    // Check to see if don't have a root, check the property file
    if (StringTools.isNotValidString(movieLibraryRoot)) {
        movieLibraryRoot = getProperty("mjb.libraryRoot");
        if (StringTools.isValidString(movieLibraryRoot)) {
            LOG.info("Got libraryRoot from properties file: {}", movieLibraryRoot);
        } else {
            LOG.error("No library root found!");
            help();
            return;
        }
    }

    if (jukeboxRoot == null) {
        jukeboxRoot = getProperty("mjb.jukeboxRoot");
        if (jukeboxRoot == null) {
            LOG.info("jukeboxRoot is null in properties file. Please fix this as it may cause errors.");
        } else {
            LOG.info("Got jukeboxRoot from properties file: {}", jukeboxRoot);
        }
    }

    File f = new File(movieLibraryRoot);
    if (f.exists() && f.isDirectory() && jukeboxRoot == null) {
        jukeboxRoot = movieLibraryRoot;
    }

    if (movieLibraryRoot == null) {
        help();
        return;
    }

    if (jukeboxRoot == null) {
        LOG.info("Wrong arguments specified: you must define the jukeboxRoot property (-o) !");
        help();
        return;
    }

    if (!f.exists()) {
        LOG.error("Directory or library configuration file '{}', not found.", movieLibraryRoot);
        return;
    }

    FileTools.initUnsafeChars();
    FileTools.initSubtitleExtensions();

    // make canonical names
    jukeboxRoot = FileTools.getCanonicalPath(jukeboxRoot);
    movieLibraryRoot = FileTools.getCanonicalPath(movieLibraryRoot);
    MovieJukebox ml = new MovieJukebox(movieLibraryRoot, jukeboxRoot);
    if (dumpLibraryStructure) {
        LOG.warn(
                "WARNING !!! A dump of your library directory structure will be generated for debug purpose. !!! Library won't be built or updated");
        ml.makeDumpStructure();
    } else {
        ml.generateLibrary();
    }

    // Now rename the log files
    renameLogFile();

    if (ScanningLimit.isLimitReached()) {
        LOG.warn("Scanning limit of {} was reached, please re-run to complete processing.",
                ScanningLimit.getLimit());
        System.exit(EXIT_SCAN_LIMIT);
    } else {
        System.exit(EXIT_NORMAL);
    }
}

From source file:me.gloriouseggroll.quorrabot.Quorrabot.java

public static void main(String[] args) throws IOException {
    String user = "";
    String oauth = "";
    String apioauth = "";
    String channelName = "";
    String webauth = "";
    String webauthro = "";
    String clientid = "";
    String owner = "";
    String hostname = "";
    int baseport = 25300;
    InetAddress ip = InetAddress.getByName("127.0.0.1");
    int port = 0;
    double msglimit30 = 18.75;
    String datastore = "";
    String datastoreconfig = "";
    String youtubekey = "";
    String gamewispauth = "";
    String gamewisprefresh = "";
    String twitchalertstoken = "";
    String lastfmuser = "";
    String tpetoken = "";
    String twittertoken = "";
    String twittertokensecret = "";
    String streamtiptoken = "";
    String streamtipid = "";
    boolean webenable = true;
    boolean musicenable = true;
    boolean usehttps = false;
    String keystorepath = "";
    String keystorepassword = "";
    String timeZone = "";
    String mySqlConn = "";
    String mySqlHost = "";
    String mySqlPort = "";
    String mySqlName = "";
    String mySqlUser = "";
    String mySqlPass = "";
    FollowersCache followersCache;/* w w w.  ja va  2  s . c o  m*/
    ChannelUsersCache channelUsersCache;
    ChannelHostCache hostCache;
    SubscribersCache subscribersCache;
    String discordToken = "";
    String discordMainChannel = "";

    boolean changed = false;

    try {
        if (new File("./botlogin.txt").exists()) {
            String data = FileUtils.readFileToString(new File("./botlogin.txt"));
            String[] lines = data.replaceAll("\\r", "").split("\\n");

            for (String line : lines) {

                if (line.startsWith("logtimezone=") && line.length() >= 15) {
                    timeZone = line.substring(12);
                }
                if (line.startsWith("websocketircab")) {
                    Quorrabot.webSocketIRCAB = true;
                }
                if (line.startsWith("user=") && line.length() > 8) {
                    user = line.substring(5);
                }
                if (line.startsWith("oauth=") && line.length() > 9) {
                    oauth = line.substring(6);
                }
                if (line.startsWith("apioauth=") && line.length() > 12) {
                    apioauth = line.substring(9);
                }
                if (line.startsWith("clientid=") && line.length() > 12) {
                    clientid = line.substring(9);
                }
                if (line.startsWith("channel=") && line.length() > 11) {
                    channelName = line.substring(8);
                }
                if (line.startsWith("owner=") && line.length() > 9) {
                    owner = line.substring(6);
                }
                if (line.startsWith("baseport=") && line.length() > 10) {
                    baseport = Integer.parseInt(line.substring(9));
                }
                if (line.startsWith("ip=") && line.length() > 4) {
                    ip = InetAddress.getByName(line.substring(3));
                }
                if (line.startsWith("hostname=") && line.length() > 10) {
                    hostname = line.substring(9);
                }
                if (line.startsWith("port=") && line.length() > 6) {
                    port = Integer.parseInt(line.substring(5));
                }
                if (line.startsWith("msglimit30=") && line.length() > 12) {
                    msglimit30 = Double.parseDouble(line.substring(11));
                }
                if (line.startsWith("datastore=") && line.length() > 11) {
                    datastore = line.substring(10);
                }
                if (line.startsWith("youtubekey=") && line.length() > 12) {
                    youtubekey = line.substring(11);
                }
                if (line.startsWith("gamewispauth=") && line.length() > 14) {
                    gamewispauth = line.substring(13);
                }
                if (line.startsWith("gamewisprefresh=") && line.length() > 17) {
                    gamewisprefresh = line.substring(16);
                }
                if (line.startsWith("twitchalertstoken=") && line.length() > 19) {
                    twitchalertstoken = line.substring(18);
                }
                if (line.startsWith("lastfmuser=") && line.length() > 12) {
                    lastfmuser = line.substring(11);
                }
                if (line.startsWith("tpetoken=") && line.length() > 10) {
                    tpetoken = line.substring(9);
                }
                if (line.startsWith("twittertoken=") && line.length() > 14) {
                    twittertoken = line.substring(13);
                }
                if (line.startsWith("twittertokensecret=") && line.length() > 20) {
                    twittertokensecret = line.substring(19);
                }
                if (line.startsWith("streamtiptoken=") && line.length() > 16) {
                    streamtiptoken = line.substring(15);
                }
                if (line.startsWith("streamtipid=") && line.length() > 13) {
                    streamtipid = line.substring(12);
                }
                if (line.startsWith("webenable=") && line.length() > 11) {
                    webenable = Boolean.valueOf(line.substring(10));
                }
                if (line.startsWith("musicenable=") && line.length() > 13) {
                    musicenable = Boolean.valueOf(line.substring(12));
                }
                if (line.startsWith("usehttps=") && line.length() > 10) {
                    usehttps = Boolean.valueOf(line.substring(9));
                }
                if (line.startsWith("mysqlhost=") && line.length() > 11) {
                    mySqlHost = line.substring(10);
                }
                if (line.startsWith("mysqlport=") && line.length() > 11) {
                    mySqlPort = line.substring(10);
                }
                if (line.startsWith("mysqlname=") && line.length() > 11) {
                    mySqlName = line.substring(10);
                }
                if (line.startsWith("mysqluser=") && line.length() > 11) {
                    mySqlUser = line.substring(10);
                }
                if (line.startsWith("mysqlpass=") && line.length() > 11) {
                    mySqlPass = line.substring(10);
                }
                if (line.startsWith("keystorepath=") && line.length() > 14) {
                    keystorepath = line.substring(13);
                }
                if (line.startsWith("keystorepassword=") && line.length() > 18) {
                    keystorepassword = line.substring(17);
                }
                if (line.startsWith("webauth=") && line.length() > 9) {
                    webauth = line.substring(8);
                }
                if (line.startsWith("webauthro=") && line.length() > 11) {
                    webauthro = line.substring(10);
                }
                if (line.startsWith("discordtoken=") && line.length() >= 14) {
                    discordToken = line.substring(13);
                }
                if (line.startsWith("discordmainchannel=") && line.length() >= 20) {
                    discordMainChannel = line.substring(19);
                }
            }
        }
    } catch (IOException ex) {
        com.gmt2001.Console.err.printStackTrace(ex);
    }

    /**
     * Check to see if there's a soundboardauth set
     */
    if (webauth.isEmpty()) {
        webauth = generateWebAuth();
        com.gmt2001.Console.debug.println("New webauth key has been generated for botlogin.txt");
        changed = true;
    }
    /**
     * Check to see if there's a soundboardauthread set
     */
    if (webauthro.isEmpty()) {
        webauthro = generateWebAuth();
        com.gmt2001.Console.debug.println("New webauth read-only key has been generated for botlogin.txt");
        changed = true;
    }

    try {
        if (user.isEmpty()) {
            com.gmt2001.Console.out.print("Please enter the bot's twitch username: ");
            user = System.console().readLine().trim().toLowerCase();
            changed = true;
        }
        if (oauth.isEmpty()) {
            com.gmt2001.Console.out.println(
                    "Visit http://quorrabot.com/pages/twitchapi/ to generate oAuth tokens for both the bot and the channel owner accounts (including 'oauth:') & type it below.");
            com.gmt2001.Console.out
                    .println("IMPORTANT: This MUST be done while logged in as the BOT account!" + "\n");
            com.gmt2001.Console.out.println("Please enter the bot's tmi oauth token: ");
            oauth = System.console().readLine().trim();
            changed = true;
        }
        if (channelName.isEmpty()) {
            com.gmt2001.Console.out.print(
                    "Please enter the name of the twitch channel the bot should join (not the url, just the name): ");
            channelName = System.console().readLine().trim().toLowerCase();
            changed = true;
        }
        if (apioauth.isEmpty()) {
            com.gmt2001.Console.out.println(
                    "Visit http://quorrabot.com/pages/twitchapi/ to generate oAuth tokens for both the bot and the channel owner accounts (including 'oauth:') & type it below.");
            com.gmt2001.Console.out.println(
                    "IMPORTANT: This MUST be done while logged in on the CHANNEL OWNER account!" + "\n");
            com.gmt2001.Console.out.println("Please enter the channel owner's tmi oauth token: ");
            apioauth = System.console().readLine().trim();
            changed = true;
        }
    } catch (NullPointerException ex) {
        com.gmt2001.Console.err.printStackTrace(ex);
    }

    if (owner.isEmpty()) {
        owner = channelName;

        changed = true;
    }

    if (args.length > 0) {
        for (String arg : args) {
            if (arg.equalsIgnoreCase("printlogin")) {
                com.gmt2001.Console.out.println("user='" + user + "'");
                com.gmt2001.Console.out.println("oauth='" + oauth + "'");
                com.gmt2001.Console.out.println("apioauth='" + apioauth + "'");
                com.gmt2001.Console.out.println("clientid='" + clientid + "'");
                com.gmt2001.Console.out.println("channel='" + channelName + "'");
                com.gmt2001.Console.out.println("owner='" + owner + "'");
                com.gmt2001.Console.out.println("baseport='" + baseport + "'");
                com.gmt2001.Console.out.println("ip='" + ip.getHostAddress() + "'");
                com.gmt2001.Console.out.println("hostname='" + hostname + "'");
                com.gmt2001.Console.out.println("port='" + port + "'");
                com.gmt2001.Console.out.println("msglimit30='" + msglimit30 + "'");
                com.gmt2001.Console.out.println("datastore='" + datastore + "'");
                com.gmt2001.Console.out.println("youtubekey='" + youtubekey + "'");
                com.gmt2001.Console.out.println("gamewispauth=" + gamewispauth + "'");
                com.gmt2001.Console.out.println("gamewisprefresh=" + gamewisprefresh + "'");
                com.gmt2001.Console.out.println("twitchalertstoken='" + twitchalertstoken + "'");
                com.gmt2001.Console.out.println("lastfmuser='" + lastfmuser + "'");
                com.gmt2001.Console.out.println("tpetoken='" + tpetoken + "'");
                com.gmt2001.Console.out.println("twittertoken='" + twittertoken + "'");
                com.gmt2001.Console.out.println("twittertokensecret='" + twittertokensecret + "'");
                com.gmt2001.Console.out.println("streamtiptoken='" + streamtiptoken + "'");
                com.gmt2001.Console.out.println("streamtipid='" + streamtipid + "'");
                com.gmt2001.Console.out.println("webenable=" + webenable);
                com.gmt2001.Console.out.println("musicenable=" + musicenable);
                com.gmt2001.Console.out.println("usehttps=" + usehttps);
                com.gmt2001.Console.out.println("keystorepath='" + keystorepath + "'");
                com.gmt2001.Console.out.println("keystorepassword='" + keystorepassword + "'");
                com.gmt2001.Console.out.println("discordtoken='" + discordToken + "'");
                com.gmt2001.Console.out.println("discordmainchannel='" + discordMainChannel + "'");
            }
            if (arg.equalsIgnoreCase("debugon")) {
                Quorrabot.enableDebugging = true;
            }
            if (arg.equalsIgnoreCase("ini2sqlite")) {
                com.gmt2001.Console.out.println("Converting default IniStore to default SqliteStore...");
                ini2sqlite(false);
                com.gmt2001.Console.out.println("Operation complete. The bot will now exit");
                System.exit(0);
                return;
            }
            if (arg.toLowerCase().startsWith("user=") && arg.length() > 8) {
                if (!user.equals(arg.substring(5))) {
                    user = arg.substring(5).toLowerCase();
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("oauth=") && arg.length() > 9) {
                if (!oauth.equals(arg.substring(6))) {
                    oauth = arg.substring(6);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("apioauth=") && arg.length() > 12) {
                if (!apioauth.equals(arg.substring(9))) {
                    apioauth = arg.substring(9);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("mysqlhost=") && arg.length() > 11) {
                if (!mySqlHost.equals(arg.substring(10))) {
                    mySqlHost = arg.substring(10);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("mysqlport=") && arg.length() > 11) {
                if (!mySqlPort.equals(arg.substring(10))) {
                    mySqlPort = arg.substring(10);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("mysqlname=") && arg.length() > 11) {
                if (!mySqlName.equals(arg.substring(10))) {
                    mySqlName = arg.substring(10);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("mysqluser=") && arg.length() > 11) {
                if (!mySqlUser.equals(arg.substring(14))) {
                    mySqlUser = arg.substring(10);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("mysqlpass=") && arg.length() > 11) {
                if (!mySqlPass.equals(arg.substring(10))) {
                    mySqlPass = arg.substring(10);
                    changed = true;
                }
            }

            if (arg.toLowerCase().startsWith("clientid=") && arg.length() > 12) {
                if (!clientid.equals(arg.substring(9))) {
                    clientid = arg.substring(9);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("channel=") && arg.length() > 11) {
                if (!channelName.equals(arg.substring(8))) {
                    channelName = arg.substring(8).toLowerCase();
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("owner=") && arg.length() > 9) {
                if (!owner.equals(arg.substring(6))) {
                    owner = arg.substring(6).toLowerCase();
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("baseport=") && arg.length() > 10) {
                if (baseport != Integer.parseInt(arg.substring(9))) {
                    baseport = Integer.parseInt(arg.substring(9));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("ip=") && arg.length() > 4) {
                if (ip != InetAddress.getByName(arg.substring(3))) {
                    ip = InetAddress.getByName(arg.substring(3));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("hostname=") && arg.length() > 10) {
                if (!hostname.equals(arg.substring(9))) {
                    hostname = arg.substring(9);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("port=") && arg.length() > 6) {
                if (port != Integer.parseInt(arg.substring(5))) {
                    port = Integer.parseInt(arg.substring(5));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("msglimit30=") && arg.length() > 12) {
                if (msglimit30 != Double.parseDouble(arg.substring(11))) {
                    msglimit30 = Double.parseDouble(arg.substring(11));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("datastore=") && arg.length() > 11) {
                if (!datastore.equals(arg.substring(10))) {
                    datastore = arg.substring(10);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("datastoreconfig=") && arg.length() > 17) {
                datastoreconfig = arg.substring(16);
            }
            if (arg.toLowerCase().startsWith("youtubekey=") && arg.length() > 12) {
                if (!youtubekey.equals(arg.substring(11))) {
                    youtubekey = arg.substring(11);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("gamewispauth=") && arg.length() > 14) {
                if (!gamewispauth.equals(arg.substring(13))) {
                    gamewispauth = arg.substring(13);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("gamewisprefresh=") && arg.length() > 17) {
                if (!gamewisprefresh.equals(arg.substring(16))) {
                    gamewisprefresh = arg.substring(16);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("twitchalertstoken=") && arg.length() > 19) {
                if (!twitchalertstoken.equals(arg.substring(18))) {
                    twitchalertstoken = arg.substring(18);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("lastfmuser=") && arg.length() > 12) {
                if (!lastfmuser.equals(arg.substring(11))) {
                    lastfmuser = arg.substring(11);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("tpetoken=") && arg.length() > 10) {
                if (!tpetoken.equals(arg.substring(9))) {
                    tpetoken = arg.substring(9);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("twittertoken=") && arg.length() > 14) {
                if (!twittertoken.equals(arg.substring(13))) {
                    twittertoken = arg.substring(13);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("twittertokensecret=") && arg.length() > 20) {
                if (!twittertokensecret.equals(arg.substring(19))) {
                    twittertokensecret = arg.substring(19);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("streamtiptoken=") && arg.length() > 16) {
                if (!streamtiptoken.equals(arg.substring(15))) {
                    streamtiptoken = arg.substring(15);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("streamtipid=") && arg.length() > 13) {
                if (!streamtipid.equals(arg.substring(12))) {
                    streamtipid = arg.substring(12);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("webenable=") && arg.length() > 11) {
                if (webenable != Boolean.valueOf(arg.substring(10))) {
                    webenable = Boolean.valueOf(arg.substring(10));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("musicenable=") && arg.length() > 13) {
                if (musicenable != Boolean.valueOf(arg.substring(12))) {
                    musicenable = Boolean.valueOf(arg.substring(12));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("usehttps=") && arg.length() > 10) {
                if (usehttps != Boolean.valueOf(arg.substring(9))) {
                    usehttps = Boolean.valueOf(arg.substring(9));
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("keystorepath=") && arg.length() > 14) {
                if (!keystorepath.equals(arg.substring(13))) {
                    keystorepath = arg.substring(13);
                    changed = true;
                }
            }
            if (arg.toLowerCase().startsWith("keystorepassword=") && arg.length() > 18) {
                if (!keystorepassword.equals(arg.substring(17))) {
                    keystorepassword = arg.substring(17);
                    changed = true;
                }
            }

            if (arg.equalsIgnoreCase("help") || arg.equalsIgnoreCase("--help") || arg.equalsIgnoreCase("-h")
                    || arg.equalsIgnoreCase("-?")) {
                com.gmt2001.Console.out.println(
                        "Usage: java -Dfile.encoding=UTF-8 -jar QuorraBot.jar [printlogin] [user=<bot username>] "
                                + "[oauth=<bot irc oauth>] [apioauth=<editor oauth>] [clientid=<oauth clientid>] [channel=<channel to join>] "
                                + "[owner=<bot owner username>] [baseport=<bot webserver port, music server will be +1>] [ip=<IP address (optional) to bind to>] [hostname=<custom irc server>] "
                                + "[port=<custom irc port>] [msglimit30=<message limit per 30 seconds>] "
                                + "[datastore=<DataStore type, for a list, run java -jar QuorraBot.jar storetypes>] "
                                + "[datastoreconfig=<Optional DataStore config option, different for each DataStore type>] "
                                + "[youtubekey=<youtube api key>] [webenable=<true | false>] [musicenable=<true | false>] "
                                + "[gamewispauth=<gamewisp oauth>] "
                                + "[gamewisprefresh=<gamewisp refresh key>] "
                                + "[twitchalertstoken=<TwitchAlerts access token>] "
                                + "[lastfmuser=<Last.FM username>] " + "[tpetoken=<Tipeeestream access token>] "
                                + "[streamtiptoken=<StreamTip access token>] "
                                + "[streamtipid=<StreamTip Client ID>] "
                                + "[twittertoken=<Twitter access token>] "
                                + "[twittertokensecret=<Twitter access token secret>]");

                return;
            }
            if (arg.equalsIgnoreCase("storetypes")) {
                com.gmt2001.Console.out.println(
                        "DataStore types: IniStore (datastoreconfig parameter is folder name, stores in .ini files), "
                                + "TempStore (Stores in memory, lost on shutdown), "
                                + "SqliteStore (Default, Stores in a SQLite3 database, datastoreconfig parameter is a config file");
                return;
            }
        }
    }

    if (changed) {
        String data = "";
        data += "user=" + user + "\r\n";
        data += "oauth=" + oauth + "\r\n";
        data += "apioauth=" + apioauth + "\r\n";
        data += "clientid=" + clientid + "\r\n";
        data += "webauth=" + webauth + "\r\n";
        data += "webauthro=" + webauthro + "\r\n";
        data += "channel=" + channelName + "\r\n";
        data += "owner=" + owner + "\r\n";
        data += "baseport=" + baseport + "\r\n";
        data += "ip=" + ip.getHostAddress() + "\r\n";
        data += "hostname=" + hostname + "\r\n";
        data += "port=" + port + "\r\n";
        data += "msglimit30=" + msglimit30 + "\r\n";
        data += "datastore=" + datastore + "\r\n";
        data += "youtubekey=" + youtubekey + "\r\n";
        data += "gamewispauth=" + gamewispauth + "\r\n";
        data += "gamewisprefresh=" + gamewisprefresh + "\r\n";
        data += "twitchalertstoken=" + twitchalertstoken + "\r\n";
        data += "lastfmuser=" + lastfmuser + "\r\n";
        data += "tpetoken=" + tpetoken + "\r\n";
        data += "twittertoken=" + twittertoken + "\r\n";
        data += "twittertokensecret=" + twittertokensecret + "\r\n";
        data += "streamtiptoken=" + streamtiptoken + "\r\n";
        data += "streamtipid=" + streamtipid + "\r\n";
        data += "webenable=" + webenable + "\r\n";
        data += "musicenable=" + musicenable + "\r\n";
        data += "usehttps=" + usehttps + "\r\n";
        data += "logtimezone=" + timeZone + "\r\n";
        data += "mysqlhost=" + mySqlHost + "\r\n";
        data += "mysqlport=" + mySqlPort + "\r\n";
        data += "mysqlname=" + mySqlName + "\r\n";
        data += "mysqluser=" + mySqlUser + "\r\n";
        data += "mysqlpass=" + mySqlPass + "\r\n";
        data += "keystorepath=" + keystorepath + "\r\n";
        data += "keystorepassword=" + keystorepassword + "\r\n";
        data += "discordtoken=" + discordToken + "\r\n";
        data += "discordmainchannel=" + discordMainChannel;

        Files.write(Paths.get("./botlogin.txt"), data.getBytes(StandardCharsets.UTF_8),
                StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING);
    }
    channelUsersCache = ChannelUsersCache.instance(owner);
    followersCache = FollowersCache.instance(owner);
    hostCache = ChannelHostCache.instance(owner);
    subscribersCache = SubscribersCache.instance(owner);

    Quorrabot.instance = new Quorrabot(user, oauth, apioauth, clientid, channelName, owner, baseport, ip,
            hostname, port, msglimit30, datastore, datastoreconfig, youtubekey, gamewispauth, gamewisprefresh,
            twitchalertstoken, lastfmuser, tpetoken, twittertoken, twittertokensecret, streamtiptoken,
            streamtipid, webenable, webauth, webauthro, musicenable, usehttps, timeZone, mySqlHost, mySqlPort,
            mySqlConn, mySqlPass, mySqlUser, mySqlName, keystorepath, followersCache, hostCache,
            channelUsersCache, subscribersCache, discordToken, discordMainChannel);
}

From source file:com.adobe.aem.demomachine.communities.Loader.java

public static void main(String[] args) {

    String hostname = null;/* ww  w  .j  a v  a 2 s  . c  o  m*/
    String port = null;
    String altport = null;
    String csvfile = null;
    String analytics = null;
    String adminPassword = "admin";
    boolean reset = false;
    boolean configure = false;
    boolean minimize = false;
    boolean noenablement = true;
    int maxretries = MAXRETRIES;

    // Command line options for this tool
    Options options = new Options();
    options.addOption("h", true, "Hostname");
    options.addOption("p", true, "Port");
    options.addOption("a", true, "Alternate Port");
    options.addOption("f", true, "CSV file");
    options.addOption("r", false, "Reset");
    options.addOption("u", true, "Admin Password");
    options.addOption("c", false, "Configure");
    options.addOption("m", false, "Minimize");
    options.addOption("e", false, "No Enablement");
    options.addOption("s", true, "Analytics Endpoint");
    options.addOption("t", false, "Analytics");
    options.addOption("w", false, "Retry");
    CommandLineParser parser = new BasicParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("h")) {
            hostname = cmd.getOptionValue("h");
        }

        if (cmd.hasOption("p")) {
            port = cmd.getOptionValue("p");
        }

        if (cmd.hasOption("a")) {
            altport = cmd.getOptionValue("a");
        }

        if (cmd.hasOption("f")) {
            csvfile = cmd.getOptionValue("f");
        }

        if (cmd.hasOption("u")) {
            adminPassword = cmd.getOptionValue("u");
        }

        if (cmd.hasOption("t")) {
            if (cmd.hasOption("s")) {
                analytics = cmd.getOptionValue("s");
            }
        }

        if (cmd.hasOption("r")) {
            reset = true;
        }

        if (cmd.hasOption("w")) {
            maxretries = Integer.parseInt(cmd.getOptionValue("w"));
        }

        if (cmd.hasOption("c")) {
            configure = true;
        }

        if (cmd.hasOption("m")) {
            minimize = true;
        }

        if (cmd.hasOption("e")) {
            noenablement = false;
        }

        if (csvfile == null || port == null || hostname == null) {
            System.out.println(
                    "Request parameters: -h hostname -p port -a alternateport -u adminPassword -f path_to_CSV_file -r (true|false, delete content before import) -c (true|false, post additional properties)");
            System.exit(-1);
        }

    } catch (ParseException ex) {

        logger.error(ex.getMessage());

    }

    logger.debug("AEM Demo Loader: Processing file " + csvfile);

    try {

        // Reading and processing the CSV file, stand alone or as part of a ZIP file
        if (csvfile != null && csvfile.toLowerCase().endsWith(".zip")) {

            ZipFile zipFile = new ZipFile(csvfile);
            ZipInputStream stream = new ZipInputStream(new FileInputStream(csvfile));
            ZipEntry zipEntry;
            while ((zipEntry = stream.getNextEntry()) != null) {
                if (!zipEntry.isDirectory() && zipEntry.getName().toLowerCase().endsWith(".csv")) {

                    InputStream is = zipFile.getInputStream(zipEntry);
                    BufferedReader in = new BufferedReader(new InputStreamReader(is, "UTF-8"));
                    processLoading(null, in, hostname, port, altport, adminPassword, analytics, reset,
                            configure, minimize, noenablement, csvfile, maxretries);

                }
            }

            try {
                stream.close();
                zipFile.close();
            } catch (IOException ioex) {
                //omitted.
            }

        } else if (csvfile.toLowerCase().endsWith(".csv")) {

            Reader in = new FileReader(csvfile);
            processLoading(null, in, hostname, port, altport, adminPassword, analytics, reset, configure,
                    minimize, noenablement, csvfile, maxretries);

        }

    } catch (IOException e) {

        logger.error(e.getMessage());

    }

}

From source file:com.peterbochs.PeterBochsDebugger.java

public static void main(String[] args) {
    WebServiceUtil.log("peter-bochs", "start", null, null, null);
    try {//www.j  a v  a 2  s .  c  om
        UIManager.setLookAndFeel("com.peterswing.white.PeterSwingWhiteLookAndFeel");
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (args.length == 0) {
        String errorMessage = "Wrong number of argument\n\n";
        errorMessage += "\nIn Linux/Mac : java -jar peter-bochs-debugger.jar bochs -f bochsrc.bxrc";
        errorMessage += "\nIn windows : java -jar peter-bochs-debugger.jar c:\\program files\\bochs2.4.3\\bochsdbg.exe -q -f bochsrc.bxrc";
        errorMessage += "\n!!! if using peter-bochs in windows, you need to pass the full path of bochs exe and -q to the parameter. (!!! relative path of bochs exe will not work)";
        errorMessage += "\n!!! to use \"experimental feature\", please add \"-debug\" to the parameter list";
        System.out.println(errorMessage);
        JOptionPane.showMessageDialog(null, errorMessage);
        System.exit(1);
    } else {
        if (args[0].equals("-version") || args[0].equals("-v")) {
            System.out.println(Global.version);
            System.exit(1);
        }
    }

    for (String str : args) {
        if (str.contains("bochsrc") || str.contains(".bxrc")) {
            bochsrc = str;
        }
    }

    String osName = System.getProperty("os.name").toLowerCase();
    if (osName.toLowerCase().contains("windows")) {
        os = OSType.win;
    } else if (osName.toLowerCase().contains("mac")) {
        os = OSType.mac;
    } else {
        os = OSType.linux;
    }
    if (os == OSType.mac) {
        com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication();
        // System.setProperty("dock:name", "Your Application Name");
        macApp.setDockIconImage(new ImageIcon(
                PeterBochsDebugger.class.getClassLoader().getResource("com/peterbochs/icons/peter.png"))
                        .getImage());
        // java.awt.PopupMenu menu = new java.awt.PopupMenu();
        // menu.add(new MenuItem("test"));
        // macApp.setDockMenu(menu);

        macApp.addApplicationListener(new MacAboutBoxHandler());
    }

    if (ArrayUtils.contains(args, "-debug")) {
        Global.debug = true;
        args = (String[]) ArrayUtils.removeElement(args, "-debug");
    } else {
        Global.debug = false;
    }

    try {
        if (PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile()
                .endsWith(".jar")) {
            JarFile jarFile = new JarFile(
                    PeterBochsDebugger.class.getProtectionDomain().getCodeSource().getLocation().getFile());
            if (System.getProperty("os.name").toLowerCase().contains("linux")) {
                if (System.getProperty("os.arch").contains("64")) {
                    if (Global.debug) {
                        System.out.println("Loading linux 64 bits jogl");
                    }
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libgluegen-rt.so")),
                            new File("libgluegen-rt.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_awt.so")),
                            new File("libjogl_awt.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl_cg.so")),
                            new File("libjogl_cg.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_amd64/libjogl.so")),
                            new File("libjogl.so"));
                } else {
                    if (Global.debug) {
                        System.out.println("Loading linux 32 bits jogl");
                    }
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_i586/libgluegen-rt.so")),
                            new File("libgluegen-rt.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_awt.so")),
                            new File("libjogl_awt.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl_cg.so")),
                            new File("libjogl_cg.so"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/linux_i586/libjogl.so")),
                            new File("libjogl.so"));
                }
                try {
                    File f = new File(".");
                    Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl.so");
                    System.out.println("Loading " + f.getAbsolutePath() + File.separator + "libjogl.so");
                    Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_awt.so");
                    Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libjogl_cg.so");
                    Runtime.getRuntime().load(f.getAbsolutePath() + File.separator + "libgluegen-rt.so");
                } catch (UnsatisfiedLinkError e) {
                    e.printStackTrace();
                    System.err.println("Native code library failed to load.\n" + e);
                    System.err.println(
                            "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e);
                }
            } else if (System.getProperty("os.name").toLowerCase().contains("windows")) {
                CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/PauseBochs.exe")),
                        new File("PauseBochs.exe"));
                CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/StopBochs.exe")),
                        new File("StopBochs.exe"));
                CommonLib.writeFile(jarFile.getInputStream(new JarEntry("com/peterbochs/exe/ndisasm.exe")),
                        new File("ndisasm.exe"));

                if (System.getProperty("os.arch").contains("64")) {
                    if (Global.debug) {
                        System.out.println("Loading windows 64 bits jogl");
                    }
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl.dll")),
                            new File("jogl.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_awt.dll")),
                            new File("jogl_awt.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_amd64/jogl_cg.dll")),
                            new File("jogl_cg.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_amd64/gluegen-rt.dll")),
                            new File("gluegen-rt.dll"));
                } else {
                    if (Global.debug) {
                        System.out.println("Loading windows 32 bits jogl");
                    }
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl.dll")),
                            new File("jogl.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_awt.dll")),
                            new File("jogl_awt.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_i586/jogl_cg.dll")),
                            new File("jogl_cg.dll"));
                    CommonLib.writeFile(
                            jarFile.getInputStream(
                                    new JarEntry("com/peterbochs/jogl_dll/windows_i586/gluegen-rt.dll")),
                            new File("gluegen-rt.dll"));
                }
                try {
                    File f = new File(".");
                    System.load(f.getAbsolutePath() + File.separator + "jogl.dll");
                    System.load(f.getAbsolutePath() + File.separator + "jogl_awt.dll");
                    System.load(f.getAbsolutePath() + File.separator + "jogl_cg.dll");
                    System.load(f.getAbsolutePath() + File.separator + "gluegen-rt.dll");
                } catch (UnsatisfiedLinkError e) {
                    e.printStackTrace();
                    System.err.println("Native code library failed to load.\n" + e);
                    System.err.println(
                            "Solution : Please add \"-Djava.library.path=.\" to start peter-bochs\n" + e);
                }
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    if (ArrayUtils.contains(args, "-loadBreakpoint")) {
        Setting.getInstance().setLoadBreakpointAtStartup(true);
        args = (String[]) ArrayUtils.removeElement(args, "-loadBreakpoint");
    } else if (ArrayUtils.contains(args, "-loadbreakpoint")) {
        Setting.getInstance().setLoadBreakpointAtStartup(true);
        args = (String[]) ArrayUtils.removeElement(args, "-loadbreakpoint");
    }

    for (int x = 0; x < args.length; x++) {
        if (args[x].toLowerCase().startsWith("-osdebug")) {
            Global.osDebug = CommonLib.string2long(args[x].replaceAll("-.*=", ""));
            args = (String[]) ArrayUtils.removeElement(args, args[x]);
            x = -1;
        } else if (args[x].toLowerCase().startsWith("-profilingmemoryport")) {
            Global.profilingMemoryPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", ""));
            args = (String[]) ArrayUtils.removeElement(args, args[x]);
            x = -1;
        } else if (args[x].toLowerCase().startsWith("-profilingjmpport")) {
            Global.profilingJmpPort = (int) CommonLib.string2long(args[x].replaceAll("-.*=", ""));
            args = (String[]) ArrayUtils.removeElement(args, args[x]);
            x = -1;
        } else if (args[x].toLowerCase().startsWith("-loadelf")) {
            Global.elfPaths = args[x].replaceAll("-loadelf=", "").split(",");
            Setting.getInstance().setLoadSystemMapAtStartup(true);
            args = (String[]) ArrayUtils.removeElement(args, args[x]);
            x = -1;
        } else if (args[x].toLowerCase().startsWith("-loadmap")) {
            System.out.println("-loadmap is not deprecated, please use -loadelf.");
        }
    }

    arguments = args;

    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            PeterBochsDebugger inst = new PeterBochsDebugger();
            PeterBochsDebugger.instance = inst;

            new Thread("preventSetVisibleHang thread") {
                public void run() {
                    try {
                        Thread.sleep(10000);
                        if (preventSetVisibleHang) {
                            System.out.println(
                                    "setVisible(true) cause system hang, this probably a swing bug, so force exit, please restart");
                            System.exit(-1);
                        }
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }.start();

            if (Global.debug) {
                System.out.println("setVisible(true)");
            }
            inst.setVisible(true);

            preventSetVisibleHang = false;
            if (Global.debug) {
                System.out.println("end setVisible(true)");
            }
        }
    });
}

From source file:Main.java

private static boolean isEnableSSL(String url) {
    return url.toLowerCase().startsWith("https");
}

From source file:Main.java

public static boolean isTrueString(String str) {
    str = str.toLowerCase();
    return "true".equals(str) || "1".equals(str) || "yes".equals(str);
}

From source file:Main.java

public static String getFileNameForName(String name) {
    return name.toLowerCase();
}

From source file:Main.java

public static boolean isCollectionPid(String pid) {
    return pid.toLowerCase().startsWith("vc:");
}