/** {@inheritDoc} */
  @SuppressWarnings("TypeMayBeWeakened")
  @Nullable
  private Collection<byte[]> marshalFieldsCollection(
      @Nullable Collection<Object> col, GridCacheContext<K, V> ctx) throws GridException {
    assert ctx != null;

    if (col == null) return null;

    Collection<List<Object>> col0 = new ArrayList<>(col.size());

    for (Object o : col) {
      List<GridIndexingEntity<?>> list = (List<GridIndexingEntity<?>>) o;
      List<Object> list0 = new ArrayList<>(list.size());

      for (GridIndexingEntity<?> ent : list) {
        if (ent.bytes() != null) list0.add(ent.bytes());
        else {
          if (ctx.deploymentEnabled()) prepareObject(ent.value(), ctx);

          list0.add(CU.marshal(ctx, ent.value()));
        }
      }

      col0.add(list0);
    }

    return marshalCollection(col0, ctx);
  }
  /**
   * @param placeNameServiceSet the set of PlaceNameService objects that PlaceNameLayer will render.
   * @throws IllegalArgumentException if {@link
   *     gov.nasa.worldwind.layers.placename.PlaceNameServiceSet} is null
   */
  public PlaceNameLayer(PlaceNameServiceSet placeNameServiceSet) {
    if (placeNameServiceSet == null) {
      String message = Logging.getMessage("nullValue.PlaceNameServiceSetIsNull");
      Logging.logger().fine(message);
      throw new IllegalArgumentException(message);
    }

    //
    this.placeNameServiceSet = placeNameServiceSet.deepCopy();
    for (int i = 0; i < this.placeNameServiceSet.getServiceCount(); i++) {
      // todo do this for long as well and pick min
      int calc1 =
          (int)
              (PlaceNameService.TILING_SECTOR.getDeltaLatDegrees()
                  / this.placeNameServiceSet
                      .getService(i)
                      .getTileDelta()
                      .getLatitude()
                      .getDegrees());
      int numLevels = (int) Math.log(calc1);
      navTiles.add(
          new NavigationTile(
              this.placeNameServiceSet.getService(i),
              PlaceNameService.TILING_SECTOR,
              numLevels,
              "top"));
    }

    if (!WorldWind.getMemoryCacheSet().containsCache(Tile.class.getName())) {
      long size = Configuration.getLongValue(AVKey.PLACENAME_LAYER_CACHE_SIZE, 2000000L);
      MemoryCache cache = new BasicMemoryCache((long) (0.85 * size), size);
      cache.setName("Placename Tiles");
      WorldWind.getMemoryCacheSet().addCache(Tile.class.getName(), cache);
    }
  }
  /**
   * Adds a Near key.
   *
   * @param key Key.
   * @param keyBytes Key bytes.
   * @param ctx Context.
   * @throws GridException If failed.
   */
  public void addNearKey(K key, byte[] keyBytes, GridCacheContext<K, V> ctx) throws GridException {
    if (ctx.deploymentEnabled()) prepareObject(key, ctx);

    if (nearKeyBytes == null) nearKeyBytes = new ArrayList<>();

    nearKeyBytes.add(keyBytes);
  }
  /** {@inheritDoc} */
  @SuppressWarnings("TypeMayBeWeakened")
  @Nullable
  private Collection<Object> unmarshalFieldsCollection(
      @Nullable Collection<byte[]> byteCol, GridCacheContext<K, V> ctx, ClassLoader ldr)
      throws GridException {
    assert ctx != null;
    assert ldr != null;

    Collection<Object> col = unmarshalCollection(byteCol, ctx, ldr);
    Collection<Object> col0 = null;

    if (col != null) {
      col0 = new ArrayList<>(col.size());

      for (Object o : col) {
        List<Object> list = (List<Object>) o;
        List<Object> list0 = new ArrayList<>(list.size());

        for (Object obj : list)
          list0.add(obj != null ? ctx.marshaller().unmarshal((byte[]) obj, ldr) : null);

        col0.add(list0);
      }
    }

    return col0;
  }
 protected void buildSubNavTiles() {
   if (level > 0) {
     // split sector, create a navTile for each quad
     Sector[] subSectors = this.navSector.subdivide();
     for (int j = 0; j < subSectors.length; j++) {
       subNavTiles.add(
           new NavigationTile(placeNameService, subSectors[j], level - 1, this.id + "." + j));
     }
   }
 }
 public List<Tile> getTiles() {
   if (tileKeys.isEmpty()) {
     Tile[] tiles = buildTiles(this.placeNameService, this);
     // load tileKeys
     for (Tile t : tiles) {
       tileKeys.add(t.getFileCachePath());
       WorldWind.getMemoryCache(Tile.class.getName()).add(t.getFileCachePath(), t);
     }
     return Arrays.asList(tiles);
   } else {
     List<Tile> dataTiles = new ArrayList<Tile>();
     for (String s : tileKeys) {
       Tile t = (Tile) WorldWind.getMemoryCache(Tile.class.getName()).getObject(s);
       if (t != null) {
         dataTiles.add(t);
       }
     }
     return dataTiles;
   }
 }
 /**
  * Adds <tt>WebRtcDataStreamListener</tt> to the list of listeners.
  *
  * @param listener the <tt>WebRtcDataStreamListener</tt> to be added to the listeners list.
  */
 public void addChannelListener(WebRtcDataStreamListener listener) {
   if (listener == null) {
     throw new NullPointerException("listener");
   } else {
     synchronized (listeners) {
       if (!listeners.contains(listener)) {
         listeners.add(listener);
       }
     }
   }
 }
 @MarshalsPointer
 public static List<CFStreamSocketSOCKSVersion> toObject(
     Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<CFStreamSocketSOCKSVersion> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(CFStreamSocketSOCKSVersion.valueOf(o.get(i, CFString.class)));
   }
   return list;
 }
 @MarshalsPointer
 public static List<CFURLUbiquitousItemDownloadingStatus> toObject(
     Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(CFArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CFURLUbiquitousItemDownloadingStatus> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(CFURLUbiquitousItemDownloadingStatus.valueOf(o.get(i, CFString.class)));
   }
   return list;
 }
