logo
Adding Occurrences < A TMAPI Tutorial < < Home 

PrevUpNext

Adding Occurrences

In order to attach a reference Occurrence to a Topic, you have to create a Locator first. That is then used when a new occurrence is added to a topic:

Locator locSydOcc                = 
        tMap.createLocator ( "http://www.sydney.com.au/airport-transfers.htm" );
Occurrence ocSydAirportTransfers = 
        tAirportSydney.createOccurrence( locSydOcc, null, null );
We passed in null for the type and the scope of the occurrence as may fit here. Should we, though, want to type an occurrence, then we need yet another topic:
Topic tHomepage = tMap.createTopic();
tHomepage.createTopicName( "Homepage", null );

Locator locSydHome        = 
        tMap.createLocator ( "http://www.sydneyairport.com.au/SACL/default.htm" );
Occurrence ocSydAirportHP = 
        tAirportSydney.createOccurrence( locSydHome, tHomepage, null );

In a rather similar way we can also add occurrence values, i.e. those which allow us to affiliate text content with a topic. In our running example we add the airport 3-letter code to the 'Sydney Airport' topic:

Topic tAirportCode = tMap.createTopic();
tAirportCode.createTopicName( "Airport Code", null );
tAirportSydney.createOccurrence( "SYD", tAirportCode, null );