Example usage for java.lang Boolean Boolean

List of usage examples for java.lang Boolean Boolean

Introduction

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

Prototype

@Deprecated(since = "9")
public Boolean(String s) 

Source Link

Document

Allocates a Boolean object representing the value true if the string argument is not null and is equal, ignoring case, to the string "true" .

Usage

From source file:gov.nih.nci.ncicb.tcga.dcc.annotations.webservice.AnnotationAddWS.java

/**
 * Add a new <code>DccAnnotation</code> in the database with the following values:
 *
 * @param diseaseAsString            the disease (can be the disease Id, name or description)
 * @param itemTypeAsString           the item type (can be the item type Id, name or description)
 * @param itemAsString               the item (one of the supported barcodes or an UUID)
 * @param annotationCategoryAsString the annotation category (can be the annotation category Id or name)
 * @param annotationNoteAsString     the annotation note
 * @param useStrictItemValidationAsString
 *                                   set to "true" to validate the annotation's item against the database values or "false" otherwise
 * @return the new <code>DccAnnotation</code>
 */// w w  w  .j  a  va 2s.  com
private DccAnnotation addAnnotation(final String diseaseAsString, final String itemTypeAsString,
        final String itemAsString, final String annotationCategoryAsString, final String annotationNoteAsString,
        final String useStrictItemValidationAsString) {

    DccAnnotation result = null;

    final boolean useStrictItemValidation = new Boolean(useStrictItemValidationAsString);

    // Retrieving Ids and validating inputs
    final Integer diseaseId = getDiseaseId(diseaseAsString);
    final DccAnnotationItemType dccAnnotationItemType = getDccAnnotationItemType(itemTypeAsString);
    final Long itemTypeId = dccAnnotationItemType.getItemTypeId();
    validateItem(itemAsString, dccAnnotationItemType.getItemTypeName());
    final Long annotationCategoryId = getAnnotationCategoryId(annotationCategoryAsString);
    validateAnnotationNoteAsString(annotationNoteAsString);

    // Note: if the web service user is not authenticated at that point, that is not a problem because as soon as the protected resource is called
    // (at the DAO level), Spring will display a login page and re-call the web service after the user authenticated
    // at which point the 'user' field will be properly set
    final String user = getSecurityUtil().getAuthenticatedPrincipalLoginName();

    try {
        result = annotationService.addAnnotation(diseaseId, itemTypeId, itemAsString, annotationCategoryId,
                annotationNoteAsString, user, useStrictItemValidation);
    } catch (final AnnotationQueries.AnnotationQueriesException e) {

        final String errorMessage = new StringBuilder("Error while adding new annotation: ")
                .append(e.getMessage()).toString();

        WebServiceUtil.logAndThrowWebApplicationException(log, errorMessage,
                HttpStatusCode.INTERNAL_SERVER_ERROR);
    } catch (final BeanException be) {
        final String errorMessage = new StringBuilder("Error while adding new annotation: ")
                .append(be.getMessage()).toString();

        WebServiceUtil.logAndThrowWebApplicationException(log, errorMessage,
                HttpStatusCode.INTERNAL_SERVER_ERROR);
    }

    return result;
}

From source file:edu.lternet.pasta.client.ResultSetUtility.java

/**
 * Transforms Solr search results XML to an HTML table.
 * /*from  w ww .  j  a v a  2 s .com*/
 * @param xslPath
 *            The path to the search results-set stylesheet.
 * 
 * @return The HTML table as a String object.
 */
