Package org.jugile.util

Examples of org.jugile.util.Buffer


  protected final static String MAPSTART = "@";
 
 
  public String toCsv() { return toCsv(0);}
  private final String toCsv(int versionIncrement) {
    Buffer buf = new Buffer();
    buf.add(getId()); // id
    buf.add(CSVDELIMITER);
    buf.add(""+(version+versionIncrement)); // version
    buf.add(CSVDELIMITER);
    buf.add(_modified==null?"-":_modified.toString(TSFORMAT)); // modified time
    List<Field> flds = flds();
    flds.addAll(cn1s());
    for (Field f : flds) {
      buf.add(CSVDELIMITER);
      Object o = null;
      try { o = f.get(this); } catch (Exception e) { fail(e); }
      if (o == null) buf.add(NULLCHAR);
      else if (o instanceof String) {
        if (((String)o).length() == 0) buf.add(NULLCHAR);
        else if (((String)o).equals(""+NULLCHAR)) {
          buf.add(""+NULLCHAR+NULLCHAR);
        }
        else {
          String str = Jugile.replaceControls((String)o);
          str = escape(str,CSVDELIMITER);
          buf.add(str);
        }
      }
      else if (o instanceof Bo) buf.add(((Bo)o).getId());
      else if (o instanceof Time) buf.add(((Time)o).toString(TSFORMAT));
      else if (o instanceof EnumType) buf.add(""+((EnumType)o).getValue());
      else buf.add(escape(o.toString(),CSVDELIMITER));
    }
    return buf.toString();
  }
View Full Code Here


      if (i.equals(ic)) return true;
    }
    return false;
  }
  protected final String _headerRow() {
    Buffer buf = new Buffer();
    buf.add(Bo.HEADERSTART);
    buf.add(getClass().getName());
    buf.add(Bo.CSVDELIMITER);
    buf.add("v");
    buf.add(Bo.CSVDELIMITER);
    buf.add("ts");
    List<Field> flds = flds();
    flds.addAll(cn1s());
    for (Field f : flds) {
      buf.add(Bo.CSVDELIMITER);
      buf.add(f.getName());
    }
    return buf.toString();
  }
View Full Code Here

  }
  private String getSelectHeaderFldsString() {
    return Jugile.join(Arrays.asList(sHeaderFlds), ",");
  }
  protected String _getSelectFlds() {
    Buffer buf = new Buffer();
    buf.add(getSelectHeaderFldsString());
    for (String fld : _dbflds()) {
      buf.add(","+fld);
    }
    return buf.toString();
  }
View Full Code Here

      buf.add(","+fld);
    }
    return buf.toString();
  }
  protected String _getUpdateFlds() {
    Buffer buf = new Buffer();
    for (int i = 0; i < _dbflds().size(); i++) {
      if (i > 0) buf.add(",");
      buf.add(_dbflds().get(i)+"=?");
    }
    return buf.toString();   
  }
View Full Code Here

  // for testing
  protected E getOriginal(long id) { return items.get(id); }
 
  public String csv() {
    if (items.size() == 0) return ""; // empty set
    Buffer buf = new Buffer();
    buf.ln(_first()._headerRow());
    if (items.size() > 0) {
      Iterator<E> i2 = items.values().iterator();
      while (i2.hasNext()) {
        E o = i2.next();
        buf.ln(o._delta());
      }     
    }
    return buf.toString();
  }
View Full Code Here

  }

  public String nncsv() throws Exception {
    if (items.size() == 0) return ""; // empty set
    //log.debug("nncsv() first: " + _first() + "to " + this);
    Buffer buf = new Buffer();
    for (Field f : _first().nns()) {
      String cn1 = f.getName();
      if (items.size() > 0) {
        buf.ln(_first()._nnHeader(f));
        Iterator<E> i2 = items.values().iterator();
        while (i2.hasNext()) {
          E o = i2.next();
          BoMap<E> m = (BoMap<E>)o.getBoMap(cn1);
          if (m.size() > 0) {
            buf.add(((Bo)o).getId());
            for (Bo bo : m) {
              // items() of n-n collection, added
              buf.add(Bo.CSVDELIMITER + bo.getId());             
            }
            buf.nl();
          }
        }
      }     
    }
    return buf.toString();
  }
View Full Code Here

    return nodes;
  }
 
 
  public void dump(String header) {
    Buffer buf = new Buffer("    ");
    buf.ln("");
    buf.ln("");
    buf.ln(mult("=",77));
    buf.ln("   DAIMS OO memory dump: " + now().getUiTs());
    buf.ln("     - "+ header);
    buf.ln(mult("=",77));
    buf.ln("");
    try {
      cd().dump(buf);
      uow().dump(buf);
    } catch (Exception e) { fail(e); }   
    print(buf.toString());
  }
View Full Code Here

      }
    }
  }
 
  public String status() {
    Buffer buf = new Buffer();
    buf.nl();
    buf.ln("removed: " + removed.size());
    buf.ln("items: " + items.size());
    if (origin != null) {
      buf.ln("origin: " + origin.size());
    }
    return buf.toString();
  }
View Full Code Here

    if (size == 0) cs.countEmpty++;
    if (size == 1 && size > 0) cs.count1++;
  }
 
  public String toString() {
    Buffer buf = new Buffer();
    buf.ln();
    buf.ln("================");
    buf.ln("Domain Stats:");
    buf.ln("================");
    buf.ln("name, count = collections or objects, item count = items in collections, empty collections, collections size 1"); // headers
    for (Class cl : classes) {
      BoStats bs = map.get(cl);
      buf.ln(bs.name + ", " + bs.count);
      buf.incrIndent();
      for (String name : bs.map.keySet()) {
        CollStats cs = bs.map.get(name);
        buf.ln(name +", " +cs.toString());
      }
      buf.decrIndent();
    }
    buf.ln("================");
    buf.ln(" objects:      " + count);
    buf.ln(" associations: " + total);
   
    return buf.toString();
  }
View Full Code Here

    }
    return 0;
  }
 
  private static String qmarks(int count) {
    Buffer buf = new Buffer();
    for (int i = 0; i < count; i++) {
      if (i > 0) buf.add(",");
      buf.add("?");
    }
    return buf.toString();
  }
View Full Code Here

TOP

Related Classes of org.jugile.util.Buffer

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.