Esempio n. 10
0
 @MarshalsPointer
 public static List<CGImagePropertyGIF> toObject(
     Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(CFArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CGImagePropertyGIF> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(CGImagePropertyGIF.valueOf(o.get(i, CFString.class)));
   }
   return list;
 }
Esempio n. 11
0
 @MarshalsPointer
 public static List<CVBufferAttributes> toObject(
     Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(CFArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CVBufferAttributes> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new CVBufferAttributes(o.get(i, CFDictionary.class)));
   }
   return list;
 }
 @MarshalsPointer
 public static List<CMFormatDescriptionExtension> toObject(
     Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<CMFormatDescriptionExtension> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new CMFormatDescriptionExtension(o.get(i, CFDictionary.class)));
   }
   return list;
 }
 @MarshalsPointer
 public static List<AVSampleRateConverterSettings> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<AVSampleRateConverterSettings> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new AVSampleRateConverterSettings(o.get(i)));
   }
   return list;
 }
Esempio n. 14
0
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<SCNLightingModel> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSString> o = (NSArray<NSString>) NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<SCNLightingModel> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(SCNLightingModel.valueOf(o.get(i)));
   }
   return list;
 }
Esempio n. 15
0
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<CMVideoCodecType> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSString> o = (NSArray<NSString>) NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<CMVideoCodecType> list = new ArrayList<>();
   for (NSString str : o) {
     list.add(CMVideoCodecType.valueOf(str));
   }
   return list;
 }
 @MarshalsPointer
 public static List<CBCentralManagerOptions> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CBCentralManagerOptions> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new CBCentralManagerOptions(o.get(i)));
   }
   return list;
 }
Esempio n. 17
0
 @MarshalsPointer
 public static List<ABSource> toObject(Class<? extends CFType> cls, long handle, long flags) {
   CFArray o = (CFArray) CFType.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<ABSource> list = new ArrayList<>();
   for (long i = 0, n = o.size(); i < n; i++) {
     ABRecord record = o.get(i, ABRecord.class);
     list.add(
         (ABSource) NativeObject.Marshaler.toObject(ABSource.class, record.getHandle(), flags));
   }
   return list;
 }
 @MarshalsPointer
 public static List<MPMoviePlayerThumbnailRequest> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<MPMoviePlayerThumbnailRequest> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new MPMoviePlayerThumbnailRequest(o.get(i)));
   }
   return list;
 }
