Package org.apache.commons.lang3.tuple

Examples of org.apache.commons.lang3.tuple.Pair


      logger.trace("Buffer: {}, cursor: {}", buffer, cursor);
      logger.trace("Candidates {}", candidates);
    }
    if (StringUtils.isNotBlank(buffer)) {
      // User is typing a command
      StrTokenizer strTokenizer = new StrTokenizer(buffer);
      String action = strTokenizer.next();
      Collection<String> arguments = argumentMap.get(action);
      if (arguments != null) {
        if (logger.isTraceEnabled()) {
          logger.trace("Arguments found for {}, Tokens: {}", action, strTokenizer.getTokenList());
          logger.trace("Arguments for {}: {}", action, arguments);
        }
        List<String> args = new ArrayList<String>(arguments);
        List<Completer> completers = new ArrayList<Completer>();
        for (String token : strTokenizer.getTokenList()) {
          boolean argContains = arguments.contains(token);
          if (token.startsWith("-") && !argContains) {
            continue;
          }
          if (argContains) {
View Full Code Here


    return success;
  }

  @Override
  protected int executeCommand(String line) {
    String[] tokens = new StrTokenizer(line).getTokenArray();
    String action = tokens[0];
    String[] actionArgs = Arrays.copyOfRange(tokens, 1, tokens.length);
    if (logger.isDebugEnabled()) {
      logger.debug("Executing command action: {}, Tokens: {}", action, tokens.length);
    }
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

*/
  @SuppressWarnings({ "rawtypes", "unchecked" })
private DefaultMutableTreeNode createNode(Doc doc)
  {
    //System.out.println("handle " + doc.name());
    Pair pair = Pair.of(doc, new ArrayList<String>());
   
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(pair);
    doc2node.put(doc, node);
    return node;
  }
View Full Code Here

   */
  @SuppressWarnings({ "rawtypes", "unchecked" })
private DefaultMutableTreeNode createNode(Doc doc)
  {
    //System.out.println("handle " + doc.name());
    Pair pair = Pair.of(doc, new ArrayList<String>());
   
    DefaultMutableTreeNode node = new DefaultMutableTreeNode(pair);
    doc2node.put(doc, node);
    return node;
  }
View Full Code Here

      usedWords.add(word);

      // is the word found in the dictionary
      boolean foundWord = false;

      Pair frenchPinyinTranslation = null;
      if (chineseFrench.containsKey(word)) {
        frenchPinyinTranslation = getPinyinTranslation(chineseFrench
            .get(word));
      }
      Pair germanPinyinTranslation = null;
      if (chineseGerman.containsKey(word)) {
        germanPinyinTranslation = getPinyinTranslation(chineseGerman
            .get(word));
      }

      if (frenchPinyinTranslation != null
          || germanPinyinTranslation != null) {
        foundWord = true;
        // first add subwords
        if (word.length() > 1) {// only then subwords can occur
          for (String subword : TextBoostUtils
              .splitIntoAllSubstrings(word, false)) {
            addWordTranslation(result, usedWords, subword,
                chineseFrench, chineseGerman,
                characterComponents);
          }
        }
        // end of subwords

        Object[] row = { "", "", "", "" };
        // word, pinyin, french, german

        row[0] = word.replace('\t', ' ');
        if (frenchPinyinTranslation != null)
          row[1] = frenchPinyinTranslation.getKey();
        else if (germanPinyinTranslation != null)
          row[1] = germanPinyinTranslation.getKey();
        if (frenchPinyinTranslation != null)
          row[2] = frenchPinyinTranslation.getRight();

        if (germanPinyinTranslation != null)
          row[3] = germanPinyinTranslation.getRight();

        result.addRow(row);
      }

      if (minimizeMemory && !foundWord) {
View Full Code Here

TOP

Related Classes of org.apache.commons.lang3.tuple.Pair

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.