Example usage for java.lang Boolean toString

List of usage examples for java.lang Boolean toString

Introduction

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

Prototype

public static String toString(boolean b) 

Source Link

Document

Returns a String object representing the specified boolean.

Usage

From source file:net.big_oh.postoffice.PostOfficeServiceFactoryUnitTest.java

/**
 * Test method for/*from w w  w .  j a va  2 s . c  om*/
 * {@link net.big_oh.postoffice.PostOfficeServiceFactory#getInstance(java.util.Properties)}
 * .
 */
@Test
public void testGetInstanceProperties() {

    final boolean testAuthenticatewithTlsValue = true;
    final boolean testDebugValue = true;
    final boolean testTransportWithSslValue = true;
    final String testFromValue = "foo@bar.com";
    final String testHostValue = "smtp.someserver.net";
    final int testPortValue = 28374;
    final String testSmtpPasswordValue = "super secret";
    final String testSmtpUserNameValue = "jsmith";

    final Properties testProperties = new Properties();
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_AUTHENTICATE_WITH_TLS,
            Boolean.toString(testAuthenticatewithTlsValue));
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_DEBUG, Boolean.toString(testDebugValue));
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_TRANSPORT_WITH_SSL,
            Boolean.toString(testTransportWithSslValue));
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_FROM, testFromValue);
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_HOST, testHostValue);
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_PORT, Integer.toString(testPortValue));
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_SMTP_PASSWORD, testSmtpPasswordValue);
    testProperties.setProperty(PostOfficeServiceFactory.PROPERTY_KEY_SMTP_USER_NAME, testSmtpUserNameValue);

    final IPostOfficeService poService = PostOfficeServiceFactory.getInstance(testProperties);

    assertEquals(testAuthenticatewithTlsValue, poService.isAuthenticateWithTls());
    assertEquals(testDebugValue, poService.isDebug());
    assertEquals(testTransportWithSslValue, poService.isTransportWithSsl());
    assertEquals(testFromValue, poService.getSendersFromAddress());
    assertEquals(testSmtpPasswordValue, poService.getSmtpPassword());
    assertEquals(testHostValue, poService.getSmtpServerHost());
    assertEquals(testPortValue, poService.getSmtpServerPort());
    assertEquals(testSmtpUserNameValue, poService.getSmtpUserName());

}

From source file:com.ibm.jaql.lang.Jaql.java

public static void run(String filename, Reader reader, OutputAdapter outputAdapter, OutputAdapter logAdapter,
        boolean batchMode, String[] searchPath) throws Exception {
    Jaql engine = new Jaql(filename, reader);
    JaqlPrinter printerToClose = null;//from  w  w  w. ja  va  2s .c o  m
    if (outputAdapter == null) {
        FastPrintStream out = new FastPrintStream(System.out); // TODO: use system encoding? have jaql encoding parameter?
        engine.setJaqlPrinter(new StreamPrinter(out, batchMode));
    } else {
        printerToClose = new IODescriptorPrinter(outputAdapter.getWriter());
        engine.setJaqlPrinter(printerToClose);
    }

    engine.setProperty("stopOnException", Boolean.toString(batchMode));

    if (logAdapter != null) {
        engine.setExceptionHandler(new JsonWriterExceptionHandler(logAdapter.getWriter()));
    }

    if (searchPath != null) {
        engine.setModulePath(searchPath);
    }

    engine.run();

    if (printerToClose != null)
        printerToClose.close();
}

From source file:SendMessage.java

/**
 * Creates the main window's contents//from w  w  w .j a va 2 s  .c o m
 * 
 * @param parent the main window
 * @return Control
 */
protected Control createContents(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(5, true));

    // Create a big text box for the message text
    final Text text = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 5;
    text.setLayoutData(data);

    // Create the Confirm button
    Button confirm = new Button(composite, SWT.PUSH);
    confirm.setText("Confirm");
    confirm.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Error button
    Button error = new Button(composite, SWT.PUSH);
    error.setText("Error");
    error.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Information button
    Button information = new Button(composite, SWT.PUSH);
    information.setText("Information");
    information.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Question button
    Button question = new Button(composite, SWT.PUSH);
    question.setText("Question");
    question.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the Warning button
    Button warning = new Button(composite, SWT.PUSH);
    warning.setText("Warning");
    warning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // Create the label to display the return value
    final Label label = new Label(composite, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 5;
    label.setLayoutData(data);

    // Save ourselves some typing
    final Shell shell = parent.getShell();

    // Display a Confirmation dialog
    confirm.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean b = MessageDialog.openConfirm(shell, "Confirm", text.getText());
            label.setText("Returned " + Boolean.toString(b));
        }
    });

    // Display an Error dialog
    error.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openError(shell, "Error", text.getText());
            label.setText("Returned void");
        }
    });

    // Display an Information dialog
    information.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openInformation(shell, "Information", text.getText());
            label.setText("Returned void");
        }
    });

    // Display a Question dialog
    question.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            boolean b = MessageDialog.openQuestion(shell, "Question", text.getText());
            label.setText("Returned " + Boolean.toString(b));
        }
    });

    // Display a Warning dialog
    warning.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            MessageDialog.openWarning(shell, "Warning", text.getText());
            label.setText("Returned void");
        }
    });

    return composite;
}

From source file:com.iitb.cse.Utils.java

