Require a string to appear, or throw an exception.
<p>
<em>Precondition:</em> Entity expansion is not required.
<p>
<em>Precondition:</em> data buffer has no characters that will get sent
to the application.
187495
private void require(String delim) throws SAXException, IOException {
        int length = delim.length();
        char[] ch;

        if (length < dataBuffer.length) {
            ch = dataBuffer;
            delim.getChars(0, length, ch, 0);
        } else {
            ch = delim.toCharArray();
        }

        for (int i = 0; i < length; i++) {
                require(ch[i]);
        }
    }
29238
public static String checkNotEmpty(String str, String message) {
        if (checkNotNull(str).isEmpty()) {
            throw new IllegalArgumentException(message);
        }
        return str;
    }
436411
public static void checkRequiredPreconditions(final boolean required, final String ifMatch,
            final String ifUnmodifiedSince) {
        if (required && ifMatch == null && ifUnmodifiedSince == null) {
            throw new ClientErrorException(status(PRECONDITION_REQUIRED).build());
        }
    }
734841
public final void doWork(final HttpServletRequest pReq,
    final HttpServletResponse pResp) throws ServletException, IOException {
    pReq.setCharacterEncoding("UTF-8");
    pResp.setCharacterEncoding("UTF-8");
    IFactoryAppBeans factoryAppBeans = null;
    try {
      HashMap<String, Object> reqVars = new HashMap<String, Object>();
      factoryAppBeans = (IFactoryAppBeans) getServletContext()
          .getAttribute("IFactoryAppBeans");
      HttpRequestData requestData = new HttpRequestData(pReq, pResp);
      requestData.setAttribute("reqVars", reqVars);
      IHandlerRequest hndlI18nRequest = (IHandlerRequest)
        factoryAppBeans.lazyGet("hndlI18nRequest");
      hndlI18nRequest.handle(reqVars, requestData);
      IMngSoftware mngSoftware = (IMngSoftware) factoryAppBeans
        .lazyGet("IMngSoftware");
      ISrvI18n srvI18n = (ISrvI18n) factoryAppBeans.lazyGet("ISrvI18n");
      UtlJsp utlJsp = (UtlJsp) factoryAppBeans.lazyGet("UtlJsp");
      String dbgShStr = pReq.getParameter("dbgSh");
      if (dbgShStr != null) {
        mngSoftware.setDbgSh(Boolean.valueOf(dbgShStr));
      }
      String dbgFlStr = pReq.getParameter("dbgFl");
      if (dbgFlStr != null) {
        mngSoftware.setDbgFl(Integer.parseInt(dbgFlStr));
      }
      String dbgClStr = pReq.getParameter("dbgCl");
      if (dbgClStr != null) {
        mngSoftware.setDbgCl(Integer.parseInt(dbgClStr));
      }
      pReq.setAttribute("mngSoftware", mngSoftware);
      pReq.setAttribute("srvI18n", srvI18n);
      pReq.setAttribute("utlJsp", utlJsp);
      String nmRnd = pReq.getParameter("nmRnd");
      String path = dirJsp + nmRnd + ".jsp";
      RequestDispatcher rd = getServletContext().getRequestDispatcher(path);
      rd.include(pReq, pResp);
    } catch (Exception e) {
      if (factoryAppBeans != null) {
        ILog logger = null;
        try {
          logger = (ILog) factoryAppBeans.lazyGet("ILog");
        } catch (Exception e1) {
          e1.printStackTrace();
        }
        if (logger != null) {
          logger.error(null, getClass(), "WORK", e);
        } else {
          e.printStackTrace();
        }
      } else {
        e.printStackTrace();
      }
      if (e instanceof ExceptionWithCode) {
        pReq.setAttribute("error_code",
          ((ExceptionWithCode) e).getCode());
        pReq.setAttribute("short_message",
          ((ExceptionWithCode) e).getShortMessage());
      } else {
        pReq.setAttribute("error_code",
          HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      }
      pReq.setAttribute("javax.servlet.error.status_code",
        HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      pReq.setAttribute("javax.servlet.error.exception", e);
      pReq.setAttribute("javax.servlet.error.request_uri",
        pReq.getRequestURI());
      pReq.setAttribute("javax.servlet.error.servlet_name", this.getClass()
        .getCanonicalName());
      pResp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
    }
  }
618236
private void required(String attributeName, Resource attributValue, boolean exists) throws ApplicationException {
	if (attributValue == null)
	    throw new ApplicationException("invalid attribute constellation for the tag zip", "attribute [" + attributeName + "] is required, if action is [" + action + "]");

	if (exists && !attributValue.exists()) throw new ApplicationException(attributeName + " resource [" + attributValue + "] doesn't exist");
	else if (exists && !attributValue.canRead()) throw new ApplicationException("no access to " + attributeName + " resource [" + attributValue + "]");

    }
271135
public static Character detectChar(String string, CharPredicate predicate)
    {
        int size = string.length();
        for (int i = 0; i < size; i++)
        {
            char character = string.charAt(i);
            if (predicate.accept(character))
            {
                return character;
            }
        }
        return null;
    }
462896
public void append(String str) {
	if (str == null) return;
	int restLength = buffer.length - pos;
	if (str.length() < restLength) {
	    str.getChars(0, str.length(), buffer, pos);
	    pos += str.length();
	}
	else {
	    str.getChars(0, restLength, buffer, pos);
	    curr.next = new Entity(buffer);
	    curr = curr.next;
	    length += buffer.length;
	    buffer = new char[(buffer.length > str.length() - restLength) ? buffer.length : str.length() - restLength];

	    str.getChars(restLength, str.length(), buffer, 0);
	    pos = str.length() - restLength;

	}
    }
172860
private static void checkPreconditions(final Pattern pattern, final String replacement) {
        if(pattern == null ) {
            throw new NullPointerException("regex should not be null");
        }
        
        if(replacement == null) {
            throw new NullPointerException("replacement should not be null");
        }
    }
451065
@Override
    public String validate(DTDValidatorBase v, char[] cbuf, int start, int end, boolean normalize)
        throws XMLStreamException
    {
        //int origStart = start;

        /* First things first; let's ensure value is not empty (all
         * white space)...
         */
        while (start < end && WstxInputData.isSpaceChar(cbuf[start])) {
            ++start;
        }
        // Empty value?
        if (start >= end) {
            return reportValidationProblem(v, "Empty NMTOKENS value");
        }

        /* Then, let's have separate handling for normalizing and
         * non-normalizing case, since latter is trivially easy case:
         */
        if (!normalize) {
            for (; start < end; ++start) {
                char c = cbuf[start];
                if (!WstxInputData.isSpaceChar(c) 
                    && !WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                    return reportInvalidChar(v, c, "not valid as NMTOKENS character");
                }
            }
            return null; // ok, all good
        }

        //boolean trimmed = (origStart != start);
        //origStart = start;

        --end; // so that it now points to the last char
        // Wouldn't absolutely have to trim trailing... but is easy to do
        while (end > start && WstxInputData.isSpaceChar(cbuf[end])) {
            --end;
            //trimmed = true;
        }

        /* Ok, now, need to check we only have valid chars, and maybe
         * also coalesce multiple spaces, if any.
         */
        StringBuilder sb = null;

        while (start <= end) {
            int i = start;
            for (; i <= end; ++i) {
                char c = cbuf[i];
                if (WstxInputData.isSpaceChar(c)) {
                    break;
                }
                if (!WstxInputData.isNameChar(c, mCfgNsAware, mCfgXml11)) {
                    return reportInvalidChar(v, c, "not valid as an NMTOKENS character");
                }
            }

            if (sb == null) {
                sb = new StringBuilder(end - start + 1);
            } else {
                sb.append(' ');
            }
            sb.append(cbuf, start, (i - start));

            start = i + 1;
            // Ok, any white space to skip?
            while (start <= end && WstxInputData.isSpaceChar(cbuf[start])) {
                ++start;
            }
        }

        /* 27-Nov-2005, TSa: Could actually optimize trimming, and often
         *   avoid using StringBuilder... but let's only do it if it turns
         *   out dealing with NMTOKENS normalization shows up on profiling...
         */
        return sb.toString();
    }
306932
public void required(final String tagName, final String actionName, final String attributeName, final Object attribute) throws PageException {
	if (attribute == null) {
	    final Excepton util = CFMLEngineFactory.getInstance().getExceptionUtil();
	    throw util.createApplicationException("Attribute [" + attributeName + "] for tag [" + tagName + "] is required if attribute action has the value [" + actionName + "]");
	}
    }
1089751
public static void addString(ByteBuffer buffer, String val)
  {
    addBytes(buffer, StringUtils.toUtf8(val));
  }
1308543
public static <T extends FocusWidget & HasText> String requireNonEmpty (T widget, String error)
    {
        String text = widget.getText().trim();
        if (text.length() == 0) {
            Popups.errorBelow(error, widget);
            widget.setFocus(true);
            throw new InputException();
        }
        return text;
    }
930775
public void characters(String s) throws org.xml.sax.SAXException
    {
        if (m_inEntityRef && !m_expandDTDEntities)
            return;
        final int length = s.length();
        if (length > m_charsBuff.length)
        {
            m_charsBuff = new char[length * 2 + 1];
        }
        s.getChars(0, length, m_charsBuff, 0);
        characters(m_charsBuff, 0, length);
    }
620207
private void parsePreamble(ByteBuffer buffer) {
        if (_partialBoundary > 0) {
            int partial = _delimiterSearch.startsWith(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining(), _partialBoundary);
            if (partial > 0) {
                if (partial == _delimiterSearch.getLength()) {
                    buffer.position(buffer.position() + partial - _partialBoundary);
                    _partialBoundary = 0;
                    setState(State.DELIMITER);
                    return;
                }

                _partialBoundary = partial;
                BufferUtils.clear(buffer);
                return;
            }

            _partialBoundary = 0;
        }

        int delimiter = _delimiterSearch.match(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
        if (delimiter >= 0) {
            buffer.position(delimiter - buffer.arrayOffset() + _delimiterSearch.getLength());
            setState(State.DELIMITER);
            return;
        }

        _partialBoundary = _delimiterSearch.endsWith(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
        BufferUtils.clear(buffer);
    }
66650
private final void validateChar(int value)
        throws XMLStreamException
    {
        /* 24-Jan-2006, TSa: Ok, "high" Unicode chars are problematic,
         *   need to be reported by a surrogate pair..
         */
        if (value >= 0xD800) {
            if (value < 0xE000) { // no surrogates via entity expansion
                reportIllegalChar(value);
            }
            if (value > 0xFFFF) {
                // Within valid range at all?
                if (value > MAX_UNICODE_CHAR) {
                    reportUnicodeOverflow();
                }
            } else if (value >= 0xFFFE) { // 0xFFFE and 0xFFFF are illegal too
                reportIllegalChar(value);
            }
            // Ok, fine as is
        } else if (value < 32) {
            if (value == 0) {
                throwParseError("Invalid character reference: null character not allowed in XML content.");
            }
            // XML 1.1 allows most other chars; 1.0 does not:
            if (!mXml11 && !mAllowXml11EscapedCharsInXml10
                && (value != 0x9 && value != 0xA && value != 0xD)) {
                reportIllegalChar(value);
            }
        }
    }
1130674
@Deprecated
    public static <CS extends CharSequence> CS requireNotNullOrEmpty(CS cs, String message) {
        return requireNotNullNorEmpty(cs, message);
    }
496627
public static boolean noneSatisfyCodePoint(String string, CodePointPredicate predicate)
    {
        int size = string.length();
        for (int i = 0; i < size; )
        {
            int codePoint = string.codePointAt(i);
            if (predicate.accept(codePoint))
            {
                return false;
            }
            i += Character.charCount(codePoint);
        }
        return true;
    }