Package java.lang.ref

Examples of java.lang.ref.SoftReference


   * messageId contains the persistent name of this notification.
   */
  private String messageId;

  MessageSoftRef(Message msg) {
    this.softRef = new SoftReference(msg);
    this.stamp = msg.stamp;
    if (msg.isPersistent()) {
      name = msg.toStringId();
      if (msg.not.detachable && !msg.not.detached) {
        messageId = msg.not.getMessageId();
View Full Code Here


      return ref;

    Message msg;
    try {
      msg = Message.load(name);
      softRef = new SoftReference(msg);
      if (logmon.isLoggable(BasicLevel.DEBUG))
        logmon.log(BasicLevel.DEBUG, "SoftReference: reload from disk " + msg);
    } catch (Exception exc) {
      logmon.log(BasicLevel.ERROR, "SoftReference: Can't load message " + name, exc);
      throw new TransactionError(exc);
View Full Code Here

      mLastMessages.remove(key);
    }
    else if (command.equals("PART"))
    {
      HashMap last_channels = null;
      SoftReference reference = (SoftReference)mLastMessages.get(key);
      if (last_channels != null)
      {
        last_channels.remove(fullMessage.getParameters().get(0));
      }
    }
View Full Code Here

    }
   
    String key = getKey(bot, nick);
   
    HashMap last_channels = null;
    SoftReference reference = (SoftReference)mLastMessages.get(key);
    if (reference !=null)
    {
      last_channels = (HashMap)reference.get();
    }

    Matcher detect_matcher = DETECT.matcher(fullMessage.getTrailing());
    if (detect_matcher.matches())
    {
      if (null == last_channels)
      {
        return;
      }
     
      String last_log = (String)last_channels.get(channel.getName());
      if (null == last_log)
      {
        return;
      }
         
      try
      {
        Pattern log_pattern = Pattern.compile(detect_matcher.group(1));
        Matcher log_matcher = log_pattern.matcher(last_log);
        String result = null;
        if ("g".equals(detect_matcher.group(3)))
        {
          result = log_matcher.replaceAll(detect_matcher.group(2));
        }
        else
        {
          result = log_matcher.replaceFirst(detect_matcher.group(2));
        }

        if (!last_log.equals(result))
        {
          if (result.length() > 120)
          {
            result = result.substring(0, 120);
          }
             
          channel.send(nick+": "+result);
        }
      }
      catch (PatternSyntaxException e)
      {
        List list = StringUtils.split(e.getMessage(), "\n");
        Iterator list_it = list.iterator();
        boolean first = true;
        while (list_it.hasNext())
        {
          if (first)
          {
            channel.send(nick+": your regular expression was not valid, "+list_it.next());
          }
          else
          {
            channel.send(nick+": "+list_it.next());
          }
          first = false;
        }
      }
    }
    else
    {
      if (null == last_channels)
      {
        last_channels = new HashMap();
        mLastMessages.put(key, new SoftReference(last_channels));
      }
     
      last_channels.put(channel.getName(), fullMessage.getTrailing());
    }
  }
View Full Code Here

    private String            toString;

    public ReaperTask(ReapableCache cache)
    {
        this.toString  = cache.toString();
        this.reference = new SoftReference(cache);
    }
View Full Code Here

    public boolean register(Cache newCache) {
        if (enableCacheTrace) {
            synchronized (cacheSet) {
                defragCacheSet();
                return cacheSet.add(new SoftReference(newCache, cacheQueue));
            }
        } else {
            return false;
        }
    }
View Full Code Here

    public boolean register(MeasurableCache newMeasurableCache) {
        if (enableCacheTrace) {
            synchronized (measurableCacheSet) {
                defragMeasurableCacheSet();
                return measurableCacheSet.add(new SoftReference(newMeasurableCache, measurableCacheQueue));
            }
        } else {
            return false;
        }
    }
View Full Code Here

    if (bCache) {
      oRefObj = oMicrosites.get(sURI);

      if (null == oRefObj) {
        oRetObj = new Microsite(sURI, bValidateXML);
        oMicrosites.put(sURI, new SoftReference(oRetObj));
      }
      else {
        oRetObj = (Microsite) ( (SoftReference) oRefObj).get();
        if (null == oRetObj)
          oRetObj = new Microsite(sURI, bValidateXML);
View Full Code Here

  public Image getImage() throws JRException
  {
    if (awtImageRef == null || awtImageRef.get() == null)
    {
      Image awtImage = JRImageLoader.loadImage(getImageData());
      awtImageRef = new SoftReference(awtImage);
    }
    return (Image) awtImageRef.get();
  }
View Full Code Here

        // *********************************************************
        // Assign SoftReference to File cached in-memory as a String

        oReplaced = new String(cBuffer);
        oFileStr = new SoftReference(oReplaced);

      } // fi (oReplaced)

    } // fi (bHasReplacements)

View Full Code Here

TOP

Related Classes of java.lang.ref.SoftReference

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.