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:com.cts.datapipeline.job.chunks.ReplacerAndSkipHeaderFooterLineItemProcessor.java

@Override
public String process(String line) throws Exception {

    //int count = (int) stepExecution.getExecutionContext().get("line.count");
    //System.out.println("TT Count--->" + count);
    int totalRows = -1;
    int currentLine = -1;
    if (stepExecution.getExecutionContext().containsKey("cFile")) {
        String cFile = stepExecution.getExecutionContext().getString("cFile");
        totalRows = (int) stepExecution.getExecutionContext().get(cFile);
        currentLine = stepExecution.getExecutionContext().getInt("currentLine");
        System.out.println(cFile + " " + totalRows);
    }/* w  w  w  . j a v a2s  .  com*/

    boolean isPatternBased = Boolean
            .parseBoolean((String) parameters.get(ReplacerInputParams.header_PatternBased.name()));
    boolean isRecordBased = Boolean
            .parseBoolean((String) parameters.get(ReplacerInputParams.header_RecordBased.name()));

    if (isPatternBased) {
        String header = (String) parameters.get(ReplacerInputParams.header.name());
        String footer = (String) parameters.get(ReplacerInputParams.footer.name());

        if (line.contains(header) || line.contains(footer)) {
            return null;
        } else {
            return line;
        }
    } else if (isRecordBased) {
        long headerRows = (long) parameters.get(ReplacerInputParams.headerRows.name());
        long footerRows = (long) parameters.get(ReplacerInputParams.footerRows.name());

        if (currentLine <= headerRows) {
            return null;
        }

        if (currentLine > totalRows - footerRows) {
            return null;
        }
    }

    String find = (String) parameters.get(ReplacerInputParams.find.name());
    String replace = (String) parameters.get(ReplacerInputParams.replace.name());
    return line.replace(find, replace);
}

From source file:com.github.kpavlov.commons.spring.annotations.BooleanValueCondition.java

@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    final Environment environment = context.getEnvironment();
    if (environment != null) {
        Map<String, Object> attributes = metadata.getAnnotationAttributes(Enabled.class.getName());
        if (attributes != null) {
            String expression = (String) attributes.get("value");
            final String value = environment.resolvePlaceholders(expression);
            return (Boolean.parseBoolean(value));
        }/*from  ww w.ja va2s.co  m*/
    }
    return true;
}

From source file:de.felixschulze.teamcity.xcode.ClangBuildProcess.java

@NotNull
public BuildFinishedStatus call() throws Exception {
    final BuildProgressLogger logger = build.getBuildLogger();

    logger.targetStarted("Clang analyze");

    final String projectFile = getParameter(XcodeConstants.PARAM_PROJECT, true);
    final String target = getParameter(XcodeConstants.PARAM_TARGETNAME, false);
    final String configuration = getParameter(XcodeConstants.PARAM_CONFIGURATION, false);
    final String sdk = getParameter(XcodeConstants.PARAM_SDK, false);

    final Boolean clean = Boolean.parseBoolean(getParameter(XcodeConstants.PARAM_CLEAN, false));

    if (clean) {// w w  w  . j a  v  a 2  s.c  o m
        logger.targetStarted("clean");
        File buildDirectory = new File(context.getWorkingDirectory(), "build");
        logger.message("Clean dir: " + buildDirectory.getAbsolutePath());
        FileUtils.deleteDirectory(buildDirectory);
        logger.targetFinished("clean");
    }

    final long startTime = System.currentTimeMillis();

    if (buildXcodeProjectWithClang(projectFile, target, configuration, sdk)) {
        final long endTime = System.currentTimeMillis();
        logger.message("Analyze finished (took " + ((endTime - startTime) / 1000) + " seconds)");
        logger.targetFinished("Clang analyze");
        return BuildFinishedStatus.FINISHED_SUCCESS;
    } else {
        logger.error("Error during Clang analyze.");
        return BuildFinishedStatus.FINISHED_FAILED;
    }
}

From source file:org.mitre.secretsharing.server.FormJoinServlet.java

@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    Writer w = new HtmlXSSWriter(resp.getWriter());

    try {//  w  w  w  .  ja v  a 2 s .  c om
        String parts = req.getParameter("parts");
        if (parts == null)
            throw new RuntimeException("No secret parts provided");

        boolean base64 = false;
        if (req.getParameter("base64") != null)
            base64 = Boolean.parseBoolean(req.getParameter("base64"));

        List<Part> partsBytes = new ArrayList<Part>();
        for (String s : parts.split("\n")) {
            s = s.trim();
            if (s.isEmpty())
                continue;
            try {
                partsBytes.add(PartFormats.parse(s));
            } catch (Exception e) {
                throw new RuntimeException("Corrupt key part \"" + s + "\""
                        + (e.getMessage() == null ? ": Improper encoding of secret parts"
                                : ": " + e.getMessage()),
                        e);
            }
        }

        Part[] p = partsBytes.toArray(new Part[0]);

        byte[] secret = p[0].join(Arrays.copyOfRange(p, 1, p.length));

        if (base64)
            w.write(Base64Variants.MIME.encode(secret));
        else
            w.write(new String(secret, "UTF-8"));
    } catch (Throwable t) {
        if (t.getMessage() != null)
            w.write("error: " + t.getMessage());
        else
            w.write("error");
    }
}