Esempio n. 19
0
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<SCNMatrix4> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSValue> o = (NSArray<NSValue>) NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<SCNMatrix4> list = new ArrayList<>();
   for (NSValue val : o) {
     list.add(val.SCNMatrix4Value());
   }
   return list;
 }
Esempio n. 20
0
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<CVPixelFormatType> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSNumber> o = (NSArray<NSNumber>) NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<CVPixelFormatType> list = new ArrayList<>();
   for (NSNumber n : o) {
     list.add(CVPixelFormatType.valueOf(n.longValue()));
   }
   return list;
 }
 @MarshalsPointer
 public static List<UIImagePickerControllerEditingInfo> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary> o =
       (NSArray<NSDictionary>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<UIImagePickerControllerEditingInfo> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new UIImagePickerControllerEditingInfo(o.get(i)));
   }
   return list;
 }
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<CNInstantMessageAddressPropertyKey> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSString> o =
       (NSArray<NSString>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<CNInstantMessageAddressPropertyKey> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(CNInstantMessageAddressPropertyKey.valueOf(o.get(i)));
   }
   return list;
 }
 @SuppressWarnings("unchecked")
 @MarshalsPointer
 public static List<HKDietaryQuantityTypeIdentifier> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSString> o =
       (NSArray<NSString>) NSObject.Marshaler.toObject(NSArray.class, handle, flags);
   if (o == null) {
     return null;
   }
   List<HKDietaryQuantityTypeIdentifier> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(HKDietaryQuantityTypeIdentifier.valueOf(o.get(i)));
   }
   return list;
 }
Esempio n. 24
0
 @MarshalsPointer
 public static List<NSNetServiceErrorUserInfo> toObject(
     Class<? extends NSObject> cls, long handle, long flags) {
   NSArray<NSDictionary<NSString, NSObject>> o =
       (NSArray<NSDictionary<NSString, NSObject>>)
           NSObject.Marshaler.toObject(cls, handle, flags);
   if (o == null) {
     return null;
   }
   List<NSNetServiceErrorUserInfo> list = new ArrayList<>();
   for (int i = 0; i < o.size(); i++) {
     list.add(new NSNetServiceErrorUserInfo(o.get(i)));
   }
   return list;
 }
  static void testMixed(Charset cs) throws Throwable {
    CharsetDecoder dec =
        cs.newDecoder()
            .onMalformedInput(CodingErrorAction.REPLACE)
            .onUnmappableCharacter(CodingErrorAction.REPLACE);
    CharsetEncoder enc =
        cs.newEncoder()
            .onMalformedInput(CodingErrorAction.REPLACE)
            .onUnmappableCharacter(CodingErrorAction.REPLACE);
    List<Integer> cps = new ArrayList<>(0x10000);
    int off = 0;
    int cp = 0;
    while (cp < 0x10000) {
      if (enc.canEncode((char) cp)) {
        cps.add(cp);
      }
      cp++;
    }
    Collections.shuffle(cps);
    char[] bmpCA = new char[cps.size()];
    for (int i = 0; i < cps.size(); i++) bmpCA[i] = (char) (int) cps.get(i);
    String bmpStr = new String(bmpCA);
    // getBytes(csn);
    byte[] bmpBA = bmpStr.getBytes(cs.name());
    ByteBuffer bf = enc.reset().encode(CharBuffer.wrap(bmpCA));
    byte[] baNIO = new byte[bf.limit()];
    bf.get(baNIO, 0, baNIO.length);
    if (!Arrays.equals(bmpBA, baNIO)) {
      throw new RuntimeException("getBytes(csn) failed  -> " + cs.name());
    }

    // getBytes(cs);
    bmpBA = bmpStr.getBytes(cs);
    if (!Arrays.equals(bmpBA, baNIO))
      throw new RuntimeException("getBytes(cs) failed  -> " + cs.name());

    // new String(csn);
    String strSC = new String(bmpBA, cs.name());
    String strNIO = dec.reset().decode(ByteBuffer.wrap(bmpBA)).toString();
    if (!strNIO.equals(strSC)) {
      throw new RuntimeException("new String(csn) failed  -> " + cs.name());
    }

    // new String(cs);
    strSC = new String(bmpBA, cs);
    if (!strNIO.equals(strSC)) throw new RuntimeException("new String(cs) failed  -> " + cs.name());
  }
