public String toString() {
   StringBuilder buf = new StringBuilder();
   buf.append(var.getFQN());
   buf.append(slices.toString());
   if (this.filter != null) {
     buf.append("|");
     buf.append(filter.toString());
   }
   return buf.toString();
 }
 /**
  * Convert the view to a constraint string suitable for use in a URL, except not URL encoded.
  *
  * @return constraint string
  */
 public String toConstraintString() {
   StringBuilder buf = new StringBuilder();
   boolean first = true;
   for (int i = 0; i < segments.size(); i++) {
     Segment seg = segments.get(i);
     if (!seg.var.isTopLevel()) continue;
     if (!first) buf.append(";");
     first = false;
     dumpvar(seg, buf, true);
   }
   return buf.toString();
 }
 /**
  * Recursive helper for tostring/toConstraintString
  *
  * @param seg
  * @param buf
  * @param forconstraint
  */
 protected void dumpvar(Segment seg, StringBuilder buf, boolean forconstraint) {
   if (seg.var.isTopLevel()) buf.append(seg.var.getFQN());
   else buf.append(seg.var.getShortName());
   List<DapDimension> dimset = seg.var.getDimensions();
   // Add any slices
   List<Slice> slices = seg.slices;
   if (slices == null) dimset = new ArrayList<DapDimension>();
   else assert dimset.size() == slices.size();
   for (int i = 0; i < dimset.size(); i++) {
     Slice slice = slices.get(i);
     DapDimension dim = dimset.get(i);
     try {
       buf.append(forconstraint ? slice.toConstraintString() : slice.toString());
     } catch (DapException de) {
     }
   }
   // if the var is atomic, then we are done
   if (seg.var.getSort() == DapSort.ATOMICVARIABLE) return;
   // If structure and all fields are in the view, then done
   if (seg.var.getSort() == DapSort.STRUCTURE || seg.var.getSort() == DapSort.SEQUENCE) {
     if (!isWholeCompound((DapStructure) seg.var)) {
       // Need to insert {...} and recurse
       buf.append(LBRACE);
       DapStructure struct = (DapStructure) seg.var;
       boolean first = true;
       for (DapVariable field : struct.getFields()) {
         if (!first) buf.append(";");
         first = false;
         Segment fseg = findSegment(field);
         dumpvar(fseg, buf, forconstraint);
       }
       buf.append(RBRACE);
     }
     if (seg.var.getSort() == DapSort.SEQUENCE && seg.filter != null) {
       buf.append("|");
       buf.append(seg.filter.toString());
     }
   }
 }