public String xmlToHtmlTable(String xslPath) throws ParseException {
    String html = "";
    HashMap<String, String> parameterMap = new HashMap<String, String>();

    if (numFound > 0) {
        String tableHeaderHTML = composeTableHeaderHTML(this.showSavedData);

        String savedDataList = "";
        if (savedData != null) {
            savedDataList = savedData.getSavedDataList();
        }

        // Pass the docsPerPage value as a parameter to the XSLT
        parameterMap.put("start", start.toString());
        parameterMap.put("rows", new Integer(this.rows).toString());
        parameterMap.put("isSavedDataPage", new Boolean(this.isSavedDataPage).toString());
        parameterMap.put("savedDataList", savedDataList);
        parameterMap.put("showSavedData", new Boolean(this.showSavedData).toString());

        String tableRowsHTML = XSLTUtility.xmlToHtml(this.resultSet, xslPath, parameterMap);

        String tableFooterHTML = composeTableFooterHTML();

        StringBuilder sb = new StringBuilder("");
        sb.append(pageHeaderHTML);
        sb.append(pageBodyHTML);
        sb.append(tableHeaderHTML);
        sb.append(tableRowsHTML);
        sb.append(tableFooterHTML);
        sb.append(pageBodyHTML);
        html = sb.toString();
    } else {
        html = composeNoMatchesHTML(isSavedDataPage);
    }

    htmlTable = html;
    return html;
}

From source file:ambit2.data.qmrf.Qmrf_Xml_Pdf.java

