Example usage for java.lang String compareToIgnoreCase

List of usage examples for java.lang String compareToIgnoreCase

Introduction

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

Prototype

public int compareToIgnoreCase(String str) 

Source Link

Document

Compares two strings lexicographically, ignoring case differences.

Usage

From source file:gov.nih.nci.evs.browser.utils.CodeSearchUtils.java

public CodedNodeSet getCodedNodeSetContainingSourceCode(String scheme, String version, String sourceAbbr,
        String code, int maxToReturn, boolean searchInactive) {

    if (sourceAbbr == null || code == null) {
        return null;
    }/*  w w  w  . j a v a  2s  . co m*/

    LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService();
    CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
    versionOrTag.setVersion(version);

    if (lbSvc == null) {
        _logger.warn("lbSvc = null");
        return null;
    }

    LocalNameList contextList = null;
    NameAndValueList qualifierList = null;

    Vector<String> v = null;
    if (code.compareTo("") != 0) {
        qualifierList = new NameAndValueList();
        NameAndValue nv = new NameAndValue();
        nv.setName("source-code");
        nv.setContent(code);
        qualifierList.addNameAndValue(nv);
    }

    LocalNameList propertyLnL = null;
    // sourceLnL
    Vector<String> w2 = new Vector<String>();
    w2.add(sourceAbbr);
    LocalNameList sourceLnL = vector2LocalNameList(w2);
    if (sourceAbbr.compareTo("*") == 0 || sourceAbbr.compareToIgnoreCase("ALL") == 0) {
        sourceLnL = null;
    }

    SortOptionList sortCriteria = null;// Constructors.createSortOptionList(new
                                       // String[]{"matchToQuery", "code"});
    CodedNodeSet cns = null;
    try {
        cns = getNodeSet(lbSvc, scheme, versionOrTag);
        if (cns == null) {
            _logger.warn("lbSvc.getCodingSchemeConceptsd returns null");
            return null;
        }
        CodedNodeSet.PropertyType[] types = new PropertyType[] { PropertyType.PRESENTATION };

        cns = cns.restrictToProperties(propertyLnL, types, sourceLnL, contextList, qualifierList);

        if (cns != null) {
            boolean activeOnly = !searchInactive;
            cns = restrictToActiveStatus(cns, activeOnly);
            if (cns == null) {
                return null;
            }
        }
    } catch (Exception e) {
        // getLogger().error("ERROR: Exception in findConceptWithSourceCodeMatching.");
        e.printStackTrace();
        return null;
    }
    return cns;
}

From source file:org.jboss.dashboard.commons.text.StringUtil.java

/**
 * Returns a String who replace Strings include into <I>str</I>,
 * which are into delimiters and known in <I>in</I>,
 * to corresponding String from <I>out</I>.
 * <br>/*  www. j a v a 2 s  .c  o m*/
 * If in and out aren't of the same size, the string is returned
 * unchanged.
 * <br>
 * beginDelim and endDelim can't be the same. If they are, a
 * IllegalArgumentException is throw.
 *
 * @param str        String to manipulate
 * @param in         array of strings to find
 * @param out        array of strings to replace
 * @param beginDelim String who delimiters the begin of the substrings
 *                   into <I>str</I>
 * @param endDelim   String who delimiters the end of the substrings
 *                   into <I>str</I>
 * @return the new string
 * @throws IllegalArgumentException if beginDelim and endDelim are equal
 */
