Example usage for java.lang Boolean parseBoolean

List of usage examples for java.lang Boolean parseBoolean

Introduction

In this page you can find the example usage for java.lang Boolean parseBoolean.

Prototype

public static boolean parseBoolean(String s) 

Source Link

Document

Parses the string argument as a boolean.

Usage

From source file:correospingtelnet.Telnet.java

public static void main(String[] args) throws Exception {
    FileOutputStream fout = null;

    String remoteip = "64.62.142.154";

    int remoteport = 23;

    try {/*w w  w  .j av  a2 s.co  m*/
        fout = new FileOutputStream("spy.log", true);
    } catch (IOException e) {
        System.err.println("Exception while opening the spy file: " + e.getMessage());
    }

    tc = new TelnetClient();

    TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
    EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
    SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);

    try {
        tc.addOptionHandler(ttopt);
        tc.addOptionHandler(echoopt);
        tc.addOptionHandler(gaopt);
    } catch (InvalidTelnetOptionException e) {
        System.err.println("Error registering option handlers: " + e.getMessage());
    }

    while (true) {
        boolean end_loop = false;
        try {
            tc.connect(remoteip, remoteport);

            Thread reader = new Thread(new Telnet());
            tc.registerNotifHandler(new Telnet());
            System.out.println("TelnetClientExample");
            System.out.println("Type AYT to send an AYT telnet command");
            System.out.println("Type OPT to print a report of status of options (0-24)");
            System.out.println("Type REGISTER to register a new SimpleOptionHandler");
            System.out.println("Type UNREGISTER to unregister an OptionHandler");
            System.out.println("Type SPY to register the spy (connect to port 3333 to spy)");
            System.out.println("Type UNSPY to stop spying the connection");
            System.out.println("Type ^[A-Z] to send the control character; use ^^ to send ^");

            reader.start();
            OutputStream outstr = tc.getOutputStream();

            byte[] buff = new byte[1024];
            int ret_read = 0;

            do {
                try {
                    ret_read = System.in.read(buff);
                    if (ret_read > 0) {
                        final String line = new String(buff, 0, ret_read); // deliberate use of default charset
                        if (line.startsWith("AYT")) {
                            try {
                                System.out.println("Sending AYT");

                                System.out.println("AYT response:" + tc.sendAYT(5000));
                            } catch (IOException e) {
                                System.err.println("Exception waiting AYT response: " + e.getMessage());
                            }
                        } else if (line.startsWith("OPT")) {
                            System.out.println("Status of options:");
                            for (int ii = 0; ii < 25; ii++) {
                                System.out.println("Local Option " + ii + ":" + tc.getLocalOptionState(ii)
                                        + " Remote Option " + ii + ":" + tc.getRemoteOptionState(ii));
                            }
                        } else if (line.startsWith("REGISTER")) {
                            StringTokenizer st = new StringTokenizer(new String(buff));
                            try {
                                st.nextToken();
                                int opcode = Integer.parseInt(st.nextToken());
                                boolean initlocal = Boolean.parseBoolean(st.nextToken());
                                boolean initremote = Boolean.parseBoolean(st.nextToken());
                                boolean acceptlocal = Boolean.parseBoolean(st.nextToken());
                                boolean acceptremote = Boolean.parseBoolean(st.nextToken());
                                SimpleOptionHandler opthand = new SimpleOptionHandler(opcode, initlocal,
                                        initremote, acceptlocal, acceptremote);
                                tc.addOptionHandler(opthand);
                            } catch (Exception e) {
                                if (e instanceof InvalidTelnetOptionException) {
                                    System.err.println("Error registering option: " + e.getMessage());
                                } else {
                                    System.err.println("Invalid REGISTER command.");
                                    System.err.println(
                                            "Use REGISTER optcode initlocal initremote acceptlocal acceptremote");
                                    System.err.println("(optcode is an integer.)");
                                    System.err.println(
                                            "(initlocal, initremote, acceptlocal, acceptremote are boolean)");
                                }
                            }
                        } else if (line.startsWith("UNREGISTER")) {
                            StringTokenizer st = new StringTokenizer(new String(buff));
                            try {
                                st.nextToken();
                                int opcode = (new Integer(st.nextToken())).intValue();
                                tc.deleteOptionHandler(opcode);
                            } catch (Exception e) {
                                if (e instanceof InvalidTelnetOptionException) {
                                    System.err.println("Error unregistering option: " + e.getMessage());
                                } else {
                                    System.err.println("Invalid UNREGISTER command.");
                                    System.err.println("Use UNREGISTER optcode");
                                    System.err.println("(optcode is an integer)");
                                }
                            }
                        } else if (line.startsWith("SPY")) {
                            tc.registerSpyStream(fout);
                        } else if (line.startsWith("UNSPY")) {
                            tc.stopSpyStream();
                        } else if (line.matches("^\\^[A-Z^]\\r?\\n?$")) {
                            byte toSend = buff[1];
                            if (toSend == '^') {
                                outstr.write(toSend);
                            } else {
                                outstr.write(toSend - 'A' + 1);
                            }
                            outstr.flush();
                        } else {
                            try {
                                outstr.write(buff, 0, ret_read);
                                outstr.flush();
                            } catch (IOException e) {
                                end_loop = true;
                            }
                        }
                    }
                } catch (IOException e) {
                    System.err.println("Exception while reading keyboard:" + e.getMessage());
                    end_loop = true;
                }
            } while ((ret_read > 0) && (end_loop == false));

            try {
                tc.disconnect();
            } catch (IOException e) {
                System.err.println("Exception while connecting:" + e.getMessage());
            }
        } catch (IOException e) {
            System.err.println("Exception while connecting:" + e.getMessage());
            System.exit(1);
        }
    }
}