Esempio n. 26
0
  /**
   * Finds all files in folder and in it's sub-tree of specified depth.
   *
   * @param file Starting folder
   * @param maxDepth Depth of the tree. If 1 - just look in the folder, no sub-folders.
   * @param filter file filter.
   * @return List of found files.
   */
  public static List<VisorLogFile> fileTree(File file, int maxDepth, @Nullable FileFilter filter) {
    if (file.isDirectory()) {
      File[] files = (filter == null) ? file.listFiles() : file.listFiles(filter);

      if (files == null) return Collections.emptyList();

      List<VisorLogFile> res = new ArrayList<>(files.length);

      for (File f : files) {
        if (f.isFile() && f.length() > 0) res.add(new VisorLogFile(f));
        else if (maxDepth > 1) res.addAll(fileTree(f, maxDepth - 1, filter));
      }

      return res;
    }

    return F.asList(new VisorLogFile(file));
  }
Esempio n. 27
0
  /** {@inheritDoc} */
  @SuppressWarnings("all")
  @Override
  public boolean readFrom(ByteBuffer buf) {
    commState.setBuffer(buf);

    if (!super.readFrom(buf)) return false;

    switch (commState.idx) {
      case 8:
        if (commState.readSize == -1) {
          if (buf.remaining() < 4) return false;

          commState.readSize = commState.getInt();
        }

        if (commState.readSize >= 0) {
          if (nearKeyBytes == null) nearKeyBytes = new ArrayList<>(commState.readSize);

          for (int i = commState.readItems; i < commState.readSize; i++) {
            byte[] _val = commState.getByteArray();

            if (_val == BYTE_ARR_NOT_READ) return false;

            nearKeyBytes.add((byte[]) _val);

            commState.readItems++;
          }
        }

        commState.readSize = -1;
        commState.readItems = 0;

        commState.idx++;
    }

    return true;
  }