public static String replaceAll(String str, String[] in, String[] out, String beginDelim, String endDelim) {

    if (in.length != out.length) {
        return str;
    }

    if (beginDelim.equals(endDelim)) {
        throw new IllegalArgumentException("beginDelim and endDelim are equals: " + beginDelim);
    }

    StringBuffer str_ret = new StringBuffer();
    String sFound;
    String sOut;
    String lastSegment;
    int lastIndex = 0;
    int indexBegin = str.indexOf(beginDelim);
    int indexEnd = -1;
    int indexIn = -1;
    int index = -1;
    boolean found = false;
    int countIn = in.length;

    while (indexBegin > -1) {
        indexEnd = str.indexOf(endDelim, indexBegin);
        if (beginDelim.equals(endDelim) && beginDelim.equals("")) {
            indexEnd++;
        } else {
            index = str.indexOf(beginDelim, indexBegin + beginDelim.length());
            while (index > -1 && index < indexEnd) {
                indexBegin = index;
                index = str.indexOf(beginDelim, indexBegin + beginDelim.length());
            }
        }
        sFound = str.substring(indexBegin + beginDelim.length(), indexEnd);
        lastSegment = str.substring(lastIndex, indexBegin);
        sOut = "";
        found = false;
        indexIn = 0;
        while (!found && indexIn < countIn) {
            if (sFound.compareToIgnoreCase(in[indexIn]) == 0) {
                sOut = indentParagraph(lastSegment, out[indexIn]);
                found = true;
            }
            indexIn++;
        }
        //dejamos el tag para que se note el error de tag no existente
        if (!found) {
            sOut = beginDelim + sFound + endDelim;
        }
        //if no word to replace and after tag to replace you have a CR ignore
        if (found && sOut.compareTo("") == 0) {
            index = lastSegment.lastIndexOf('\n');
            if (index > -1 && lastSegment.substring(index + 1).trim().compareTo("") == 0) {
                lastSegment = lastSegment.substring(0, index);
            }
        }

        str_ret.append(lastSegment).append(sOut);
        lastIndex = indexEnd + endDelim.length();
        indexBegin = str.indexOf(beginDelim, lastIndex);
    }
    if (lastIndex < str.length()) {
        str_ret.append(str.substring(lastIndex, str.length()));
    }

    return str_ret.toString();
}

From source file:com.orange.oidc.tim.service.SIMStorage.java

public boolean delete_tokens(String server_url, String client_id, String scope) {

    boolean bStatus = false;
    Channel channel = null;//w  ww .  ja  v  a2  s .co  m
    try {
        channel = initChannelToSIM();
        if (channel == null) {
            Logd(TAG, "//delete_tokens end : channel error");
            return bStatus;
        }

        int response = search_tokens(channel, server_url, client_id, scope, true);
        if (response != 0x9000) {
            // error
            Logd(TAG, "//delete_tokens error search : " + toHexa(response));
            channel.close();
            return bStatus;
        }

        byte[] respApdu = channel.transmit(new byte[] { TIM_CLA, STORE_DATA, DELETE_TOKENS_KEY, 0x00, 0x00 });
        String sw1sw2 = "";
        if (respApdu != null && respApdu.length > 2)
            sw1sw2 = toHexa(respApdu[respApdu.length - 2], respApdu[respApdu.length - 1]);
        else
            sw1sw2 = KryptoUtils.bytesToHex(respApdu);
        if (sw1sw2.compareToIgnoreCase("9000") == 0)
            bStatus = true;

    } catch (Exception e) {
        Log.e(TAG, "read_tokens Error occured:", e);
    }

    // close channel
    if (channel != null && !channel.isClosed()) {
        channel.close();
    }

    return bStatus;
}

From source file:com.bright.assetbank.application.servlet.ApplicationActionServlet.java