From source file:com.bluexml.side.form.clazz.utils.ClassDiagramUtils.java

/**
 * Will return the field corresponding to the attribute
 * //from www.j  a  v a  2s .  c o m
 * @param att
 * @return
 */
public static Field getFieldForAttribute(Attribute att) {
    Field field = null;
    if (att != null) {
        Map<String, String> metaInfoMap = InitializeMetaInfo(att.getMetainfo());
        // Choice Field

        DataType typ = att.getTyp();
        if (typ.equals(DataType.CUSTOM)) {
            // map to handled type
            typ = getFieldForAlfrescoCustomType(att);
        }

        if (att.getValueList() != null) {
            field = FormFactory.eINSTANCE.createChoiceField();
            if (metaInfoMap.containsKey("multiple") && metaInfoMap.get("multiple") != null
                    && metaInfoMap.get("multiple").equals("True")) {
                ((ChoiceField) field).setMultiple(true);
            }
        } else if (typ.equals(DataType.STRING) | typ.equals(DataType.CHAR)) {
            // Email Field
            if (Boolean.parseBoolean(metaInfoMap.get("email"))) {
                field = FormFactory.eINSTANCE.createEmailField();
            } else {
                // Char Field
                field = FormFactory.eINSTANCE.createCharField();
                if (metaInfoMap.containsKey("max-length") && metaInfoMap.get("max-length") != null) {
                    ((CharField) field).setMax_length(Integer.parseInt(metaInfoMap.get("max-length")));
                }
                if (metaInfoMap.containsKey("min-length") && metaInfoMap.get("min-length") != null) {
                    ((CharField) field).setMin_length(Integer.parseInt(metaInfoMap.get("min-length")));
                }
            }
            // Date Time Field
        } else if (typ.equals(DataType.DATE_TIME)) {
            field = FormFactory.eINSTANCE.createDateTimeField();
            // Date Field
        } else if (typ.equals(DataType.DATE)) {
            field = FormFactory.eINSTANCE.createDateField();
            // Time Field
        } else if (typ.equals(DataType.TIME)) {
            field = FormFactory.eINSTANCE.createTimeField();
        } else if (typ.equals(DataType.BOOLEAN) || typ.equals(DataType.BYTE)) {
            // Boolean Field
            field = FormFactory.eINSTANCE.createBooleanField();
        } else if (typ.equals(DataType.INT)) {
            // Integer Field
            field = FormFactory.eINSTANCE.createIntegerField();
        } else if (typ.equals(DataType.LONG)) {
            // Long Field
            field = FormFactory.eINSTANCE.createIntegerField();
        } else if (typ.equals(DataType.FLOAT)) {
            // Float Field
            field = FormFactory.eINSTANCE.createFloatField();
        } else if (typ.equals(DataType.DOUBLE)) {
            // Decimal Field
            field = FormFactory.eINSTANCE.createDecimalField();
        } else if (typ.equals(DataType.SHORT)) {
            // Short Field
            field = FormFactory.eINSTANCE.createIntegerField();
        } else if (typ.equals(DataType.OBJECT)) {
            field = FormFactory.eINSTANCE.createCharField();
        } else if (typ.equals(DataType.CUSTOM)) {
            field = FormFactory.eINSTANCE.createCharField();
        } else {
            EcorePlugin.INSTANCE.log("No field available for " + typ);
        }

        if (field == null) {
            // field = formFactory.eINSTANCE.createField();
        } else {
            field.setRef(att);
            field.setId(att.getName());
            if (att.getTitle() != null && att.getTitle().length() > 0) {
                field.setLabel(att.getTitle());
            } else {
                field.setLabel(att.getName());
            }
            if (att.getMockup().size() > 0) {
                field.getMockup().addAll(att.getMockup());
            }
            field.setHidden(Boolean.parseBoolean(metaInfoMap.get("hidden")));
            field.setHelp_text(att.getDescription());
            field.setMandatory(Boolean.parseBoolean(metaInfoMap.get("required")));
            field.setInitial(att.getInitialValue());
            field.setId(att.getName());
        }
    }
    return field;
}

