logo
Adding Topics with Names < A TMAPI Tutorial < < Home 

PrevUpNext

Adding Topics with Names

Given a map tMap, creating a topic object in there is straightforward:

Topic tAirportSydney = tMap.createTopic();
This, by itself, does not mean a lot, though. The topic has no further information, so we add a new topic name to it:
tAirportSydney.createTopicName( "Airport Sydney, Australia", null );
We pass in null for the scope to let the name be unconstrained.

Probably the next thing to do is to define the type of the topic. We have to make sure the typing topic is also in the map, and - being good citizens - we also add some topic name for it:

Topic tAirport = tMap.createTopic();
tAirport.createTopicName( "Airport", null );
Then we simply add that as type
tAirportSydney.addType( tAirport );

In the case that we need a scope for a topic name, we first have to make sure that all topics which compound the scope exist in the map. In our case we use the language to scope names (probably not the best use case of scope, but this is a different story):

Topic tGerman     = tMap.createTopic();
tGerman.createTopicName( "german language", null );

ArrayList alScope = new ArrayList();
alScope.add( tGerman );

tAirportSydney.createTopicName( "Flughafen Sydney, Australien", alScope );
After all scoping topics are added to a list, that is then used when actually adding a new topic name.