public void xml2pdf(InputSource xml, OutputStream pdf) {

    try {//from   w  w  w  . j  a va2  s  .com
        Document document = new Document(PageSize.A4, 80, 50, 30, 65);

        PdfWriter writer = PdfWriter.getInstance(document, pdf);
        //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar);
        writer.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines);
        //PdfOutline root = writer.getDirectContent().getRootOutline();
        //new PdfOutline(root, new PDFAction("http://nina.acad.bg/qmrf"), "a bookmark");

        //writer.addFileAttachment(arg0, arg1, arg2, arg3)

        if (docBuilder == null)
            docBuilder = docBuilderFactory.newDocumentBuilder();
        docBuilder.setErrorHandler(new SimpleErrorHandler(getClass().getName()));
        QMRFSchemaResolver resolver = new QMRFSchemaResolver("http://ambit2.acad.bg/qmrf/qmrf.dtd", null);
        resolver.setIgnoreSystemID(true);
        docBuilder.setEntityResolver(resolver);

        org.w3c.dom.Document doc = null;
        try {
            doc = docBuilder.parse(xml);
        } catch (Exception x) {
            document.addCreationDate();
            document.addCreator(getClass().getName());
            document.open();
            document.add(new Paragraph(new Chunk(x.getMessage())));
            document.close();
            return;
        }

        document.addCreationDate();
        document.addCreator(getClass().getName());
        document.addKeywords(replaceTags(findNodeValue("keywords", doc)));
        document.addTitle(replaceTags(findNodeValue("QSAR_title", doc)));

        try {
            NodeList info = doc.getElementsByTagName("QMRF");
            for (int i = 0; i < info.getLength(); i++)
                document.addSubject(findAttributeValue("name", info.item(i)) + '.'
                        + findAttributeValue("version", info.item(i)));
        } catch (Exception x) {
            document.addSubject("QMRF");
        }
        try {
            document.addAuthor(listNodeAttributes(doc, "qmrf_authors", "author_ref", "author", att_author,
                    new Boolean(true)));
        } catch (Exception x) {
            document.addAuthor(getClass().getName());
        }

        document.open();
        PdfContentByte cb = writer.getDirectContent();

        try {
            headerTable(document, doc);
        } catch (Exception x) {
            document.add(new Paragraph(new Chunk(x.getMessage())));
            document.close();
            return;
        }

        PdfOutline root = writer.getDirectContent().getRootOutline();

        for (int i = 0; i < subchapters.length; i++)

            try {
                int align = Paragraph.ALIGN_LEFT;
                if (Mode.chapter == (Mode) subchapters[i][2]) {
                    document.add(new Paragraph(new Chunk('\n')));
                    PdfPTable table = new PdfPTable(1);

                    table.setWidthPercentage(100);

                    StringBuffer b = new StringBuffer();
                    b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc));
                    b.append('.');
                    b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc));

                    String bookmark = b.toString();

                    Chunk title = new Chunk(bookmark);
                    title.setLocalDestination(bookmark);
                    title.setFont(bfont);

                    PdfDestination destination = new PdfDestination(PdfDestination.FITH);
                    PdfOutline outline = new PdfOutline(root, destination, bookmark);

                    Paragraph p = new Paragraph(title);

                    PdfPCell cell = new PdfPCell(p);
                    cell.setBackgroundColor(chapterColor);
                    table.addCell(cell);
                    document.add(table);
                    float pos = writer.getVerticalPosition(false);
                    if (pos < 90)
                        document.newPage();
                } else {
                    Phrase phrase = new Phrase();
                    switch ((Mode) subchapters[i][2]) {
                    case title: {
                        StringBuffer b = new StringBuffer();
                        String cn = findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter,
                                doc);
                        if (cn == null)
                            break;

                        b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc));
                        b.append('.');
                        b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc));

                        String subchapterBookmark = b.toString();
                        b.append(':');

                        Chunk title = new Chunk(b.toString());
                        title.setLocalDestination(subchapterBookmark);
                        title.setFont(bfont);
                        phrase.add(title);

                        PdfDestination destination = new PdfDestination(PdfDestination.FITBH);
                        PdfOutline outline = new PdfOutline(root, destination, subchapterBookmark);

                        break;

                    }
                    case text: {
                        createNodePhrase(subchapters[i][0].toString(), doc, phrase, font);
                        align = Paragraph.ALIGN_JUSTIFIED;
                        break;
                    }
                    case answer: {
                        String a = findAnswer(subchapters[i][0].toString(), doc);
                        if (a != null) {
                            Chunk answer = new Chunk(a);
                            answer.setFont(font);
                            phrase.add(answer);
                        }
                        break;
                    }
                    case dataset: {
                        StringBuffer b = new StringBuffer();
                        b.append(findDataAvailable(subchapters[i][0].toString(), doc));
                        Chunk dataset = new Chunk(b.toString());
                        dataset.setFont(font);
                        phrase.add(dataset);
                        break;
                    }
                    case attachments: {
                        PdfPTable table = getAttachmentsAsTable(doc, "attachment_training_data");
                        if (table != null) {
                            phrase.add(new Paragraph("Training set(s)"));
                            phrase.add(table);
                        }
                        table = getAttachmentsAsTable(doc, "attachment_validation_data");
                        if (table != null) {
                            phrase.add(new Paragraph("Test set(s)"));
                            phrase.add(table);
                        }
                        table = getAttachmentsAsTable(doc, "attachment_documents");
                        if (table != null) {
                            phrase.add(new Paragraph("Supporting information"));
                            phrase.add(table);
                        }
                        break;
                        /*
                        StringBuffer b = new StringBuffer();
                        b.append("Training set(s)\n");
                         b.append(listAttachments(doc,"attachment_training_data"));
                         b.append("Test set(s)\n");
                         b.append(listAttachments(doc,"attachment_validation_data"));
                         b.append("Supporting information\n");
                         b.append(listAttachments(doc,"attachment_documents"));
                        Chunk attachments = new Chunk(b.toString());
                        attachments.setFont(font);
                        phrase.add(attachments);
                                
                        break;
                        */
                    }
                    case reference: {
                        try {
                            String value = listNodeAttributes(doc, subchapters[i][0].toString(),
                                    subchapters[i][3].toString(), subchapters[i][4].toString(),
                                    (String[]) subchapters[i][5], (Boolean) subchapters[i][6]);

                            Chunk reference = new Chunk(value);
                            reference.setFont(font);
                            align = Paragraph.ALIGN_JUSTIFIED;
                            phrase.add(reference);
                        } catch (Exception x) {

                        }
                        break;

                    }
                    }

                    Paragraph p = new Paragraph(phrase);
                    p.setAlignment(align);
                    document.add(p);
                    float pos = writer.getVerticalPosition(false);
                    /*
                    cb.moveTo(0, pos);
                    cb.lineTo(PageSize.A4.width(), pos);
                    cb.stroke();
                    */
                    if (pos < 90)
                        document.newPage();
                }
            } catch (Exception x) {
                x.printStackTrace();
            }

        document.close();

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println(e.getMessage());
    }
}