From source file:net.roboconf.target.docker.internal.DockerUtils.java

/**
 * Verifies the Docker client configuration.
 * @param targetProperties the target properties
 * @throws TargetException if the configuration is invalid
 *//*from   w w w  .  j a  v a2  s.  co m*/
public static void verifyDockerClient(Map<String, String> targetProperties) throws TargetException {

    String imageId = targetProperties.get(DockerHandler.IMAGE_ID);
    String generate = targetProperties.get(DockerHandler.GENERATE_IMAGE);
    if (imageId == null && !Boolean.parseBoolean(generate))
        throw new TargetException(
                "The " + DockerHandler.IMAGE_ID + " parameter was not specified, or enable image generation.");
}

From source file:co.propack.sample.payment.service.gateway.NullPaymentGatewayHostedWebResponseServiceImpl.java

@Override
public PaymentResponseDTO translateWebResponse(HttpServletRequest request) throws PaymentException {
    PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.THIRD_PARTY_ACCOUNT,
            NullPaymentGatewayType.NULL_HOSTED_GATEWAY)
                    .rawResponse(webResponsePrintService.printRequest(request));

    Map<String, String[]> paramMap = request.getParameterMap();

    Money amount = Money.ZERO;/*from ww  w .  j  a  va  2s .com*/
    if (paramMap.containsKey(NullPaymentGatewayConstants.TRANSACTION_AMT)) {
        String amt = paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT)[0];
        amount = new Money(amt);
    }

    responseDTO.successful(true)
            .completeCheckoutOnCallback(Boolean
                    .parseBoolean(paramMap.get(NullPaymentGatewayConstants.COMPLETE_CHECKOUT_ON_CALLBACK)[0]))
            .amount(amount).paymentTransactionType(PaymentTransactionType.UNCONFIRMED)
            .orderId(paramMap.get(NullPaymentGatewayConstants.ORDER_ID)[0])
            .responseMap(NullPaymentGatewayConstants.RESULT_MESSAGE,
                    paramMap.get(NullPaymentGatewayConstants.RESULT_MESSAGE)[0]);

    return responseDTO;
}

From source file:edu.harvard.i2b2.fhir.server.config.ServerConfigs.java

public ServerConfigs() {
    if (configC == null) {
        try {/*from w  w  w . ja  v  a  2 s  . c om*/
            configC = new CompositeConfiguration();

            configC.addConfiguration(new JNDIConfiguration());
            configC.addConfiguration(new SystemConfiguration());
            if (ServerConfigs.class.getResourceAsStream("/confidential.properties") != null) {
                logger.info("using confidential.properties");
                configC.addConfiguration(new PropertiesConfiguration("confidential.properties"));
            } else {
                logger.info("using application.properties");
                configC.addConfiguration(new PropertiesConfiguration("/application.properties"));

            }
            String jndiI2b2Url = configC.getString("java:global/i2b2Url");
            if (jndiI2b2Url != null) {
                configC.setProperty("i2b2Url", jndiI2b2Url);
            }
            logger.info("initialized: ava:global/i2b2Url=" + jndiI2b2Url);
            logger.info("initialized: i2b2Url=" + configC.getString("i2b2Url"));

            openAccess = Boolean.parseBoolean(GetString(ConfigParameter.openAccess));
            maxQueryThreads = Integer.parseInt(GetString(ConfigParameter.maxQueryThreads));

            logger.info("initialized:" + configC.toString());
            /*
             * logger.info("initialized:" + "\ni2b2Url:" + i2b2Url +
             * "\ndemoAccessToken:" + openAccessToken + "\n openAccess:" +
             * openAccess + "\nmaxQueryThreads" + maxQueryThreads +
             * "\ndemoConfidentialClientId:" + demoConfidentialClientId +
             * "\ndemoConfidentialClientSecret" +
             * demoConfidentialClientSecret);
             */
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
        }
    }
}

