Example usage for java.util Observable Observable

List of usage examples for java.util Observable Observable

Introduction

In this page you can find the example usage for java.util Observable Observable.

Prototype


public Observable() 

Source Link

Document

Construct an Observable with zero Observers.

Usage

From source file:net.sourceforge.jasa.report.HistoricalDataReport.java

public HistoricalDataReport() {
    observableProxy = new Observable() {
        public void notifyObservers() {
            setChanged();/* ww w  . ja va 2s . c  om*/
            super.notifyObservers();
        }
    };
}

From source file:edu.cuny.cat.stat.HistoricalReport.java

public HistoricalReport() {
    asks = new LinkedList<Shout>();
    bids = new LinkedList<Shout>();
    sortedShouts = new TreeBag<Shout>(new ShoutComparator());
    matchedShouts = Collections.synchronizedSet(new HashSet<Shout>());
    shoutMap = Collections.synchronizedMap(new HashMap<String, Shout>());

    observableProxy = new Observable() {
        @Override//from ww w.  j  av a2  s.com
        public void notifyObservers() {
            setChanged();
            super.notifyObservers();
        }
    };
}

From source file:org.sakaiproject.sitestats.test.StatsUpdateManagerTest.java

@SuppressWarnings("unchecked")
public void testInvalidEvents() {
    // #1: send invalid events
    Event e3 = M_sum.buildEvent(new Date(), "unknown.event", "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e4 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "no_context", null, FakeData.USER_A_ID,
            "session-id-a");
    Event e5 = M_sum.buildEvent(new Date(), FakeData.EVENT_CHATNEW, "/chat/msg/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID, null, null);
    Event e6 = M_sum.buildEvent(new Date(), StatsManager.SITEVISIT_EVENTID, "no_context", null,
            FakeData.USER_A_ID, "session-id-a");
    Event e7 = M_sum.buildEvent(new Date(), StatsManager.SITEVISIT_EVENTID, "no_context", null, null, null);
    Event e8 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/group/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e9 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/group/" + FakeData.SITE_A_ID,
            FakeData.SITE_A_ID, null, null);
    Event e10 = M_sum.buildEvent(new Date(), StatsManager.SITEVISIT_EVENTID,
            "/presence/non_existent_site-presence", null, FakeData.USER_A_ID, "session-id-a");
    Event e11 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/user/something",
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e12 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/attachment/something",
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e13 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/group/small_ref",
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e14 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/group/private",
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e15 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "/content/group-user/small_ref",
            FakeData.SITE_A_ID, FakeData.USER_A_ID, "session-id-a");
    Event e16 = M_sum.buildEvent(new Date(), FakeData.EVENT_CONTENTNEW, "", FakeData.SITE_A_ID,
            FakeData.USER_A_ID, "session-id-a");
    ((Observer) M_sum).update(new Observable(), "this_is_not_an_event");
    assertTrue(M_sum.collectEvents((List<Event>) null));
    assertTrue(M_sum.collectEvents(new ArrayList<Event>()));
    assertTrue(M_sum.collectEvents(new Event[] {}));
    assertTrue(M_sum//ww  w .  jav  a 2 s.  c o m
            .collectEvents(Arrays.asList(null, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16)));
    assertTrue(M_sum.collectEvents(
            new Event[] { null, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16 }));
    assertTrue(M_sum.collectEvent(null));
    assertTrue(M_sum.collectEvent(e3));
    assertTrue(M_sum.collectEvent(e4));
    assertTrue(M_sum.collectEvent(e5));
    assertTrue(M_sum.collectEvent(e6));
    assertTrue(M_sum.collectEvent(e7));
    assertTrue(M_sum.collectEvent(e8));
    assertTrue(M_sum.collectEvent(e9));
    assertTrue(M_sum.collectEvent(e10));
    assertTrue(M_sum.collectEvent(e11));
    assertTrue(M_sum.collectEvent(e12));
    assertTrue(M_sum.collectEvent(e13));
    assertTrue(M_sum.collectEvent(e14));
    assertTrue(M_sum.collectEvent(e15));
    assertTrue(M_sum.collectEvent(e16));
    // #1: SST_EVENTS
    List<EventStat> r1 = (List<EventStat>) db.getResultsForClass(EventStatImpl.class);
    assertEquals(0, r1.size());
    // #1: SST_SITEVISITS
    List<SiteVisits> r2 = (List<SiteVisits>) db.getResultsForClass(SiteVisitsImpl.class);
    assertEquals(0, r2.size());
    // #1: SST_SITEACTIVITY
    List<SiteActivity> r3 = (List<SiteActivity>) db.getResultsForClass(SiteActivityImpl.class);
    assertEquals(0, r3.size());
    // #1: SST_RESOURCES
    List<ResourceStat> r4 = (List<ResourceStat>) db.getResultsForClass(ResourceStatImpl.class);
    assertEquals(0, r4.size());
}