Beispiel #1
0
  void updateSlot(final USK origUSK, final long number, final ClientContext context) {
    if (logMINOR) Logger.minor(this, "Updating (slot) " + origUSK.getURI() + " : " + number);
    USK clear = origUSK.clearCopy();
    final USKCallback[] callbacks;
    synchronized (this) {
      Long l = latestSlotByClearUSK.get(clear);
      if (logMINOR) Logger.minor(this, "Old slot: " + l);
      if ((l == null) || (number > l.longValue())) {
        l = Long.valueOf(number);
        latestSlotByClearUSK.put(clear, l);
        if (logMINOR) Logger.minor(this, "Put " + number);
      } else return;

      callbacks = subscribersByClearUSK.get(clear);
      if (temporaryBackgroundFetchersPrefetch.containsKey(clear)) {
        temporaryBackgroundFetchersPrefetch.put(clear, System.currentTimeMillis());
        schedulePrefetchChecker();
      }
    }
    if (callbacks != null) {
      // Run off-thread, because of locking, and because client callbacks may take some time
      final USK usk = origUSK.copy(number);
      for (final USKCallback callback : callbacks)
        context.mainExecutor.execute(
            new Runnable() {
              @Override
              public void run() {
                callback.onFoundEdition(
                    number, usk, null, // non-persistent
                    context, false, (short) -1, null, false, false);
              }
            },
            "USKManager callback executor for " + callback);
    }
  }
Beispiel #2
0
 /**
  * Entry point for instrumentation, invoked by the modified classloader for JVM <= 1.4x. For Java
  * 1.5 it is invoked by the agent interface of the JVM. Thus this method is invoked for each class
  * being loaded by the JVM. This does not imply that all classes are instrumented.
  *
  * @param loader the class loader attempting to load this class.
  * @param className class name of class being loaded
  * @param protectionDomain security protection domain
  * @param classfileBuffer
  * @param offset
  * @param length
  * @return null if the class is not instrumented (modified)
  */
 public static byte[] transform(
     ClassLoader loader,
     String className,
     ProtectionDomain protectionDomain,
     byte[] classfileBuffer,
     int offset,
     int length) {
   try {
     init();
     // Check to see if we already know this class loader or add it to the Javassist ClassPool
     // search path if
     // it's new. This is important in J2EE- and Servlet containers that have class loader
     // hierarchies
     if (!classLoaders.containsKey(
         loader)) { // <<< TODO: this is a weak hash map, will this really work as intended?
       classPool.insertClassPath(new LoaderClassPath(loader));
       classLoaders.put(loader, null);
     }
     // Parses the byte array into a CtClass instance.
     CtClass ctc = loadClass(classfileBuffer, offset, length);
     // transforms the class if it is of any interest to us.
     byte[] bb = findTypeAndTransform(ctc);
     // removes the CtClass from the pool to release memory
     ctc.detach();
     return bb;
   } catch (Throwable t) {
     Log.warning(
         "Exception during categorizeAndTransform of class "
             + className
             + ". The class will be ignored.",
         t);
     return null;
   }
 }
 private Drawable getActivityIconWithCache(ComponentName componentname)
 {
     String s = componentname.flattenToShortString();
     if (mOutsideDrawablesCache.containsKey(s))
     {
         componentname = (android.graphics.drawable.Drawable.ConstantState)mOutsideDrawablesCache.get(s);
         if (componentname == null)
         {
             return null;
         } else
         {
             return componentname.newDrawable(mProviderContext.getResources());
         }
     }
     Drawable drawable = getActivityIcon(componentname);
     if (drawable == null)
     {
         componentname = null;
     } else
     {
         componentname = drawable.getConstantState();
     }
     mOutsideDrawablesCache.put(s, componentname);
     return drawable;
 }
 public MPSLanguageVirtualFile getFileFor(@NotNull final Language language) {
   if (myVirtualFiles.containsKey(language)) {
     return myVirtualFiles.get(language);
   }
   MPSLanguageVirtualFile vf = new MPSLanguageVirtualFile(language);
   myVirtualFiles.put(language, vf);
   return vf;
 }
Beispiel #5
0
  private SelectionKey checkIfSpinnedKey(final SelectionKey key) {
    if (!key.isValid()
        && key.channel().isOpen()
        && spinnedSelectorsHistory.containsKey(key.selector())) {
      final SelectionKey newKey = key.channel().keyFor(selector);
      newKey.attach(key.attachment());
      return newKey;
    }

    return key;
  }
  public void addAll(@NotNull UpdaterTreeState state) {
    myToExpand.putAll(state.myToExpand);

    Object[] toSelect = state.getToSelect();
    for (Object each : toSelect) {
      if (!myAdjustedSelection.containsKey(each)) {
        myToSelect.put(each, each);
      }
    }

    myCanRunRestore = state.myCanRunRestore;
  }
