Package com.fogas.koll3ctions.core.bean

Examples of com.fogas.koll3ctions.core.bean.Collection


    return collections;
  }

  private void readCollections() throws FileNotFoundException, IOException {
    collections = new Collections();
    Collection collection = null;
    boolean inValue = false;
    boolean foundTime = false;
    boolean foundName = true;
    boolean foundItems = false;
    StringBuilder sb = new StringBuilder();
    String value;
    int size;
    char[] buff = new char[1048576];
    BufferedReader br = new BufferedReader(new FileReader(file));
    while ((size = br.read(buff)) != -1) {
      for (int i = 0; i < size; i++) {
        switch (buff[i]) {
          case '"':
            inValue = !inValue;
            if (!inValue) {
              value = sb.toString();
              sb.setLength(0);
              if ("lastAccess".equals(value)) {
                foundTime = true;
              } else if ("items".equals(value)) {
                foundItems = true;
              } else if (foundName) {
                foundName = false;
                collection = new Collection(value);
              } else if (foundItems) {
                collection.addItem(value);
              }
            }
            break;
          case '0': //$FALL-THROUGH$
          case '1': //$FALL-THROUGH$
          case '2': //$FALL-THROUGH$
          case '3': //$FALL-THROUGH$
          case '4': //$FALL-THROUGH$
          case '5': //$FALL-THROUGH$
          case '6': //$FALL-THROUGH$
          case '7': //$FALL-THROUGH$
          case '8': //$FALL-THROUGH$
          case '9':
            if (foundTime) {
              sb.append(buff[i]);
            }
            break;
          case '}': // block end
            if (foundTime) { // if end of the time
              value = sb.toString();
              sb.setLength(0);
              collection.setLastAccess(Long.parseLong(value));
              foundTime = false;
            }
            collections.add(collection);
            foundName = true;
            break;
View Full Code Here

TOP

Related Classes of com.fogas.koll3ctions.core.bean.Collection

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.