Search in sources :

Example 36 with StrBuilder

use of org.apache.commons.lang3.text.StrBuilder in project blue by kunstmusik.

the class CSDRender method handleParametersForBlueLive.

private void handleParametersForBlueLive(ArrayList parameters, ArrayList<StringChannel> stringChannels, GlobalOrcSco globalOrcSco, NoteList notes, Arrangement arrangement, boolean useAPI) {
    Object[] varNum = new Object[1];
    StrBuilder initStatements = new StrBuilder();
    StrBuilder paramScore = new StrBuilder();
    for (StringChannel strChannel : stringChannels) {
        String varName = strChannel.getChannelName();
        initStatements.append(varName);
        initStatements.append(" = ");
        initStatements.append("\"").append(strChannel.getValue()).append("\"\n");
        if (useAPI) {
            initStatements.append(varName).append(" chnexport \"");
            initStatements.append(varName).append("\", 3\n");
        }
    }
    for (int i = 0; i < parameters.size(); i++) {
        Parameter param = (Parameter) parameters.get(i);
        varNum[0] = new Integer(i);
        String varName = param.getCompilationVarName();
        // param.setCompilationVarName(varName);
        double initialVal = param.getFixedValue();
        // init statements
        initStatements.append(varName);
        initStatements.append(" init ");
        initStatements.append(NumberUtilities.formatDouble(initialVal));
        initStatements.append("\n");
        if (useAPI) {
            initStatements.append(varName).append(" chnexport \"");
            initStatements.append(varName).append("\", 3\n");
        }
    }
    globalOrcSco.appendGlobalOrc(initStatements.toString());
    try {
        notes.addAll(ScoreUtilities.getNotes(paramScore.toString()));
    } catch (NoteParseException ex) {
        ex.printStackTrace();
    }
// globalOrcSco.appendGlobalSco(paramScore.toString());
}
Also used : NoteParseException(blue.soundObject.NoteParseException) StringChannel(blue.orchestra.blueSynthBuilder.StringChannel) Parameter(blue.automation.Parameter) StrBuilder(org.apache.commons.lang3.text.StrBuilder) LinePoint(blue.components.lines.LinePoint)

Example 37 with StrBuilder

use of org.apache.commons.lang3.text.StrBuilder in project commons-lang by apache.

the class ObjectUtilsTest method testIdentityToStringStrBuilder.

@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) {
    }
}
Also used : StrBuilder(org.apache.commons.lang3.text.StrBuilder) Test(org.junit.Test)

Example 38 with StrBuilder

use of org.apache.commons.lang3.text.StrBuilder in project checker-framework by typetools.

the class MavenExample method main.

public static void main(final String[] args) {
    System.out.println("Hello World!");
    StrBuilder stb = new StrBuilder();
    // error on this line
    @NonNull Object nn = nullable;
    System.out.println(nn);
}
Also used : NonNull(org.checkerframework.checker.nullness.qual.NonNull) StrBuilder(org.apache.commons.lang3.text.StrBuilder)

Example 39 with StrBuilder

use of org.apache.commons.lang3.text.StrBuilder in project pmd by pmd.

the class AbstractVmNode method literal.

// All additional methods
/*
     * see org.apache.velocity.runtime.parser.node.Node#literal()
     */
public String literal() {
    // buffer allocation. VELOCITY-606
    if (first != null && first.equals(last)) {
        return NodeUtils.tokenLiteral(first);
    }
    Token t = first;
    final StrBuilder sb = new StrBuilder(NodeUtils.tokenLiteral(t));
    while (t != null && !t.equals(last)) {
        t = t.next;
        sb.append(NodeUtils.tokenLiteral(t));
    }
    return sb.toString();
}
Also used : StrBuilder(org.apache.commons.lang3.text.StrBuilder)

Example 40 with StrBuilder

use of org.apache.commons.lang3.text.StrBuilder in project pmd by pmd.

the class NodeUtils method getSpecialText.

/**
 * Collect all the <SPECIAL_TOKEN>s that are carried along with a token.
 * Special tokens do not participate in parsing but can still trigger
 * certain lexical actions. In some cases you may want to retrieve these
 * special tokens, this is simply a way to extract them.
 *
 * @param t
 *            the Token
 * @return StrBuilder with the special tokens.
 */
private static StrBuilder getSpecialText(final Token t) {
    final StrBuilder sb = new StrBuilder();
    Token tmpToken = t.specialToken;
    while (tmpToken.specialToken != null) {
        tmpToken = tmpToken.specialToken;
    }
    while (tmpToken != null) {
        final String st = tmpToken.image;
        for (int i = 0; i < st.length(); i++) {
            final char c = st.charAt(i);
            if (c == '#' || c == '$') {
                sb.append(c);
            }
            if (c == '\\') {
                boolean ok = true;
                boolean term = false;
                int j = i;
                for (ok = true; ok && j < st.length(); j++) {
                    final char cc = st.charAt(j);
                    if (cc == '\\') {
                        /*
                             * if we see a \, keep going
                             */
                        continue;
                    } else if (cc == '$') {
                        /*
                             * a $ ends it correctly
                             */
                        term = true;
                        ok = false;
                    } else {
                        /*
                             * nah...
                             */
                        ok = false;
                    }
                }
                if (term) {
                    final String foo = st.substring(i, j);
                    sb.append(foo);
                    i = j;
                }
            }
        }
        tmpToken = tmpToken.next;
    }
    return sb;
}
Also used : StrBuilder(org.apache.commons.lang3.text.StrBuilder)

Aggregations

StrBuilder (org.apache.commons.lang3.text.StrBuilder)44 GenericInstrument (blue.orchestra.GenericInstrument)9 LinePoint (blue.components.lines.LinePoint)8 Instrument (blue.orchestra.Instrument)5 StringChannel (blue.orchestra.blueSynthBuilder.StringChannel)4 Parameter (blue.automation.Parameter)3 NoteParseException (blue.soundObject.NoteParseException)3 ArrayList (java.util.ArrayList)3 Arrangement (blue.Arrangement)2 CompileData (blue.CompileData)2 GlobalOrcSco (blue.GlobalOrcSco)2 Tables (blue.Tables)2 ParameterNameManager (blue.automation.ParameterNameManager)2 Line (blue.components.lines.Line)2 SoundObjectParameterLine (blue.components.lines.SoundObjectParameterLine)2 Mixer (blue.mixer.Mixer)2 TempoMapper (blue.noteProcessor.TempoMapper)2 StringChannelNameManager (blue.orchestra.blueSynthBuilder.StringChannelNameManager)2 EnvelopePoint (blue.orchestra.blueX7.EnvelopePoint)2 CsdRenderResult (blue.services.render.CsdRenderResult)2