void genvalue(StringBuilder buf, BaseType lhsvar, boolean forceconstant) { // decide if the rhs is going to be a var or a constant boolean isvar = (random.nextDouble() < VARRHSPROB); if (isvar && !forceconstant) { BaseType rhsvar = findmatchingvar(lhsvar); if (rhsvar != null) gendimpoint(getPath(rhsvar), buf); else genvalue(buf, lhsvar, true); // replace with a constant } else { // use a constant String rhs = valuefor(lhsvar); while (rhs == null) rhs = valuefor(lhsvar); buf.append(rhs); } }
void genvalueset(StringBuilder buf, BaseType lhsvar) { // Decide if this will be a multi-valued rhs boolean issingleton = (random.nextDouble() >= NVALUESPROB); if (issingleton) { genvalue(buf, lhsvar, false); } else { // Determine the number of of elements in the rhs set (> 1) int setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE while (setsize < 2) setsize = random.nextInt(MAXRHSSIZE) + 1; // 1..MAXRHSSIZE buf.append("{"); for (int i = 0; i < setsize; i++) { if (i > 0) buf.append(","); genvalue(buf, lhsvar, false); } buf.append("}"); } }