Beispiel #7
0
  @Override
  public void treeExpanded(TreeExpansionEvent event) {
    browseTree.setSelectionPath(event.getPath());

    Object node = event.getPath().getLastPathComponent();

    if (!expandedTimes.containsKey(node)) {
      for (Object nodeToRenew : event.getPath().getPath()) {
        expandedTimes.put(nodeToRenew, System.currentTimeMillis());
      }
    }
  }
  private ActionCallback processHangByParent(Set<Object> elements) {
    if (elements.isEmpty()) return new ActionCallback.Done();

    ActionCallback result = new ActionCallback(elements.size());
    for (Object hangElement : elements) {
      if (!myAdjustmentCause2Adjustment.containsKey(hangElement)) {
        processHangByParent(hangElement).notify(result);
      } else {
        result.setDone();
      }
    }
    return result;
  }
  private ActionCallback processHangByParent(Set<Object> elements) {
    if (elements.size() == 0) return new ActionCallback.Done();

    ActionCallback result = new ActionCallback(elements.size());
    for (Iterator<Object> iterator = elements.iterator(); iterator.hasNext(); ) {
      Object hangElement = iterator.next();
      if (!myAdjustmentCause2Adjustment.containsKey(hangElement)) {
        processHangByParent(hangElement).notify(result);
      } else {
        result.setDone();
      }
    }
    return result;
  }
 /**
  * Gets the activity or application icon for an activity. Uses the local icon cache for fast
  * repeated lookups.
  *
  * @param component Name of an activity.
  * @return A drawable, or {@code null} if neither the activity nor the application has an icon
  *     set.
  */
 private Drawable getActivityIconWithCache(ComponentName component) {
   // First check the icon cache
   String componentIconKey = component.flattenToShortString();
   // Using containsKey() since we also store null values.
   if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
     Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
     return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
   }
   // Then try the activity or application icon
   Drawable drawable = getActivityIcon(component);
   // Stick it in the cache so we don't do this lookup again.
   Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
   mOutsideDrawablesCache.put(componentIconKey, toCache);
   return drawable;
 }
  /**
   * Returns true if the session should yield the connection due to contention over available
   * database connections.
   *
   * @param connection The connection owned by the session.
   * @param connectionFlags The connection request flags.
   * @return True if the session should yield its connection.
   * @throws IllegalStateException if the connection was not acquired from this pool or if it has
   *     already been released.
   */
  public boolean shouldYieldConnection(SQLiteConnection connection, int connectionFlags) {
    synchronized (mLock) {
      if (!mAcquiredConnections.containsKey(connection)) {
        throw new IllegalStateException(
            "Cannot perform this operation "
                + "because the specified connection was not acquired "
                + "from this pool or has already been released.");
      }

      if (!mIsOpen) {
        return false;
      }

      return isSessionBlockingImportantConnectionWaitersLocked(
          connection.isPrimaryConnection(), connectionFlags);
    }
  }