From source file:org.intalio.tempo.acm.server.ACMServer.java

public boolean isHTTPChunking() {
    return Boolean.parseBoolean(httpChunking);
}

From source file:com.otz.transport.config.EmailPluginConfiguration.java

@Bean
public EmailConfigParameters emailConfigParameters(Environment environment) {
    EmailConfigParameters emailConfigParameters = new EmailConfigParameters();

    String selectedEnvironment = environment.getActiveProfiles()[0];
    emailConfigParameters.setProtocol(// w w w.  ja va2s.co  m
            environment.getProperty(selectedEnvironment + ".services.email.mail.transport.protocol"));
    emailConfigParameters
            .setAccessKey(environment.getProperty(selectedEnvironment + ".services.email.access.key"));
    emailConfigParameters
            .setSecretKey(environment.getProperty(selectedEnvironment + ".services.email.secret.key"));
    emailConfigParameters.setHost(environment.getProperty(selectedEnvironment + ".services.email.host"));
    emailConfigParameters.setPort(
            Integer.parseInt(environment.getProperty(selectedEnvironment + ".services.email.mail.smtp.port")));
    emailConfigParameters.setSmtpAuth(Boolean
            .parseBoolean(environment.getProperty(selectedEnvironment + ".services.email.mail.smtp.auth")));
    emailConfigParameters.setSmtpSslEnable(Boolean.parseBoolean(
            environment.getProperty(selectedEnvironment + ".services.email.mail.smtp.ssl.enable")));

    return emailConfigParameters;
}

From source file:code.google.nfs.rpc.netty4.server.Netty4Server.java

public void start(int listenPort, final ExecutorService ignore) throws Exception {
    if (!startFlag.compareAndSet(false, true)) {
        return;// w ww .jav  a 2  s  .c om
    }
    bossGroup = new NioEventLoopGroup();
    ioGroup = new NioEventLoopGroup();
    businessGroup = new DefaultEventExecutorGroup(businessThreads);

    ServerBootstrap b = new ServerBootstrap();
    b.group(bossGroup, ioGroup).channel(NioServerSocketChannel.class)
            .childOption(ChannelOption.TCP_NODELAY,
                    Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.nodelay", "true")))
            .childOption(ChannelOption.SO_REUSEADDR,
                    Boolean.parseBoolean(System.getProperty("nfs.rpc.tcp.reuseaddress", "true")))
            .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ch.pipeline().addLast("decoder", new Netty4ProtocolDecoder());
                    ch.pipeline().addLast("encoder", new Netty4ProtocolEncoder());
                    ch.pipeline().addLast(businessGroup, "handler", new Netty4ServerHandler());
                }
            });

    b.bind(listenPort).sync();
    LOGGER.warn("Server started,listen at: " + listenPort + ", businessThreads is " + businessThreads);
}

From source file:admincommands.Rift.java

protected void handleRift(Player player, String... params) {
    if (params.length < 2 || !NumberUtils.isDigits(params[1])) {
        showHelp(player);/*from w w  w .  jav  a  2  s . c  o m*/
        return;
    }

    int id = NumberUtils.toInt(params[1]);
    boolean result;
    if (!isValidId(player, id)) {
        showHelp(player);
        return;
    }

    if (COMMAND_OPEN.equalsIgnoreCase(params[0])) {
        boolean guards = Boolean.parseBoolean(params[2]);
        result = RiftService.getInstance().openRifts(id, guards);
        PacketSendUtility.sendMessage(player, result ? "Rifts is opened!" : "Rifts was already opened");
    } else if (COMMAND_CLOSE.equalsIgnoreCase(params[0])) {
        result = RiftService.getInstance().closeRifts(id);
        PacketSendUtility.sendMessage(player, result ? "Rifts is closed!" : "Rifts was already closed");
    }
}

From source file:edu.wright.daselab.linkgen.ConfigurationParams.java

private static Object getPropertiesValue(String key, CONFIG_DATATYPE DT) {
    String val = config.getString(key);
    isConfigAvailable(key, val);
    switch (DT) {
    case STRING:/*  w  w  w .j a  v  a2 s  . c o m*/
        return val;
    case BOOLEAN:
        return Boolean.parseBoolean(val);
    case INT:
        return Integer.parseInt(val);
    case DOUBLE:
        return Double.parseDouble(val);
    case LONG:
        return Long.parseLong(val);
    default:
        return val;
    }
}

From source file:io.ehdev.json.validation.pojo.validation.JsonValidationBoolean.java

@Override
public boolean isEntryValid(String inputValue) {
    if (nullAcceptable && null == inputValue)
        return true;

    if (StringUtils.equalsIgnoreCase("null", inputValue))
        return true;
    if (StringUtils.isBlank(inputValue))
        return false;

    try {//ww w .j av a2 s.  com
        Boolean.parseBoolean(inputValue);
        return true;
    } catch (Exception e) {
        return false;
    }

}