Package org.apache.commons.lang3.text

Examples of org.apache.commons.lang3.text.StrBuilder$StrBuilderReader


     * @param operator The ComparisonFilter.Operator.
     * @return A string builder representing the where clause of the SQL query.
     */
    private static StrBuilder buildWhereClauseFromRightAndLeftParts(
            StrBuilder value1, StrBuilder value2, ComparisonFilter.Operator operator) {
        StrBuilder clause;
        switch(operator) {
            case EQ:
                clause = value1.append("=").append(value2);
                break;
            case NE:
                clause = value1.append("<>").append(value2);
                break;
            case LT:
                clause = value1.append("<").append(value2);
                break;
            case GT:
                clause = value1.append(">").append(value2);
                break;
            case LE:
                clause = value1.append("<=").append(value2);
                break;
            case GE:
                clause = value1.append(">=").append(value2);
                break;
            case CONTAINS:
                value2 = new StrBuilder(value2.toString().replace("\"", ""));
                clause = value1.append(" LIKE ").append("\"%").append(value2).append("%\"");
                break;
            case STARTS_WITH:
                value2 = new StrBuilder(value2.toString().replace("\"", ""));
                clause = value1.append(" LIKE ").append("\"").append(value2).append("%\"");
                break;
            case ENDS_WITH:
                value2 = new StrBuilder(value2.toString().replace("\"", ""));
                clause = value1.append(" LIKE ").append("\"%").append(value2).append("\"");
                break;
            case MATCHES:
                throw new RuntimeException("SQL does not support regular expression");
            case LIKE:
                value2 = new StrBuilder(value2.toString().replace("\"", ""));
                clause = value1.append(" LIKE ").append("\"").append(value2).append("\"");
                break;
            default:// Should never get here.
                throw new RuntimeException("Operator was not found: " + operator);
        }
        clause.insert(0, "(").append(")");
        return clause;
    }
View Full Code Here


     *
     * @param abstractColumn The column.
     * @return The column id for the data table.
     */
    private static StrBuilder getColumnId(AbstractColumn abstractColumn) {
        StrBuilder columnId = new StrBuilder();

        // For simple column the id is simply the column id.
        if(abstractColumn instanceof SimpleColumn) {
            columnId.append("`").append(abstractColumn.getId()).append("`");
        }
        else {
            // For aggregation column build the id from the aggregation type and the
            // column id (e.g. for aggregation type 'min' and column id 'salary', the
            // sql column id will be: min(`salary`);
            AggregationColumn aggregationColumn = (AggregationColumn) abstractColumn;
            columnId.append(getAggregationFunction(
                    aggregationColumn.getAggregationType())).append("(`").
                    append(aggregationColumn.getAggregatedColumn()).append("`)");
        }
        return columnId;
    }