From source file:de.avanux.smartapplianceenabler.Application.java

private void startSemp() {
    FileHandler fileHandler = new FileHandler();
    Device2EM device2EM = fileHandler.load(Device2EM.class);
    SempController sempController = applicationContext.getBean(SempController.class);
    sempController.setDevice2EM(device2EM);

    boolean disableDiscovery = Boolean.parseBoolean(System.getProperty("sae.discovery.disable", "false"));
    if (disableDiscovery) {
        logger.warn("SEMP discovery disabled.");
    } else {//from  w  w w . j  a  va 2s.  c om
        logger.debug("Starting SEMP discovery ...");
        Thread discoveryThread = new Thread(new SempDiscovery());
        discoveryThread.start();
        logger.debug("... SEMP discovery started");
    }
}

From source file:com.l2jfree.Config.java

public static void load() {
    _log.info("loading login config");
    try {/*from www  .ja  va2  s  .c o  m*/
        L2Properties serverSettings = new L2Properties(LOGIN_CONFIGURATION_FILE);

        LOGIN_SERVER_HOSTNAME = serverSettings.getProperty("LoginServerHostname", "0.0.0.0");
        LOGIN_SERVER_PORT = Integer.parseInt(serverSettings.getProperty("LoginServerPort", "2106"));
        LOGIN_HOSTNAME = serverSettings.getProperty("LoginHostname", "127.0.0.1");
        LOGIN_PORT = Integer.parseInt(serverSettings.getProperty("LoginPort", "9014"));

        ACCEPT_NEW_GAMESERVER = Boolean.parseBoolean(serverSettings.getProperty("AcceptNewGameServer", "True"));

        LOGIN_TRY_BEFORE_BAN = Integer.parseInt(serverSettings.getProperty("LoginTryBeforeBan", "10"));
        LOGIN_BLOCK_AFTER_BAN = Integer.parseInt(serverSettings.getProperty("LoginBlockAfterBan", "600"));
        GM_MIN = Integer.parseInt(serverSettings.getProperty("GMMinLevel", "100"));

        DATABASE_DRIVER = serverSettings.getProperty("Driver", "com.mysql.jdbc.Driver");
        DATABASE_URL = serverSettings.getProperty("URL", "jdbc:mysql://localhost/l2jfree_ls");
        DATABASE_LOGIN = serverSettings.getProperty("Login", "root");
        DATABASE_PASSWORD = serverSettings.getProperty("Password", "");

        SHOW_LICENCE = Boolean.parseBoolean(serverSettings.getProperty("ShowLicence", "true"));

        AUTO_CREATE_ACCOUNTS = Boolean.parseBoolean(serverSettings.getProperty("AutoCreateAccounts", "True"));

        IP_UPDATE_TIME = Integer.parseInt(serverSettings.getProperty("IpUpdateTime", "0")) * 60 * 1000;

        FLOOD_PROTECTION = Boolean.parseBoolean(serverSettings.getProperty("EnableFloodProtection", "True"));
        FAST_CONNECTION_LIMIT = Integer.parseInt(serverSettings.getProperty("FastConnectionLimit", "15"));
        NORMAL_CONNECTION_TIME = Integer.parseInt(serverSettings.getProperty("NormalConnectionTime", "700"));
        FAST_CONNECTION_TIME = Integer.parseInt(serverSettings.getProperty("FastConnectionTime", "350"));
        MAX_CONNECTION_PER_IP = Integer.parseInt(serverSettings.getProperty("MaxConnectionPerIP", "50"));

        SECURITY_CARD_LOGIN = Boolean
                .parseBoolean(serverSettings.getProperty("UseSecurityCardToLogin", "False"));
        SECURITY_CARD_ID = serverSettings.getProperty("SecurityCardID", "l2jfree");
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("Failed to Load " + LOGIN_CONFIGURATION_FILE + " File.");
    }

    //      telnet
    try {
        L2Properties telnetSettings = new L2Properties(TELNET_FILE);

        IS_TELNET_ENABLED = Boolean.valueOf(telnetSettings.getProperty("EnableTelnet", "false"));
    } catch (Exception e) {
        e.printStackTrace();
        throw new Error("Failed to Load " + TELNET_FILE + " File.");
    }

    // Initialize config properties for DB
    // ----------------------------------
    initDBProperties();
}