public void init()/*     */ throws ServletException
/*     */ {//  www  . ja v  a 2s  .  c o  m
    /*     */ try
    /*     */ {
        /*  82 */ setupGlobalSettings();
        /*     */ }
    /*     */ catch (Throwable te)
    /*     */ {
        /*  87 */ System.out.println("ApplicationActionServlet.init: Bn2Exception: " + te.getMessage());
        /*     */ }
    /*     */
    /*  91 */ String[] noStoreActions = getServletConfig().getInitParameter("noStoreGetActions")
            .split("[,\t\n ]+");
    /*  92 */ this.m_noStoreActionSet = new HashSet((int) ((noStoreActions.length + 1) * 1.5D));
    /*  93 */ this.m_noStoreActionSet.addAll(Arrays.asList(noStoreActions));
    /*     */
    /*  95 */ boolean bSuspendLicenseValidation = false;
    /*  96 */ boolean bLicenseValid = false;
    /*  97 */ boolean bLicenseException = false;
    /*  98 */ int iLicenseDaysLeft = 0;
    /*  99 */ String sLicenseDate = "";
    /* 100 */ String sLicenseType = "";
    /* 101 */ boolean bLicenseNeverExpires = false;
    /* 102 */ boolean bLicenseIPUnbound = false;
    /* 103 */ boolean bLicenseWebappUnbound = false;
    /*     */
    /* 106 */ String sLicenseIPs = "";
    /*     */
    /* 109 */ String sLicenseWebapps = "";
    /*     */ try
    /*     */ {
        /* 114 */ LicenseManager licManager = LicenseManager.getInstance();
        /* 115 */ bLicenseValid = licManager.isValid();
        /* 116 */ iLicenseDaysLeft = licManager.daysLeft();
        /* 117 */ sLicenseIPs = licManager.getFeature("IP");
        /* 118 */ sLicenseWebapps = licManager.getFeature("Webapp");
        /* 119 */ sLicenseDate = licManager.getFeature("Expiration");
        /* 120 */ sLicenseType = licManager.getFeature("Type");
        /*     */ }
    /*     */ catch (Throwable e)
    /*     */ {
        /* 124 */ bLicenseValid = false;
        /* 125 */ bLicenseException = true;
        /*     */ }
    /*     */
    /* 128 */ bLicenseNeverExpires = (iLicenseDaysLeft == 0) && ((sLicenseDate == null)
            || (sLicenseDate.length() == 0) || (sLicenseDate.compareToIgnoreCase("never") == 0));
    /* 129 */ bLicenseIPUnbound = (sLicenseIPs == null) || (sLicenseIPs.length() == 0);
    /* 130 */ bLicenseWebappUnbound = (sLicenseWebapps == null) || (sLicenseWebapps.length() == 0);
    /*     */
    /* 133 */ boolean bIPValid = false;
    /* 134 */ boolean bIPException = false;
    /* 135 */ String sLocalIPs = "";
    /* 136 */ Vector vecLocalIPs = new Vector();
    /* 137 */ String sValidIP = "";
    /*     */
    /* 139 */ if (bLicenseIPUnbound)
    /*     */ {
        /* 141 */ bIPValid = true;
        /*     */ }
    /*     */ else
    /*     */ {
        /*     */ try
        /*     */ {
            /* 148 */ Vector vecLicensedIPs = StringUtil.convertToVector(sLicenseIPs, ",");
            /*     */
            /* 151 */ InetAddress ipLocalhost = InetAddress.getLocalHost();
            /* 152 */ InetAddress[] arrAddress = InetAddress.getAllByName(ipLocalhost.getHostName());
            /* 153 */ for (int i = 0; i < arrAddress.length; i++)
            /*     */ {
                /* 158 */ String sIP = arrAddress[i].getHostAddress().trim();
                /* 159 */ vecLocalIPs.add(sIP);
                /* 160 */ sLocalIPs = sLocalIPs + sIP + ", ";
                /*     */ }
            /*     */
            /* 164 */ Iterator it = vecLicensedIPs.iterator();
            /* 165 */ while (it.hasNext())
            /*     */ {
                /* 167 */ String sLicensedIP = (String) it.next();
                /*     */
                /* 169 */ Iterator itLocal = vecLocalIPs.iterator();
                /* 170 */ while (itLocal.hasNext())
                /*     */ {
                    /* 172 */ String sLocalIP = (String) itLocal.next();
                    /*     */
                    /* 174 */ if (sLicensedIP.trim().compareToIgnoreCase(sLocalIP) == 0)
                    /*     */ {
                        /* 176 */ bIPValid = true;
                        /* 177 */ sValidIP = sLocalIP;
                        /* 178 */ break;
                        /*     */ }
                    /*     */ }
                /*     */
                /* 182 */ if (bIPValid)
                /*     */ {
                    /*     */ break;
                    /*     */ }
                /*     */ }
            /*     */
            /*     */ }
        /*     */ catch (UnknownHostException e)
        /*     */ {
            /* 191 */ bIPValid = false;
            /* 192 */ bIPException = true;
            /*     */ }
        /*     */
        /*     */ }
    /*     */
    /* 197 */ boolean bWebappValid = false;
    /* 198 */ String sLocalWebapp = "";
    /*     */
    /* 200 */ if (bLicenseWebappUnbound)
    /*     */ {
        /* 202 */ bWebappValid = true;
        /*     */ }
    /*     */ else
    /*     */ {
        /* 207 */ Vector vecLicensedWebapps = StringUtil.convertToVector(sLicenseWebapps, ",");
        /*     */
        /* 210 */ String sApplicationPath = getServletContext().getRealPath("");
        /* 211 */ File dir = new File(sApplicationPath);
        /* 212 */ sLocalWebapp = dir.getName();
        /*     */
        /* 215 */ Iterator it = vecLicensedWebapps.iterator();
        /* 216 */ while (it.hasNext())
        /*     */ {
            /* 218 */ String sLicensedWebapp = (String) it.next();
            /*     */
            /* 220 */ if (sLicensedWebapp.trim().compareToIgnoreCase(sLocalWebapp) == 0)
            /*     */ {
                /* 222 */ bWebappValid = true;
                /* 223 */ break;
                /*     */ }
            /*     */ }
        /*     */
        /*     */ }
    /*     */
    /* 229 */ boolean bTypeValid = false;
    /*     */
    /* 231 */ bTypeValid = checkLicenseType(sLicenseType);
    /*     */
    /* 234 */ if (((!bLicenseValid) || (!bIPValid) || (!bWebappValid) || (!bTypeValid))
            && (!bSuspendLicenseValidation))
    /*     */ {
        /* 236 */ GlobalApplication.getInstance().suspendWebsite();
        /*     */ }
    /*     */
    /* 240 */ if (AssetBankSettings.isApplicationUpdateInProgress())
    /*     */ {
        /* 243 */ GlobalApplication.getInstance().setSkipStartups(true);
        /*     */ }
    /*     */
    /* 247 */ if (AssetBankSettings.getRequiresEndorsedLibs())
    /*     */ {
        /* 249 */ addEndorsedLibToSystemProperties();
        /*     */ }
    /*     */
    /* 253 */ super.init();
    /*     */
    /* 256 */ if (!bLicenseValid)
    /*     */ {
        /* 258 */ GlobalApplication.getInstance().getLogger()
                .error("ApplicationActionServlet.init: License validation failed.");
        /*     */ }
    /* 260 */ if (bLicenseException)
    /*     */ {
        /* 262 */ GlobalApplication.getInstance().getLogger().error(
                "ApplicationActionServlet.init: Error in license validation is most likely due to missing license file. Check under WEB-INF/classes.");
        /*     */ }
    /* 264 */ if (!bTypeValid)
    /*     */ {
        /* 266 */ GlobalApplication.getInstance().getLogger().info(
                "ApplicationActionServlet.init: License validation failed: License is of the incorrect type");
        /*     */ }
    /* 268 */ if (bIPValid)
    /*     */ {
        /* 270 */ GlobalApplication.getInstance().getLogger()
                .info("ApplicationActionServlet.init: License valid for IP address: " + sValidIP);
        /*     */ }
    /*     */ else
    /*     */ {
        /* 274 */ GlobalApplication.getInstance().getLogger()
                .error("ApplicationActionServlet.init: License validation failed: IP address " + sLocalIPs
                        + " not in permitted range: " + sLicenseIPs);
        /*     */ }
    /* 276 */ if (bIPException)
    /*     */ {
        /* 278 */ GlobalApplication.getInstance().getLogger()
                .error("ApplicationActionServlet.init: Error in reading IP address of local host server.");
        /*     */ }
    /* 280 */ if (bWebappValid)
    /*     */ {
        /* 282 */ GlobalApplication.getInstance().getLogger()
                .info("ApplicationActionServlet.init: License valid for webapp: " + sLocalWebapp);
        /*     */ }
    /*     */ else
    /*     */ {
        /* 286 */ GlobalApplication.getInstance().getLogger()
                .error("ApplicationActionServlet.init: License validation failed: webapp " + sLocalWebapp
                        + " not in permitted range: " + sLicenseWebapps);
        /*     */ }
    /*     */
    /* 289 */ if ((bLicenseNeverExpires) && (bLicenseValid))
    /*     */ {
        /* 291 */ GlobalApplication.getInstance().getLogger()
                .info("ApplicationActionServlet.init: License never expires.");
        /*     */ }
    /*     */ else
    /*     */ {
        /* 295 */ if (iLicenseDaysLeft < 0)
        /*     */ {
            /* 297 */ GlobalApplication.getInstance().getLogger()
                    .error("ApplicationActionServlet.init: License expired!");
            /*     */ }
        /* 299 */ GlobalApplication.getInstance().getLogger()
                .info("ApplicationActionServlet.init: License days left: " + iLicenseDaysLeft);
        /*     */ }
    /*     */
    /* 303 */ GlobalApplication.getInstance().getLogger().info(
            "ApplicationActionServlet.init: Application Version: " + AssetBankSettings.getApplicationVersion());
    /*     */
    /* 307 */ ABUserProfile.setUserProfileFactory(new ABUserProfileFactory());
    /*     */
    /* 312 */ HTTPUtil.setProxySettings();
    /*     */ }