Esempio n. 28
0
  public String postFile(URLFetchService us, List<PostObj> postobjlist) throws Exception {
    int index;

    Gson gson;
    String linkID;
    List<String> linkList;
    HTTPRequest req;
    String param;

    gson = new Gson();

    linkID = createUID();
    linkList = new ArrayList<String>();
    for (index = 0; index < postobjlist.size(); index++) {
      linkList.add(postobjlist.get(index).filelink);
    }

    param =
        URLEncoder.encode("postlist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(postobjlist), "UTF-8")
            + '&'
            + URLEncoder.encode("linkid", "UTF-8")
            + "="
            + URLEncoder.encode(linkID, "UTF-8")
            + '&'
            + URLEncoder.encode("linklist", "UTF-8")
            + "="
            + URLEncoder.encode(gson.toJson(linkList), "UTF-8");
    req =
        new HTTPRequest(
            new URL("http://tnfshmoe.appspot.com/postdf89ksfxsyx9sfdex09usdjksd"), HTTPMethod.POST);
    req.setPayload(param.getBytes());
    us.fetch(req);

    return linkID;
  }
Esempio n. 29
0
  public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    int index;

    DatastoreService ds;
    MemcacheService ms;
    BlobstoreService bs;
    URLFetchService us;
    FileService fs;

    Map<String, List<BlobKey>> blobMap;
    BlobKey blobKey;
    BlobInfoFactory blobInfoFactory;
    BlobInfo blobInfo;

    int postCount;
    int postIndex;
    String postType;
    String postText;
    String postDelpw;
    String postShowgallery;
    DataObj dataObj;
    String filelink;

    String picUrl;
    HTTPResponse picRes;
    List<HTTPHeader> headerList;
    String picMime;
    String[] fileNamePart;
    AppEngineFile picFile;
    FileWriteChannel writeChannel;

    PostObj postObj;
    List<PostObj> postObjList;
    String linkID;

    resp.setCharacterEncoding("UTF-8");
    resp.setContentType("text/plain");

    try {
      ds = DatastoreServiceFactory.getDatastoreService();
      ms = MemcacheServiceFactory.getMemcacheService();
      bs = BlobstoreServiceFactory.getBlobstoreService();
      us = URLFetchServiceFactory.getURLFetchService();
      fs = FileServiceFactory.getFileService();
      blobInfoFactory = new BlobInfoFactory(ds);

      blobMap = bs.getUploads(req);
      postCount = Integer.valueOf(req.getParameter("input_post_count"));
      postObjList = new ArrayList<PostObj>();

      for (postIndex = 0; postIndex < postCount; postIndex++) {
        try {
          postType = req.getParameter("input_post_type_" + postIndex);
          if (postType == null) {
            continue;
          }

          postText = req.getParameter("input_post_text_" + postIndex);
          postDelpw = req.getParameter("input_post_delpw_" + postIndex);
          postShowgallery = req.getParameter("input_post_showgallery_" + postIndex);
          if (postShowgallery == null) {
            postShowgallery = "";
          }

          if (postType.equals("file") == true) {
            blobKey = blobMap.get("input_post_file_" + postIndex).get(0);
            if (blobKey == null) {
              throw new Exception();
            }

            dataObj = new DataObj();
            dataObj.fileid = createUID();
            dataObj.posttime = new Date().getTime();
            dataObj.delpw = postDelpw;
            dataObj.blobkey = blobKey;
            dataObj.putDB(ds);

            blobInfo = blobInfoFactory.loadBlobInfo(dataObj.blobkey);
            filelink =
                "http://"
                    + req.getServerName()
                    + "/down/"
                    + dataObj.fileid
                    + "/"
                    + blobInfo.getFilename();
            postObj =
                new PostObj(
                    dataObj.fileid,
                    filelink,
                    blobInfo.getSize(),
                    dataObj.posttime,
                    dataObj.delpw,
                    postShowgallery);
            postObjList.add(postObj);
          } else if (postType.equals("url") == true) {
            picUrl = postText;

            picRes = us.fetch(new URL(picUrl));
            headerList = picRes.getHeaders();
            picMime = "application/octet-stream";
            for (index = 0; index < headerList.size(); index++) {
              if (headerList.get(index).getName().compareToIgnoreCase("Content-Type") == 0) {
                picMime = headerList.get(index).getValue();
                break;
              }
            }

            fileNamePart = picUrl.split("/");

            picFile = fs.createNewBlobFile(picMime, fileNamePart[fileNamePart.length - 1]);
            writeChannel = fs.openWriteChannel(picFile, true);
            writeChannel.write(ByteBuffer.wrap(picRes.getContent()));
            writeChannel.closeFinally();

            dataObj = new DataObj();
            dataObj.fileid = createUID();
            dataObj.posttime = new Date().getTime();
            dataObj.delpw = postDelpw;
            dataObj.blobkey = fs.getBlobKey(picFile);
            dataObj.putDB(ds);

            blobInfo = blobInfoFactory.loadBlobInfo(dataObj.blobkey);
            filelink =
                "http://"
                    + req.getServerName()
                    + "/down/"
                    + dataObj.fileid
                    + "/"
                    + blobInfo.getFilename();
            postObj =
                new PostObj(
                    dataObj.fileid,
                    filelink,
                    blobInfo.getSize(),
                    dataObj.posttime,
                    dataObj.delpw,
                    postShowgallery);
            postObjList.add(postObj);
          }
        } catch (Exception e) {
        }
      }

      linkID = postFile(us, postObjList);

      if (req.getParameter("specflag") != null) {
        resp.getWriter().print("http://tnfshmoe.appspot.com/link.jsp?linkid=" + linkID);
      } else {
        resp.sendRedirect("http://tnfshmoe.appspot.com/link.jsp?linkid=" + linkID);
      }
    } catch (Exception e) {
    }
  }
