Code Search for Developers
 
 
  

AbstractAnalyser.java from Tea Stats at Krugle


Show AbstractAnalyser.java syntax highlighted

package net.time4tea.webstats.analyser;

import net.time4tea.webstats.analyser.extractor.ExtractionException;
import net.time4tea.webstats.analyser.extractor.key.KeyFinder;
import net.time4tea.webstats.analyser.extractor.value.ValueFinder;
import net.time4tea.webstats.jms.EnvironmentException;
import net.time4tea.webstats.process.Processor;
import net.time4tea.webstats.record.Record;
import net.time4tea.webstats.statistic.StatisticMap;
import net.time4tea.webstats.statistic.repo.StatisticMapRepository;
import net.time4tea.webstats.util.Bug;
import org.hamcrest.Matcher;

/**
 * Originally richja 12-Jul-2007
 */
public class AbstractAnalyser<T extends Record> implements Processor<T> {
    protected String name;
    protected StatisticMapRepository statisticMapRepository;
    protected Matcher<T> filter;
    protected KeyFinder<T> visitor;
    protected ValueFinder valueFinder;

    public AbstractAnalyser(String name, Matcher<T> filter, StatisticMapRepository statisticMapRepository, KeyFinder<T> keyFinder, ValueFinder valueFinder) {
        this.name = name;
        this.visitor = keyFinder;
        this.statisticMapRepository = statisticMapRepository;
        this.valueFinder = valueFinder;
        this.filter = filter;
    }

    public boolean process(T record) throws EnvironmentException {
        if (record == null) {
            return false;
        }

        if (filter.matches(record)) {
            String key = null;
            try {
                key = visitor.getKey(record);
            }
            catch (ExtractionException e) {
                throw new Bug("Can't get value from record", e);
            }
            if (key != null) {
                getStatisticMap(record).hit(key, valueFinder.getValue(record));
            }
        }

        return true;
    }

    protected StatisticMap getStatisticMap(T record) throws EnvironmentException {
        return statisticMapRepository.getStatisticMapForInstant(name, record.getDate());
    }
}




See more files for this project here

Tea Stats

Web log analyzer... Written in OO Perl, provides the usual host / page analysis. Can also do site graphing using graphviz, browser, os, worm and search engine identification, and country and session tracking.

Project homepage: http://sourceforge.net/projects/teastats
Programming language(s): Java
License: other

  composite/
    page/
      BrowserErrorsAnalyser.java
      FileTypesAnalyser.java
    session/
      AllHitsAnalyser.java
      BrowserAnalyser.java
      HowManyClicksPerSessionAnalyser.java
      LocationAnalyser.java
      SearchEngineTermAnalyser.java
      SearchEngineTermWordAnalyser.java
      SessionCountAnalyser.java
      SessionDurationAnalyser.java
  extractor/
    key/
      AttributeKeyFinder.java
      BeanKeyFinder.java
      BrowserKeyFinder.java
      ConcatenatingKeyFinder.java
      ConstantKeyFinder.java
      CountryKeyFinder.java
      DurationBucketKeyFinder.java
      FileTypeKeyFinder.java
      FirstPageKeyFinder.java
      HostKeyFinder.java
      KeyFinder.java
      LocationKeyFinder.java
      MethodKeyFinder.java
      PageKeyFinder.java
      QueryParamKeyFinder.java
      RefererHostKeyFinder.java
      SearchEngineTermKeyFinder.java
      SearchEngineWordKeyFinder.java
      SessionBandwidthKeyFinder.java
      SessionSizeKeyFinder.java
      StatusKeyFinder.java
    value/
      BytesValueFinder.java
      ConstantValueFinder.java
      SessionLengthValueFinder.java
      SessionSizeValueFinder.java
      ValueFinder.java
    CalendarFinder.java
    DayOfWeekFinder.java
    ExtractionException.java
  AbstractAnalyser.java
  Analyser.java
  SessionToPage.java