From source file:com.jaspersoft.buildomatic.crypto.MasterPropertiesObfuscator.java

@Override
public void execute() throws BuildException {
    try {//from  w ww. j av  a  2 s  .  com
        //load master props
        PropertiesConfiguration config = new PropertiesConfiguration(new File(propsFile));
        PropertiesConfigurationLayout configLayout = config.getLayout();
        configLayout.setGlobalSeparator("=");

        Boolean encFlag = Boolean.parseBoolean(config.getString(ENCRYPT_FLAG));
        Boolean encDoneFlag = Boolean.parseBoolean(config.getString(ENCRYPT_DONE_FLAG));
        if (encFlag && !encDoneFlag) {
            String blockSzStr = config.getString(CRYPTO_BLOCK_SIZE_PARAM);
            EncryptionProperties encProps = new EncryptionProperties(
                    blockSzStr != null ? Integer.parseInt(blockSzStr) : null,
                    config.getString(CRYPTO_TRANSFORMATION_PARAM));
            List<Object> propsToEncryptList = config.getList(PROPS_TO_ENCRYPT_PARAM,
                    Arrays.<Object>asList(PROPS_TO_ENCRYPT_DEF));
            log("Encrypt " + StringUtils.join(propsToEncryptList.toArray(), ','), Project.MSG_INFO);
            log("Encryption block size: " + encProps.getBlockSize(), Project.MSG_DEBUG);
            log("Encryption mode: " + encProps.getCipherTransformation(), Project.MSG_DEBUG);

            //obtain Keystore Manager
            KeystoreManager.init(this.ksp);
            KeystoreManager ksManager = KeystoreManager.getInstance();

            //obtain key
            Key secret = ksManager.getBuildKey();

            Set<String> paramSet = new HashSet<String>(propsToEncryptList.size());
            for (Object prop : propsToEncryptList) {
                String propNameToEnc = prop.toString().trim();
                if (paramSet.contains(propNameToEnc))
                    continue; //was already encrypted once
                paramSet.add(propNameToEnc);

                String pVal = config.getString(propNameToEnc);
                if (pVal != null) {
                    if (EncryptionEngine.isEncrypted(pVal))
                        log("encrypt=true was set, but param " + propNameToEnc
                                + " was found already encrypted. " + " Skipping its encryption.",
                                Project.MSG_WARN);
                    else {
                        String ct = EncryptionEngine.encrypt(secret, pVal, encProps);
                        config.setProperty(propNameToEnc, ct);
                    }
                }
            }

            //set encryption to done
            config.clearProperty(ENCRYPT_FLAG);
            config.setProperty(ENCRYPT_DONE_FLAG, "true");

            //write master props back
            config.save();
        } else if (encDoneFlag) {
            log("The master properties have already been encrypted. To re-enable the encryption, "
                    + "make sure the passwords are in plain text, set master property "
                    + "encrypt to true and remove encrypt.done.", Project.MSG_INFO);
        }
    } catch (Exception e) {
        throw new BuildException(e, getLocation());
    }
}

From source file:net.hamnaberg.confluence.admin.CacheControlConfig.java

public static CacheControlConfig fromMap(Map<String, String> map) {
    if (map == null || map.isEmpty()) {
        return null;
    }/*from  w w w.j  a  v  a  2  s  . c  om*/
    return new CacheControlConfig(NumberUtils.toInt(map.get("ttl"), 300),
            Boolean.parseBoolean(map.get("transform")), Boolean.parseBoolean(map.get("revalidate")));
}

From source file:de.julielab.umlsfilter.rules.RewriteSyntacticInversion.java

public RewriteSyntacticInversion(final Map<String, String[]> parameters) {
    super(RULENAME);
    if (!parameters.containsKey(PARAMETER_COMPOUND) || (parameters.get(PARAMETER_COMPOUND).length != 1)
            || !parameters.containsKey(PARAMETER_DESTRUCTIVE)
            || (parameters.get(PARAMETER_DESTRUCTIVE).length != 1))
        throw new IllegalArgumentException();
    compound = Boolean.parseBoolean(parameters.get(PARAMETER_COMPOUND)[0]);
    destructive = Boolean.parseBoolean(parameters.get(PARAMETER_DESTRUCTIVE)[0]);
}