From source file:gov.nih.nci.evs.browser.utils.CodeSearchUtils.java

public ResolvedConceptReferencesIterator findConceptWithSourceCodeMatching(String scheme, String version,
        String sourceAbbr, String code, int maxToReturn, boolean searchInactive) {
    if (sourceAbbr == null || code == null)
        return null;
    ResolvedConceptReferencesIterator matchIterator = null;

    LexBIGService lbSvc = new RemoteServerUtil().createLexBIGService();
    CodingSchemeVersionOrTag versionOrTag = new CodingSchemeVersionOrTag();
    versionOrTag.setVersion(version);//from  ww  w  .j  a  va 2  s  .c  o m

    if (lbSvc == null) {
        _logger.warn("lbSvc = null");
        return null;
    }

    LocalNameList contextList = null;
    NameAndValueList qualifierList = null;

    Vector<String> v = null;

    //if (code != null && code.compareTo("") != 0) {
    if (code.compareTo("") != 0) {
        qualifierList = new NameAndValueList();
        NameAndValue nv = new NameAndValue();
        nv.setName("source-code");
        nv.setContent(code);
        qualifierList.addNameAndValue(nv);
    }

    LocalNameList propertyLnL = null;
    // sourceLnL
    Vector<String> w2 = new Vector<String>();
    w2.add(sourceAbbr);
    LocalNameList sourceLnL = vector2LocalNameList(w2);
    if (sourceAbbr.compareTo("*") == 0 || sourceAbbr.compareToIgnoreCase("ALL") == 0) {
        sourceLnL = null;
    }

    SortOptionList sortCriteria = null;// Constructors.createSortOptionList(new
                                       // String[]{"matchToQuery", "code"});
    try {
        CodedNodeSet cns = lbSvc.getCodingSchemeConcepts(scheme, null);
        if (cns == null) {
            _logger.warn("lbSvc.getCodingSchemeConceptsd returns null");
            return null;
        }
        CodedNodeSet.PropertyType[] types = new PropertyType[] { PropertyType.PRESENTATION };
        cns = cns.restrictToProperties(propertyLnL, types, sourceLnL, contextList, qualifierList);

        if (cns != null) {
            boolean activeOnly = !searchInactive;
            cns = restrictToActiveStatus(cns, activeOnly);

            try {
                matchIterator = cns.resolve(sortCriteria, null, null);// ConvenienceMethods.createLocalNameList(getPropertyForCodingScheme(cs)),null);
            } catch (Exception ex) {

            }
        }

    } catch (Exception e) {
        // getLogger().error("ERROR: Exception in findConceptWithSourceCodeMatching.");
        return null;
    }
    return matchIterator;
}

