Package org.apache.commons.lang3.text

Examples of org.apache.commons.lang3.text.StrTokenizer


    decomponeQuery();
  }

  // PRIVATE METHODS
  private void decomponeQuery() {
    StrTokenizer tokenizer = new StrTokenizer(originalQuery);
    Pattern pattern = Pattern.compile("\\$\\{.*?\\}");

    String partialStr = "";
    String logicOperator = "";
    String prevOperator = "";
    while (tokenizer.hasNext()) {
      String elem = (String) tokenizer.next();

      if (logicOperators.containsKey(elem)) {
        logicOperator += elem + " ";
      } else {
        int iterations = 1;
        if (!tokenizer.hasNext())
          iterations = 2;

        for (int i = 0; i < iterations; i++) {
          if (!logicOperator.equals("") || !tokenizer.hasNext()) {
            StringBuilder partStr = new StringBuilder(partialStr);

            QueryPart queryPart = new QueryPart();

            Matcher matcher = pattern.matcher(partStr.toString());
View Full Code Here


            final Map<String, String> uriTemplateVariables) {
        if (path.startsWith(pathSeparator) != pattern.startsWith(pathSeparator)) {
            return false;
        }

        final String[] patternDirs = new StrTokenizer(pattern, pathSeparator)
                .setIgnoreEmptyTokens(true).getTokenArray();
        final String[] pathDirs = new StrTokenizer(path, pathSeparator)
                .setIgnoreEmptyTokens(true).getTokenArray();

        int pattIdxStart = 0;
        int pattIdxEnd = patternDirs.length - 1;
        int pathIdxStart = 0;
View Full Code Here

     * <code>pattern</code>' and '<code>path</code>', but does
     * <strong>not</strong> enforce this.
     */
    public String extractPathWithinPattern(final String pattern,
            final String path) {
        final String[] patternParts = new StrTokenizer(pattern, pathSeparator)
                .setIgnoreEmptyTokens(true).getTokenArray();
        final String[] pathParts = new StrTokenizer(path, pathSeparator)
                .setIgnoreEmptyTokens(true).getTokenArray();

        final StringBuilder builder = new StringBuilder();

        // Add any path parts that have a wildcarded pattern part.
View Full Code Here

            return;
        }

        final Set<String> disallowedOperationSet = new HashSet<String>();
        if (!"".equals(disallowedOperations)) {
            final String[] disallowedOperationsTokens = new StrTokenizer(
                    disallowedOperations, ",").getTokenArray();
            for (final String operation : disallowedOperationsTokens) {
                if (!("create".equals(operation) || "update".equals(operation) || "delete"
                        .equals(operation))) {
                    LOGGER.warning("-disallowedOperations options can only contain 'create', 'update', 'delete': -disallowedOperations update,delete");
View Full Code Here

        if (StringUtils.isBlank(filter)) {
            return finders;
        }

        final Set<String> requiredEntries = new HashSet<String>();
        final String[] filterTokens = new StrTokenizer(filter, ",")
                .getTokenArray();
        for (final String requiredString : filterTokens) {
            requiredEntries.add(requiredString.toLowerCase());
        }
        if (requiredEntries.isEmpty()) {
View Full Code Here

     * @see <a href="http://www.w3.org/International/questions/qa-escapes">Using character escapes in markup and CSS</a>
     * @see <a href="https://issues.apache.org/jira/browse/LANG-728">LANG-728</a>
     */
    @Test
    public void testEscapeXmlSupplementaryCharacters() {
        CharSequenceTranslator escapeXml =
            StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );

        assertEquals("Supplementary character must be represented using a single escape", "&#144308;",
                escapeXml.translate("\uD84C\uDFB4"));
    }
View Full Code Here

     * @see <a href="http://www.w3.org/International/questions/qa-escapes">Using character escapes in markup and CSS</a>
     * @see <a href="https://issues.apache.org/jira/browse/LANG-728">LANG-728</a>
     */
    @Test
    public void testEscapeXmlSupplementaryCharacters() {
        CharSequenceTranslator escapeXml =
            StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );

        assertEquals("Supplementary character must be represented using a single escape", "&#144308;",
                escapeXml.translate("\uD84C\uDFB4"));
    }
View Full Code Here

     * @see <a href="https://issues.apache.org/jira/browse/LANG-728">LANG-728</a>
     */
    @Test
    @SuppressWarnings( "deprecation" ) // ESCAPE_XML has been replaced by ESCAPE_XML10 and ESCAPE_XML11 in 3.3
    public void testEscapeXmlSupplementaryCharacters() {
        final CharSequenceTranslator escapeXml =
            StringEscapeUtils.ESCAPE_XML.with( NumericEntityEscaper.between(0x7f, Integer.MAX_VALUE) );

        assertEquals("Supplementary character must be represented using a single escape", "&#144308;",
                escapeXml.translate("\uD84C\uDFB4"));

        assertEquals("Supplementary characters mixed with basic characters should be encoded correctly", "a b c &#144308;",
                        escapeXml.translate("a b c \uD84C\uDFB4"));
    }
View Full Code Here

    @SuppressWarnings( "deprecation" ) // ESCAPE_XML has been replaced by ESCAPE_XML10 and ESCAPE_XML11 in 3.3
    public void testEscapeXmlAllCharacters() {
        // http://www.w3.org/TR/xml/#charsets says:
        // Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character,
        // excluding the surrogate blocks, FFFE, and FFFF. */
        final CharSequenceTranslator escapeXml = StringEscapeUtils.ESCAPE_XML
                .with(NumericEntityEscaper.below(9), NumericEntityEscaper.between(0xB, 0xC), NumericEntityEscaper.between(0xE, 0x19),
                        NumericEntityEscaper.between(0xD800, 0xDFFF), NumericEntityEscaper.between(0xFFFE, 0xFFFF), NumericEntityEscaper.above(0x110000));

        assertEquals("&#0;&#1;&#2;&#3;&#4;&#5;&#6;&#7;&#8;", escapeXml.translate("\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008"));
        assertEquals("\t", escapeXml.translate("\t")); // 0x9
        assertEquals("\n", escapeXml.translate("\n")); // 0xA
        assertEquals("&#11;&#12;", escapeXml.translate("\u000B\u000C"));
        assertEquals("\r", escapeXml.translate("\r")); // 0xD
        assertEquals("Hello World! Ain&apos;t this great?", escapeXml.translate("Hello World! Ain't this great?"));
        assertEquals("&#14;&#15;&#24;&#25;", escapeXml.translate("\u000E\u000F\u0018\u0019"));
    }
View Full Code Here

        String sql = "SELECT v.proposal_id as proposalId, avg(v.note) as moy, count(v.proposal_id) as nbVote, t.title as proposalTitle FROM vote v, proposal t where (v.proposal_id=t.id) group by v.proposal_id order by moy desc";
        List<SqlRow> rows = Ebean.createSqlQuery(sql).findList();
       
        Map<Long, Pair<Double, Integer>> moyennes = new HashMap<Long, Pair<Double, Integer>>();
        for (SqlRow row : rows) {
            Pair<Double, Integer> moyProposal = new ImmutablePair(row.getDouble("moy"), row.getInteger("nbVote"));
            moyennes.put(row.getLong("proposalId"), moyProposal);
        }
       
        return moyennes;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang3.text.StrTokenizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.