/**
 * genetated and returns the String in Json format. String contains
 * information about the action for sending AP settings file This string is
 * later sent to filtered devices.//w  w  w . j  a  v a2 s. c o m
 */
@SuppressWarnings("unchecked")
static String getControlFileJson(String message, String timeout, String logBgTraffic) {
    JSONObject obj = new JSONObject();
    obj.put(Constants.action, Constants.sendControlFile);
    obj.put(Constants.textFileFollow, Boolean.toString(true));
    obj.put(Constants.serverTime, Long.toString(Calendar.getInstance().getTimeInMillis()));
    obj.put(Constants.message, message);
    obj.put(Constants.timeout, timeout);
    obj.put("selectiveLog", logBgTraffic);
    String jsonString = obj.toJSONString();

    Date obj1 = new Date(Long.parseLong((String) obj.get(Constants.serverTime)));

    System.out.println(jsonString + obj1);
    return jsonString;
}

From source file:org.brushingbits.jnap.struts2.config.RestControllerConfigBuilder.java

@Inject
public RestControllerConfigBuilder(Configuration configuration, Container container,
        ObjectFactory objectFactory, @Inject("struts.convention.redirect.to.slash") String redirectToSlash,
        @Inject("struts.convention.default.parent.package") String defaultParentPackage,
        @Inject ServletContext servletContext) {

    super(configuration, container, objectFactory, redirectToSlash, defaultParentPackage);
    setAlwaysMapExecute(Boolean.toString(false));

    // finding the web application context
    try {//  w  w  w  . j a v a  2 s  .  co m
        this.applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    } catch (IllegalStateException e) {
        // TODO
    }

}

From source file:com.sawyer.advadapters.app.data.MovieItem.java

@Override
public String toString() {
    return (title == null ? "" : title) + " " + Integer.toString(year) + " " + Boolean.toString(isRecommended);
}

From source file:gobblin.runtime.listeners.EmailNotificationJobListener.java

@Override
public void onJobCancellation(JobContext jobContext) {
    JobState jobState = jobContext.getJobState();
    boolean notificationEmailEnabled = Boolean.valueOf(
            jobState.getProp(ConfigurationKeys.NOTIFICATION_EMAIL_ENABLED_KEY, Boolean.toString(false)));

    if (notificationEmailEnabled) {
        try {//  w  ww  .  java  2  s  .  c  om
            EmailUtils.sendJobCancellationEmail(jobState.getJobId(), jobState.toString(), jobState);
        } catch (EmailException ee) {
            LOGGER.error("Failed to send job cancellation notification email for job " + jobState.getJobId(),
                    ee);
        }
    }
}

From source file:com.legstar.cob2xsd.Cob2XsdIOTest.java

/**
 * Check that the XML Schema produced has the correct encoding from a file
 * standpoint.// www  .  j  a  v a 2  s  .  c  o  m
 */
@Test
public void testFileOutputEncoding() {
    try {
        configProps.put(Cob2XsdConfig.XSD_ENCODING, "UTF-8");
        configProps.put(Cob2XsdConfig.ADD_LEGSTAR_ANNOTATIONS, Boolean.toString(true));

        Cob2XsdIO cob2xsd = new Cob2XsdIO(new Cob2XsdConfig(configProps));
        File tempCobolFile = File.createTempFile("test", ".cob");
        tempCobolFile.deleteOnExit();

        FileUtils.write(tempCobolFile, "       01 A.\n           02 B PIC G(4) VALUE '?'.", "UTF8");
        File xmlSchema = cob2xsd.translate(tempCobolFile, "UTF8", tempDir, "http://www.mycompany.com/test",
                null);

        for (String line : FileUtils.readLines(xmlSchema, "UTF8")) {
            if (line.contains("cobolName=\"B\"")) {
                assertTrue(line.contains("value=\"?\""));
            }
        }
        xmlSchema.deleteOnExit();

    } catch (Exception e) {
        e.printStackTrace();
        fail();
    }

}

From source file:com.netflix.spinnaker.igor.jenkins.JenkinsCache.java

public void setLastBuild(String master, String job, int lastBuild, boolean building) {
    String key = makeKey(master, job);
    redisClientDelegate.withCommandsClient(c -> {
        c.hset(key, "lastBuildLabel", Integer.toString(lastBuild));
        c.hset(key, "lastBuildBuilding", Boolean.toString(building));
    });// w  ww  .j av a2 s  .  c  om
}

From source file:de.topicmapslab.majortom.server.http.web.AbstractMajorToMController.java

protected String getResultJSON(int code, String msg, String data, Meta meta) {
    StringBuilder b = new StringBuilder();

    b.append("{");

    b.append("\"code\" : ");
    b.append("\"");
    b.append(code);//from  ww w  .  j a v  a2  s . co m
    b.append("\"");

    b.append(", \"msg\" : ");
    b.append("\"");
    b.append(msg);
    b.append("\"");

    if (data != null) {
        b.append(", \"data\" : ");
        b.append(data);
    }

    if (meta != null) {
        b.append(", \"meta\" : {");
        b.append("\"duration\" : \"");
        b.append(Long.toString(meta.getDuration()));
        b.append("\", \"cached\" : \"");
        b.append(Boolean.toString(meta.isCached()));
        b.append("\", \"query\" : \"");
        b.append(StringEscapeUtils.escapeJavaScript(meta.getQuery()));
        b.append("\"}");
    }

    b.append("}");

    return b.toString();
}