From source file:com.bitplan.mediawiki.japi.Mediawiki.java

/**
 * check whether this is MediaWiki 1.28 or higher but make sure getVersion
 * calls with readapidenied are ignored see
 * https://github.com/WolfgangFahl/Mediawiki-Japi/issues/32
 * /*from www.  j  a  va 2 s.  com*/
 * @return
 */
public boolean isVersion128() {
    String mwversion = "Mediawiki 1.27 or before";
    try {
        mwversion = this.getVersion();
    } catch (Exception e) {
        LOGGER.log(Level.INFO, "Could not retrieve Mediawiki Version via API - will assume " + mwversion
                + " you might want to set the Version actively if you are on 1.28 and have the api blocked for non-logged in users");
    }
    boolean result = mwversion.compareToIgnoreCase("Mediawiki 1.28") >= 0;
    return result;
}

From source file:org.wso2.carbon.governance.api.common.GovernanceArtifactManager.java

@Paginate("getPaginatedGovernanceArtifacts")
public List<String> getPaginatedGovernanceArtifacts() throws GovernanceException {
    List<String> paths = Arrays.asList(GovernanceUtils.getResultPaths(registry, mediaType));
    Collections.sort(paths, new Comparator<String>() {
        public int compare(String o1, String o2) {
            Long l1 = -1l;/* w  ww .j  a  v a 2 s.com*/
            Long l2 = -1l;

            String temp1 = RegistryUtils.getParentPath(o1);
            String temp2 = RegistryUtils.getParentPath(o2);
            try {
                l1 = Long.parseLong(RegistryUtils.getResourceName(temp1));
                l2 = Long.parseLong(RegistryUtils.getResourceName(temp2));
            } catch (NumberFormatException ignore) {

            }

            // First order by name
            int result = RegistryUtils.getResourceName(temp1)
                    .compareToIgnoreCase(RegistryUtils.getResourceName(temp2));
            if (result != 0) {
                return result;
            }
            // Then order by namespace
            result = temp1.compareToIgnoreCase(temp2);
            if (result != 0) {
                return result;
            }
            // Finally by version
            return l2.compareTo(l1);
        }
    });
    return paths;
}