Beispiel #12
0
  public String[] getColumn(String colName) {
    String[] returnArray = null;
    if (contentsByColumn != null) {
      if (contentsByColumn.containsKey(colName)) {
        returnArray = contentsByColumn.get(colName);
      } else {
        System.err.println("File does not contain that column!  Available columns are :");
        System.err.println(Arrays.toString(colHeaders));
      }
    } else {
      System.err.println(
          "CSVReader contentsByColumn is null!!  Check Parse output and file contents!");
      System.err.println("Reader name is " + CSVFileName);
      System.err.println(
          "Number of columns is " + numCols + " with names " + Arrays.toString(colHeaders));
    }

    return returnArray;
  }
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
    View rowView = convertView;
    if (rowView == null) {
      LayoutInflater inflater = activity.getLayoutInflater();
      rowView = inflater.inflate(R.layout.radius_list, null);
      ViewHolder viewHolder = new ViewHolder();
      viewHolder.itemName = (TextView) rowView.findViewById(R.id.friend_textName);
      viewHolder.distance = (TextView) rowView.findViewById(R.id.txt_distance);
      viewHolder.pic = (ImageView) rowView.findViewById(R.id.friend_img_contact);
      viewHolder.bar = (ProgressBar) rowView.findViewById(R.id.progressBar);

      rowView.setTag(viewHolder);
    }

    ViewHolder holder = (ViewHolder) rowView.getTag();

    if (friends != null && friends.size() > position) {
      // Get Branch item name and price and sets it in the list holder
      holder.itemName.setText(
          friends.get(position).UserFirstName + " " + friends.get(position).UserLastName);

      holder.distance.setText(
          onlyTwoDecimalPlaces(friends.get(position).DistanceFromCurrent) + "km");

      String imageUrl = friends.get(position).UserImage;
      if (imageMap.containsKey(imageUrl)) {
        holder.pic.setImageBitmap(imageMap.get(imageUrl));
        holder.pic.setMaxHeight(30);
        holder.pic.setMaxWidth(30);
        holder.pic.setMinimumHeight(30);
        holder.pic.setMinimumWidth(30);
        holder.bar.setVisibility(View.INVISIBLE);
      } else if (imageUrl.isEmpty() || imageUrl.equals("")) {
        holder.bar.setVisibility(View.INVISIBLE);
        holder.pic.setImageResource(R.drawable.profile_picture);
      } else {
        downloadThumbnail(imageUrl);
      }
    }

    return rowView;
  }
 private void invalidateToSelectWithRefsToParent(DefaultMutableTreeNode actionNode) {
   if (actionNode != null) {
     Object readyElement = myUi.getElementFor(actionNode);
     if (readyElement != null) {
       Iterator<Object> toSelect = myToSelect.keySet().iterator();
       while (toSelect.hasNext()) {
         Object eachToSelect = toSelect.next();
         if (readyElement.equals(myUi.getTreeStructure().getParentElement(eachToSelect))) {
           List<Object> children = myUi.getLoadedChildrenFor(readyElement);
           if (!children.contains(eachToSelect)) {
             toSelect.remove();
             if (!myToSelect.containsKey(readyElement)
                 && !myUi.getSelectedElements().contains(eachToSelect)) {
               addAdjustedSelection(eachToSelect, Conditions.alwaysFalse(), null);
             }
           }
         }
       }
     }
   }
 }
 private void loadDocument() {
   transcoder = null;
   failedToLoadDocument = true;
   if (uri == null) {
     return;
   }
   String parser = XMLResourceDescriptor.getXMLParserClassName();
   SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
   try {
     Document document;
     if (documentsMap.containsKey(uri)) document = documentsMap.get(uri);
     else {
       document = factory.createDocument(uri);
       documentsMap.put(uri, document);
     }
     transcoder = new SimpleImageTranscoder(document);
     failedToLoadDocument = false;
   } catch (IOException e) {
     Activator.logError("Error loading SVG file", e);
   }
 }
  public void Handle(Player player) {
    this.Task();

    String partner = this.marriagePlus.marriedPlayer.GetPartner(player.getName());

    Player marriedPlayer = this.marriagePlus.getServer().getPlayer(partner);

    CraftPlayer loveTo = (CraftPlayer) marriedPlayer;
    CraftPlayer loveFrom = (CraftPlayer) player;

    synchronized (players) {
      if (players.containsKey(marriedPlayer)) {
        players.remove(marriedPlayer);
        return;
      }

      if (marriedPlayer.isOnline()) {
        players.put(loveTo, 20);
        players.put(loveFrom, 20);
      }
    }
  }
Beispiel #17
0
  public static StackLine[] getLines(ItemStack stack) {
    if (LINE_CACHE.containsKey(stack)) {
      return LINE_CACHE.get(stack);
    }

    StackLine[] result = new StackLine[6];

    for (int i = 0; i < 6; ++i) {
      result[i] = new StackLine();
    }

    NBTTagCompound nbt = NBTUtils.getItemData(stack);

    if (nbt.hasKey("written")) {
      for (int i = 0; i < 6; ++i) {
        result[i].readFromNBT(nbt.getCompoundTag("line[" + i + "]"));
      }
    }

    LINE_CACHE.put(stack, result);

    return result;
  }
 /**
  * Adds a StatusListener to the list to be notified of StatusEvents.
  *
  * @param l The StatusListener to be notified.
  */
 public void addStatusListener(StatusListener l) {
   // don't add the listener if it's already in the list
   if (!statusListeners.containsKey(l)) {
     statusListeners.put(l, new WeakReference(l));
   }
 }
 public boolean isQueuedForSelection(Object element) {
   return myToSelect.containsKey(element);
 }
 private boolean isDescriptionPublished(IdentifiableTimeSeries i) {
   return seriesWithDescriptionsPublished.containsKey(i);
 }
 /**
  * Adds a TreeModelListener to the list of listeners to be notified.
  *
  * @param l The TreeModelListener to be added.
  */
 public void addTreeModelListener(TreeModelListener l) {
   if (!treeModelListeners.containsKey(l)) {
     treeModelListeners.put(l, new WeakReference(l));
   }
 }