View Full Code Here

    return false;
  }

  private static ArrayList getFieldName(String genericField, String fieldValue, XMLBuilder builder, String prefixCount) {
    String fieldName = StringUtils.substringBetween(fieldValue, "$", "$");
    StrBuilder bufFieldName = new StrBuilder(fieldName);
    ArrayList arrActionResult = new ArrayList();
    analizeAction(fieldName, bufFieldName, arrActionResult);
    fieldName = bufFieldName.toString();
    // System.out.println("fieldName " + fieldName);
    // System.out.println("actionResult " + arrActionResult);
    ArrayList fieldResult = new ArrayList();
    try {
      if (fieldName != null) {
View Full Code Here

        return new Factory()
        {
            protected String getColumnName()
            {
                return new StrBuilder(fun.name().toString()).append('(')
                                                            .appendWithSeparators(factories.getColumnNames(), ", ")
                                                            .append(')')
                                                            .toString();
            }
View Full Code Here

    }

    @Override
    public String toString()
    {
        return new StrBuilder().append(fun.name())
                               .append("(")
                               .appendWithSeparators(argSelectors, ", ")
                               .append(")")
                               .toString();
    }
View Full Code Here

        }

        @Override
        public String toString()
        {
            return new StrBuilder().append(functionName)
                                   .append("(")
                                   .appendWithSeparators(args, ", ")
                                   .append(")")
                                   .toString();
        }
View Full Code Here

    @Test
    public void testIdentityToStringStrBuilder() {
        final Integer i = Integer.valueOf(102);
        final String expected = "java.lang.Integer@" + Integer.toHexString(System.identityHashCode(i));

        final StrBuilder builder = new StrBuilder();
        ObjectUtils.identityToString(builder, i);
        assertEquals(expected, builder.toString());

        try {
            ObjectUtils.identityToString((StrBuilder)null, "tmp");
            fail("NullPointerException expected");
        } catch(final NullPointerException npe) {
        }
       
        try {
            ObjectUtils.identityToString(new StrBuilder(), null);
            fail("NullPointerException expected");
        } catch(final NullPointerException npe) {
        }
    }
View Full Code Here

        assertTrue(StringUtils.startsWithAny("abcxyz", "abc"));
        assertTrue(StringUtils.startsWithAny("abcxyz", null, "xyz", "abc"));
        assertFalse(StringUtils.startsWithAny("abcxyz", null, "xyz", "abcd"));

        assertTrue("StringUtils.startsWithAny(abcxyz, StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny("abcxyz", new StringBuilder("xyz"), new StringBuffer("abc")));
        assertTrue("StringUtils.startsWithAny( StrBuilder(abcxyz), StringBuilder(xyz), StringBuffer(abc))", StringUtils.startsWithAny( new StrBuilder("abcxyz"), new StringBuilder("xyz"), new StringBuffer("abc")));
    }
View Full Code Here

        assertTrue("StringUtils.endsWithAny(abcxyz, new String[] {xyz})", StringUtils.endsWithAny("abcxyz", new String[] {"xyz"}));
        assertTrue("StringUtils.endsWithAny(abcxyz, new String[] {null, xyz, abc})", StringUtils.endsWithAny("abcxyz", new String[] {null, "xyz", "abc"}));
        assertFalse("StringUtils.endsWithAny(defg, new String[] {null, xyz, abc})", StringUtils.endsWithAny("defg", new String[] {null, "xyz", "abc"}));

        assertTrue("StringUtils.endsWithAny(abcxyz, StringBuilder(abc), StringBuffer(xyz))", StringUtils.endsWithAny("abcxyz", new StringBuilder("abc"), new StringBuffer("xyz")));
        assertTrue("StringUtils.endsWithAny( StrBuilder(abcxyz), StringBuilder(abc), StringBuffer(xyz))", StringUtils.endsWithAny( new StrBuilder("abcxyz"), new StringBuilder("abc"), new StringBuffer("xyz")));
    }
View Full Code Here

    double critDamResist = 100. - (100 * (player.calcStat(Stats.CRIT_DAMAGE_RECEPTIVE, 1., target, null) - critDamResistStatic));
    String dialog = HtmCache.getInstance().getNotNull("command/whoami.htm", player);
    NumberFormat df = NumberFormat.getInstance(Locale.ENGLISH);
    df.setMaximumFractionDigits(1);
    df.setMinimumFractionDigits(1);
    StrBuilder sb = new StrBuilder(dialog);
    sb.replaceFirst("%hpRegen%", df.format(hpRegen));
    sb.replaceFirst("%cpRegen%", df.format(cpRegen));
    sb.replaceFirst("%mpRegen%", df.format(mpRegen));
    sb.replaceFirst("%hpDrain%", df.format(hpDrain));
    sb.replaceFirst("%mpDrain%", df.format(mpDrain));
    sb.replaceFirst("%hpGain%", df.format(hpGain));
    sb.replaceFirst("%mpGain%", df.format(mpGain));
    sb.replaceFirst("%critPerc%", df.format(critPerc));
    sb.replaceFirst("%critStatic%", df.format(critStatic));
    sb.replaceFirst("%mCritDmg%", df.format(mCritDmg));
    sb.replaceFirst("%blowRate%", df.format(blowRate));
    sb.replaceFirst("%shieldDef%", df.format(shieldDef));
    sb.replaceFirst("%shieldRate%", df.format(shieldRate));
    sb.replaceFirst("%xpRate%", df.format(xpRate));
    sb.replaceFirst("%spRate%", df.format(spRate));
    sb.replaceFirst("%dropRate%", df.format(dropRate));
    sb.replaceFirst("%adenaRate%", df.format(adenaRate));
    sb.replaceFirst("%spoilRate%", df.format(spoilRate));
    sb.replaceFirst("%fireResist%", df.format(fireResist));
    sb.replaceFirst("%windResist%", df.format(windResist));
    sb.replaceFirst("%waterResist%", df.format(waterResist));
    sb.replaceFirst("%earthResist%", df.format(earthResist));
    sb.replaceFirst("%holyResist%", df.format(holyResist));
    sb.replaceFirst("%darkResist%", df.format(unholyResist));
    sb.replaceFirst("%bleedPower%", df.format(bleedPower));
    sb.replaceFirst("%bleedResist%", df.format(bleedResist));
    sb.replaceFirst("%poisonPower%", df.format(poisonPower));
    sb.replaceFirst("%poisonResist%", df.format(poisonResist));
    sb.replaceFirst("%stunPower%", df.format(stunPower));
    sb.replaceFirst("%stunResist%", df.format(stunResist));
    sb.replaceFirst("%rootPower%", df.format(rootPower));
    sb.replaceFirst("%rootResist%", df.format(rootResist));
    sb.replaceFirst("%sleepPower%", df.format(sleepPower));
    sb.replaceFirst("%sleepResist%", df.format(sleepResist));
    sb.replaceFirst("%paralyzePower%", df.format(paralyzePower));
    sb.replaceFirst("%paralyzeResist%", df.format(paralyzeResist));
    sb.replaceFirst("%mentalPower%", df.format(mentalPower));
    sb.replaceFirst("%mentalResist%", df.format(mentalResist));
    sb.replaceFirst("%debuffPower%", df.format(debuffPower));
    sb.replaceFirst("%debuffResist%", df.format(debuffResist));
    sb.replaceFirst("%cancelPower%", df.format(cancelPower));
    sb.replaceFirst("%cancelResist%", df.format(cancelResist));
    sb.replaceFirst("%swordResist%", df.format(swordResist));
    sb.replaceFirst("%dualResist%", df.format(dualResist));
    sb.replaceFirst("%bluntResist%", df.format(bluntResist));
    sb.replaceFirst("%daggerResist%", df.format(daggerResist));
    sb.replaceFirst("%bowResist%", df.format(bowResist));
    sb.replaceFirst("%crossbowResist%", df.format(crossbowResist));
    sb.replaceFirst("%fistResist%", df.format(fistResist));
    sb.replaceFirst("%poleResist%", df.format(poleResist));
    sb.replaceFirst("%critChanceResist%", df.format(critChanceResist));
    sb.replaceFirst("%critDamResist%", df.format(critDamResist));
    NpcHtmlMessage msg = new NpcHtmlMessage(0);
    msg.setHtml(Strings.bbParse(sb.toString()));
    player.sendPacket(msg);
    return true;
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.lang3.text.StrBuilder$StrBuilderReader

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.