From source file:com.xpn.xwiki.plugin.spacemanager.impl.SpaceManagerImpl.java

private List<String> sortUserNames(Collection<String> collectionOfUsers, final XWikiContext context) {
    List<String> users = new ArrayList<String>(collectionOfUsers);
    Collections.sort(users, new Comparator<String>() {
        public int compare(String a, String b) {
            try {
                XWikiDocument aDoc = context.getWiki().getDocument(a, context);
                XWikiDocument bDoc = context.getWiki().getDocument(b, context);
                String aFirstName = aDoc.getObject("XWiki.XWikiUsers").getStringValue("first_name");
                String bFirstName = bDoc.getObject("XWiki.XWikiUsers").getStringValue("first_name");
                int cmp = aFirstName.compareToIgnoreCase(bFirstName);
                if (cmp == 0) {
                    String aLastName = aDoc.getObject("XWiki.XWikiUsers").getStringValue("last_name");
                    String bLastName = bDoc.getObject("XWiki.XWikiUsers").getStringValue("last_name");
                    return aLastName.compareTo(bLastName);
                } else {
                    return cmp;
                }/*from   w w  w .  j a  v  a 2s . c  om*/
            } catch (Exception e) {
                return ((String) a).compareTo((String) b);
            }
        }
    });
    return users;
}

From source file:com.ibm.domino.das.resources.DocumentResource.java

