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());
}
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) {
}
}
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);
}
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();
}
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;
}
Aggregations