From source file:com.duroty.application.open.manager.OpenManager.java

/**
 * DOCUMENT ME!//from   w w w . j a  v a  2s . c o m
 *
 * @param hsession DOCUMENT ME!
 * @param msession DOCUMENT ME!
 * @param userObj DOCUMENT ME!
 *
 * @throws Exception DOCUMENT ME!
 * @throws MailException DOCUMENT ME!
 */
public void register(org.hibernate.Session hsession, Session msession, UserObj userObj,
        String defaultEmailDomain) throws Exception {
    try {
        Users users = new Users();
        users.setUseActive(false);
        users.setUseEmail(userObj.getEmail());
        users.setUseLanguage(userObj.getLanguage());
        users.setUseName(userObj.getName());
        users.setUsePassword(userObj.getPassword());
        users.setUseRegisterDate(new Date());
        users.setUseUsername(userObj.getUsername());

        hsession.save(users);
        hsession.flush();

        MailPreferences mailPreferences = new MailPreferences();
        mailPreferences.setUsers(users);
        mailPreferences.setMaprHtmlMessage(true);
        mailPreferences.setMaprMessagesByPage(20);
        mailPreferences.setMaprQuotaSize(0);
        mailPreferences.setMaprSignature("--\n" + userObj.getName());
        mailPreferences.setMaprSpamTolerance(100);
        mailPreferences.setMaprVacationActive(false);

        hsession.save(mailPreferences);
        hsession.flush();

        Identity identity = new Identity();
        identity.setIdeActive(true);
        identity.setIdeCode(RandomStringUtils.randomAlphanumeric(25));
        identity.setIdeDefault(true);
        identity.setIdeEmail(userObj.getUsername() + "@" + defaultEmailDomain);
        identity.setIdeName(userObj.getName());
        identity.setIdeReplyTo(userObj.getUsername() + "@" + defaultEmailDomain);
        identity.setUsers(users);

        hsession.save(identity);
        hsession.flush();

        InternetAddress from = new InternetAddress(userObj.getEmail(), userObj.getName());

        Criteria crit = hsession.createCriteria(Roles.class);
        crit.add(Restrictions.eq("rolName", "admin"));

        Roles role = (Roles) crit.uniqueResult();

        InternetAddress[] to = new InternetAddress[role.getUserRoles().size()];
        Iterator it = role.getUserRoles().iterator();
        int i = 0;

        while (it.hasNext()) {
            UserRole userRole = (UserRole) it.next();
            Users aux = userRole.getId().getUsers();
            Criteria criteria = hsession.createCriteria(Identity.class);
            criteria.add(Restrictions.eq("ideDefault", new Boolean(true)));
            criteria.add(Restrictions.eq("ideActive", new Boolean(true)));
            criteria.add(Restrictions.eq("users", aux));

            Identity id = (Identity) criteria.uniqueResult();

            to[i] = new InternetAddress(id.getIdeEmail(), id.getIdeName());
            i++;
        }

        notifyToAdmins(msession, from, to, userObj.getUsername() + " (" + userObj.getName() + ")");
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:com.marklogic.client.functionaltest.TestPartialUpdate.java

@Test
public void testPartialUpdateXML() throws IOException {
    System.out.println("Running testPartialUpdateXML");

    String[] filenames = { "constraint1.xml", "constraint2.xml", "constraint3.xml", "constraint4.xml",
            "constraint5.xml" };

    DatabaseClient client = DatabaseClientFactory.newClient("localhost", uberPort, dbName, "eval-user", "x",
            Authentication.DIGEST);//from  www .  j  a va 2 s.c  o m

    // write docs
    for (String filename : filenames) {
        writeDocumentUsingInputStreamHandle(client, filename, "/partial-update/", "XML");
    }

    String docId = "/partial-update/constraint1.xml";
    XMLDocumentManager docMgr = client.newXMLDocumentManager();
    DocumentPatchBuilder patchBldr = docMgr.newPatchBuilder();

    patchBldr.insertFragment("/root", Position.LAST_CHILD, "<modified>2013-03-21</modified>");
    DocumentPatchHandle patchHandle = patchBldr.build();
    docMgr.patch(docId, patchHandle);

    String content = docMgr.read(docId, new StringHandle()).get();

    System.out.println(content);

    assertTrue("fragment is not inserted", content.contains("<modified>2013-03-21</modified></root>"));

    // Check boolean replaces with XML documents.
    String xmlDocId = "/replaceBoolXml";

    String xmlStr1 = new String("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
    String xmlStr2 = new String(
            "<resources><screen name=\"screen_small\">true</screen><screen name=\"adjust_view_bounds\">false</screen></resources>");
    StringBuffer xmlStrbuf = new StringBuffer().append(xmlStr1).append(xmlStr2);

    StringHandle contentHandle = new StringHandle();
    contentHandle.set(xmlStrbuf.toString());

    // write the document content
    docMgr.write(xmlDocId, contentHandle);

    // Read it back to make sure the write worked.
    String contentXml = docMgr.read(xmlDocId, new StringHandle()).get();

    assertTrue("XML Replace fragment is not inserted", contentXml.contains(xmlStr2));

    DocumentPatchBuilder patchBldrBool = docMgr.newPatchBuilder();
    patchBldrBool.pathLanguage(PathLanguage.XPATH);

    // Flip the boolean values for both screen types
    patchBldrBool.replaceValue("/resources/screen[@name=\"screen_small\"]", false);
    patchBldrBool.replaceValue("/resources/screen[@name=\"adjust_view_bounds\"]", new Boolean(true));

    DocumentPatchHandle patchHandleBool = patchBldrBool.build();
    docMgr.patch(xmlDocId, patchHandleBool);

    String content1 = docMgr.read(xmlDocId, new StringHandle()).get();
    System.out.println(content1);
    String xmlStr2Mod = new String(
            "<resources><screen name=\"screen_small\">false</screen><screen name=\"adjust_view_bounds\">true</screen></resources>");

    assertTrue("XML fragment is not replaced", content1.contains(xmlStr2Mod));
    // release client
    client.release();
}

From source file:com.alkacon.opencms.survey.CmsFormReportingBean.java

/**
 * Returns a lazy initialized map that provides if the user can see the detail page or not 
 * for each group used as a key in the Map.<p> 
 * //from  w w w  . java  2 s. co  m
 * @return a lazy initialized map
 */
public Map getShowDetail() {

    if (m_group == null) {
        m_group = LazyMap.decorate(new HashMap(), new Transformer() {

            /**
             * @see org.apache.commons.collections.Transformer#transform(java.lang.Object)
             */
            public Object transform(Object input) {

                String value = String.valueOf(input);
                if (CmsStringUtil.isEmptyOrWhitespaceOnly(value)) {
                    return new Boolean(true);
                }
                try {
                    CmsUser user = getCmsObject().getRequestContext().currentUser();
                    List list = getCmsObject().getGroupsOfUser(user.getName(), false);
                    CmsGroup group;
                    for (int i = 0; i < list.size(); i++) {
                        group = (CmsGroup) list.get(i);
                        if (group.getName().equals(value)) {
                            return new Boolean(true);
                        }
                    }
                } catch (Exception e) {
                    // NOOP
                }

                return new Boolean(false);
            }
        });
    }
    return m_group;
}

From source file:CSVXMLReader.java

public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
    this.featureMap.put(name, new Boolean(value));
}

From source file:ambit.data.qmrf.Qmrf_Xml_Pdf.java

public void xml2pdf(InputSource xml, OutputStream pdf) {

    try {//w w w  .j a  v  a2  s.com
        Document document = new Document(PageSize.A4, 80, 50, 30, 65);

        PdfWriter writer = PdfWriter.getInstance(document, pdf);
        //writer.setViewerPreferences(PdfWriter.HideMenubar| PdfWriter.HideToolbar);
        writer.setViewerPreferences(PdfWriter.PageModeUseThumbs | PdfWriter.PageModeUseOutlines);
        //PdfOutline root = writer.getDirectContent().getRootOutline();
        //new PdfOutline(root, new PDFAction("http://nina.acad.bg/qmrf"), "a bookmark");

        //writer.addFileAttachment(arg0, arg1, arg2, arg3)

        if (docBuilder == null)
            docBuilder = docBuilderFactory.newDocumentBuilder();
        docBuilder.setErrorHandler(new SimpleErrorHandler(getClass().getName()));
        QMRFSchemaResolver resolver = new QMRFSchemaResolver("http://ambit.acad.bg/qmrf/qmrf.dtd", null);
        resolver.setIgnoreSystemID(true);
        docBuilder.setEntityResolver(resolver);

        org.w3c.dom.Document doc = null;
        try {
            doc = docBuilder.parse(xml);
        } catch (Exception x) {
            document.addCreationDate();
            document.addCreator(getClass().getName());
            document.open();
            document.add(new Paragraph(new Chunk(x.getMessage())));
            document.close();
            return;
        }

        document.addCreationDate();
        document.addCreator(getClass().getName());
        document.addKeywords(replaceTags(findNodeValue("keywords", doc)));
        document.addTitle(replaceTags(findNodeValue("QSAR_title", doc)));

        try {
            NodeList info = doc.getElementsByTagName("QMRF");
            for (int i = 0; i < info.getLength(); i++)
                document.addSubject(findAttributeValue("name", info.item(i)) + '.'
                        + findAttributeValue("version", info.item(i)));
        } catch (Exception x) {
            document.addSubject("QMRF");
        }
        try {
            document.addAuthor(listNodeAttributes(doc, "qmrf_authors", "author_ref", "author", att_author,
                    new Boolean(true)));
        } catch (Exception x) {
            document.addAuthor(getClass().getName());
        }

        document.open();
        PdfContentByte cb = writer.getDirectContent();

        try {
            headerTable(document, doc);
        } catch (Exception x) {
            document.add(new Paragraph(new Chunk(x.getMessage())));
            document.close();
            return;
        }

        PdfOutline root = writer.getDirectContent().getRootOutline();

        for (int i = 0; i < subchapters.length; i++)

            try {
                int align = Paragraph.ALIGN_LEFT;
                if (Mode.chapter == (Mode) subchapters[i][2]) {
                    document.add(new Paragraph(new Chunk('\n')));
                    PdfPTable table = new PdfPTable(1);

                    table.setWidthPercentage(100);

                    StringBuffer b = new StringBuffer();
                    b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc));
                    b.append('.');
                    b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc));

                    String bookmark = b.toString();

                    Chunk title = new Chunk(bookmark);
                    title.setLocalDestination(bookmark);
                    title.setFont(bfont);

                    PdfDestination destination = new PdfDestination(PdfDestination.FITH);
                    PdfOutline outline = new PdfOutline(root, destination, bookmark);

                    Paragraph p = new Paragraph(title);

                    PdfPCell cell = new PdfPCell(p);
                    cell.setBackgroundColor(chapterColor);
                    table.addCell(cell);
                    document.add(table);
                    float pos = writer.getVerticalPosition(false);
                    if (pos < 90)
                        document.newPage();
                } else {
                    Phrase phrase = new Phrase();
                    switch ((Mode) subchapters[i][2]) {
                    case title: {
                        StringBuffer b = new StringBuffer();
                        String cn = findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter,
                                doc);
                        if (cn == null)
                            break;

                        b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_chapter, doc));
                        b.append('.');
                        b.append(findAttributeValue(subchapters[i][0].toString(), xml_attribute_name, doc));

                        String subchapterBookmark = b.toString();
                        b.append(':');

                        Chunk title = new Chunk(b.toString());
                        title.setLocalDestination(subchapterBookmark);
                        title.setFont(bfont);
                        phrase.add(title);

                        PdfDestination destination = new PdfDestination(PdfDestination.FITBH);
                        PdfOutline outline = new PdfOutline(root, destination, subchapterBookmark);

                        break;

                    }
                    case text: {
                        createNodePhrase(subchapters[i][0].toString(), doc, phrase, font);
                        align = Paragraph.ALIGN_JUSTIFIED;
                        break;
                    }
                    case answer: {
                        String a = findAnswer(subchapters[i][0].toString(), doc);
                        if (a != null) {
                            Chunk answer = new Chunk(a);
                            answer.setFont(font);
                            phrase.add(answer);
                        }
                        break;
                    }
                    case dataset: {
                        StringBuffer b = new StringBuffer();
                        b.append(findDataAvailable(subchapters[i][0].toString(), doc));
                        Chunk dataset = new Chunk(b.toString());
                        dataset.setFont(font);
                        phrase.add(dataset);
                        break;
                    }
                    case attachments: {
                        PdfPTable table = getAttachmentsAsTable(doc, "attachment_training_data");
                        if (table != null) {
                            phrase.add(new Paragraph("Training set(s)"));
                            phrase.add(table);
                        }
                        table = getAttachmentsAsTable(doc, "attachment_validation_data");
                        if (table != null) {
                            phrase.add(new Paragraph("Test set(s)"));
                            phrase.add(table);
                        }
                        table = getAttachmentsAsTable(doc, "attachment_documents");
                        if (table != null) {
                            phrase.add(new Paragraph("Supporting information"));
                            phrase.add(table);
                        }
                        break;
                        /*
                        StringBuffer b = new StringBuffer();
                        b.append("Training set(s)\n");
                         b.append(listAttachments(doc,"attachment_training_data"));
                         b.append("Test set(s)\n");
                         b.append(listAttachments(doc,"attachment_validation_data"));
                         b.append("Supporting information\n");
                         b.append(listAttachments(doc,"attachment_documents"));
                        Chunk attachments = new Chunk(b.toString());
                        attachments.setFont(font);
                        phrase.add(attachments);
                                
                        break;
                        */
                    }
                    case reference: {
                        try {
                            String value = listNodeAttributes(doc, subchapters[i][0].toString(),
                                    subchapters[i][3].toString(), subchapters[i][4].toString(),
                                    (String[]) subchapters[i][5], (Boolean) subchapters[i][6]);

                            Chunk reference = new Chunk(value);
                            reference.setFont(font);
                            align = Paragraph.ALIGN_JUSTIFIED;
                            phrase.add(reference);
                        } catch (Exception x) {

                        }
                        break;

                    }
                    }

                    Paragraph p = new Paragraph(phrase);
                    p.setAlignment(align);
                    document.add(p);
                    float pos = writer.getVerticalPosition(false);
                    /*
                    cb.moveTo(0, pos);
                    cb.lineTo(PageSize.A4.width(), pos);
                    cb.stroke();
                    */
                    if (pos < 90)
                        document.newPage();
                }
            } catch (Exception x) {
                x.printStackTrace();
            }

        document.close();

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println(e.getMessage());
    }
}

From source file:biomine.bmvis2.pipeline.sources.QueryGraphSource.java

@Override
public JSONObject toJSON() {
    JSONObject ret = new JSONObject();
    JSONArray queryArr = new JSONArray();
    queryArr.addAll(query);//  w ww . ja v  a2  s  . c o m
    ret.put("query", queryArr);
    ret.put("neighborhood", new Boolean(neighborhood));
    return ret;
}

From source file:com.aurel.track.fieldType.runtime.system.check.SystemAccessLevelRT.java

/**
 * Parses the string value into the corresponding object value
 * @param isoStrValue/*from  www.j a  va  2  s.  co  m*/
 * @return
 */
@Override
public Object parseISOValue(Object isoStrValue) {
    if (isoStrValue == null) {
        return TWorkItemBean.ACCESS_LEVEL_PUBLIC;
    } else {
        Boolean accessLevel = new Boolean(isoStrValue.toString());
        if (accessLevel.booleanValue()) {
            return TWorkItemBean.ACCESS_LEVEL_PRIVATE;
        }
        return TWorkItemBean.ACCESS_LEVEL_PUBLIC;
    }
}