public Response updateDocumentByUnid(String requestEntity,
        @HeaderParam(HEADER_IF_UNMODIFIED_SINCE) final String ifUnmodifiedSince,
        @PathParam(PARAM_UNID) String unid, @QueryParam(PARAM_DOC_FORM) String form,
        @QueryParam(PARAM_DOC_COMPUTEWITHFORM) String computeWithForm, boolean put) {

    String jsonEntity = null;//from w  w w.ja  v a2  s.c o m
    Document document = null;

    try {
        // Write JSON content
        Database database = this.getDatabase(DB_ACCESS_VIEWS_DOCS);
        try {
            document = database.getDocumentByUNID(unid);
        } catch (NotesException e) {
            throw new WebApplicationException(ErrorHelper.createErrorResponse(e, Response.Status.NOT_FOUND));
        }
        ifUnmodifiedSince(document, ifUnmodifiedSince);
        JsonDocumentContent content = new JsonDocumentContent(document);
        JsonJavaObject jsonItems;
        JsonJavaFactory factory = JsonJavaFactory.instanceEx;
        try {
            StringReader reader = new StringReader(requestEntity);
            try {
                jsonItems = (JsonJavaObject) JsonParser.fromJson(factory, reader);
            } finally {
                reader.close();
            }
        } catch (Exception ex) {
            throw new ServiceException(ex, "Error while parsing the JSON content"); // $NLX-DocumentResource.ErrorwhileparsingtheJSONcontent-1$
        }
        // Handle parameters.
        if (StringUtil.isNotEmpty(form)) {
            document.replaceItemValue(ITEM_FORM, form);
        }
        content.updateFields(jsonItems, put);
        if (computeWithForm != null && computeWithForm.compareToIgnoreCase(PARAM_VALUE_TRUE) == 0) {
            document.computeWithForm(true, true);
        }
        document.save();
    } catch (NotesException e) {
        throw new WebApplicationException(ErrorHelper.createErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (ServiceException e) {
        throw new WebApplicationException(ErrorHelper.createErrorResponse(e, Response.Status.BAD_REQUEST));
    } finally {
        if (document != null) {
            try {
                document.recycle();
            } catch (NotesException e) {
                // Ignore
            }
        }
    }

    ResponseBuilder builder = Response.ok();
    builder.type(MediaType.APPLICATION_JSON_TYPE).entity(jsonEntity);

    Response response = builder.build();

    return response;
}

From source file:org.wikipedia.nirvana.archive.ArchiveWithHeaders.java

void parseTopLines(String oldItems[], int first, int last) {

    Pattern p = Pattern.compile("^==(=?)(\\s*)(?<headername>[^=]+)(\\s*)(=?)==$");
    Section part = null;//new Section();
    boolean trancated = !this.archivePartialText.isEmpty();
    for (int i = first; i <= last; i++) {
        String item = oldItems[i];
        if (item.isEmpty())
            continue;
        Matcher m = p.matcher(item);
        if (m.matches()) {
            //               if(part!=null) {
            //                  parts.add(part);
            //               }
            if (part != null && part.getHeaderHeader() == null && part.isEmpty() && (StringTools
                    .howMany(part.getHeaderText(), '=', true) < StringTools.howMany(item, '=', true))) {
                part.pushHeader(m.group("headername").trim(), item);
            } else {
                if (part != null) {
                    part.trancated = false;
                }// ww  w  .j  a v  a2 s .  c  om
                part = createSection(enumeration, m.group("headername").trim(), item, true);
                part.trancated = trancated;
                parts.add(part);
            }
        } else {
            if (part == null) {
                part = createSection(enumeration, true);
                part.trancated = trancated;
                parts.add(part);
            }
            if (item.compareToIgnoreCase("<ol>") == 0) {
                part.hasOL = true;
            } else if (item.compareToIgnoreCase("</ol>") == 0) {
                part.trancated = false;
            } else {/*
                    if(part==null) {
                    part = new Section();
                    parts.add(part);
                    }*/
                part.addOldItemToEnd(item);
            }
        }
    }
}