Esempio n. 30
0
  /**
   * Parses the binary data that describes the recurrent pattern.
   *
   * @param data the binary data.
   * @param sourceTask the calendar item.
   */
  public RecurringPattern(byte[] data, CalendarItemTimerTask sourceTask) {
    this.sourceTask = sourceTask;
    dataBuffer = ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN);

    int offset = 4;
    recurFrequency = dataBuffer.getShort(offset);
    offset += 2;

    patternType = PatternType.getFromShort(dataBuffer.getShort(offset));
    offset += 2;

    calendarType = dataBuffer.getShort(offset);
    offset += 2;

    firstDateTime = dataBuffer.getInt(offset);
    offset += 4;

    period = dataBuffer.getInt(offset);
    offset += 4;

    slidingFlag = dataBuffer.getInt(offset);
    offset += 4;

    switch (patternType) {
      case Week:
      case Month:
      case MonthEnd:
      case HjMonth:
      case HjMonthEnd:
        patternSpecific1 = dataBuffer.getInt(offset);
        patternSpecific2 = 0;
        offset += 4;
        if (patternType == PatternType.Week) {
          for (int day = firstDow; day < firstDow + 7; day++) {
            if ((patternSpecific1 & (weekOfDayMask[day % 7])) != 0) {
              allowedDaysOfWeek.add((day % 7) + 1);
            }
          }
        }
        break;
      case MonthNth:
      case HjMonthNth:
        patternSpecific1 = dataBuffer.getInt(offset);
        patternSpecific2 = dataBuffer.getInt(offset + 4);
        if (patternSpecific1 == 0x7f && patternSpecific2 != 0x5) {
          patternType = PatternType.Month;
        }
        for (int day = 0; day < 7; day++) {
          if ((patternSpecific1 & (weekOfDayMask[day])) != 0) {
            allowedDaysOfWeek.add((day) + 1);
          }
        }
        offset += 8;
        break;
      default:
        break;
    }

    // endType
    endType = dataBuffer.getInt(offset);
    offset += 4;

    occurenceCount = dataBuffer.getInt(offset);
    offset += 4;

    firstDow = dataBuffer.getInt(offset);
    offset += 4;

    deletedInstanceCount = dataBuffer.getInt(offset);
    offset += 4;

    // deleted instances
    for (int i = 0; i < deletedInstanceCount; i++) {
      deletedInstances.add(windowsTimeToDateObject(dataBuffer.getInt(offset)));
      offset += 4;
    }

    modifiedInstanceCount = dataBuffer.getInt(offset);
    offset += 4;

    // modified instances
    modifiedInstances = new int[modifiedInstanceCount];

    for (int i = 0; i < modifiedInstanceCount; i++) {
      modifiedInstances[i] = dataBuffer.getInt(offset);
      offset += 4;
    }

    startDate = dataBuffer.getInt(offset);
    offset += 4;

    endDate = dataBuffer.getInt(offset);
    offset += 4;

    offset += 16;

    short exceptionCount = dataBuffer.getShort(offset);
    offset += 2;
    exceptionInfo = new ArrayList<ExceptionInfo>(exceptionCount);
    for (int i = 0; i < exceptionCount; i++) {
      ExceptionInfo tmpExceptionInfo = new ExceptionInfo(offset);
      exceptionInfo.add(tmpExceptionInfo);
      offset += tmpExceptionInfo.sizeInBytes();

      CalendarService.BusyStatusEnum status = tmpExceptionInfo.getBusyStatus();
      Date startTime = tmpExceptionInfo.getStartDate();
      Date endTime = tmpExceptionInfo.getEndDate();
      if (status == CalendarService.BusyStatusEnum.FREE || startTime == null || endTime == null)
        continue;
      Date currentTime = new Date();

      if (endTime.before(currentTime) || endTime.equals(currentTime)) return;

      boolean executeNow = false;

      if (startTime.before(currentTime) || startTime.equals(currentTime)) executeNow = true;

      CalendarItemTimerTask task =
          new CalendarItemTimerTask(
              status, startTime, endTime, sourceTask.getId(), executeNow, this);

      task.scheduleTasks();
    }
  }