Creating an empty slot with the API

As the class IltEmptySlotextends the class IltCard, the API to create an empty slot instance in a shelf is similar to the API for creating a card.

How to create an empty slot with the API

The following sample updates the sample in Creating a card with the API.
IlpDataSource dataSource = new IltDefaultDataSource();
// create shelf, set its position and add to data sources
IltShelf s1 = new IltShelf(3, 30, 90, 0);
s1.setAttributeValue(IltShelf.PositionAttribute, new IlpPoint(20, 50));
dataSource.addObject(s1);

// create empty slot, set its position (relative to the shelf slots) and
// add to data sources
IltEmptySlot c1 = new IltEmptySlot(null, "card");
c1.setAttributeValue(IltEmptySlot.PositionAttribute, 
  new IlpShelfItemPosition(0, 0, 1, 1));
dataSource.addObject(c1);

// set parent-child relationship
dataSource.setParent(c1.getIdentifier(), s1.getIdentifier());
The result looks like this:
emptyslotAPI.gif
An Empty Slot in a Shelf

How to create a shelf with two empty slots

The following code creates a shelf with two empty slots, one showing an alarm.
IltDefaultDataSource dataSource = new IltDefaultDataSource();
IltShelf s1 = new IltShelf(4, 20, 100, 0);
s1.setAttributeValue(IltShelf.PositionAttribute, new IlpPoint(50, 50));
dataSource.addObject(s1);
IltEmptySlot e0 = new IltEmptySlot(null, "e0");
e0.setAttributeValue(IltEmptySlot.PositionAttribute, 
  new IlpShelfItemPosition(0, 0, 1, 1));
dataSource.addObject(e0);
IltEmptySlot e2 = new IltEmptySlot(new IltOSIObjectState(), "e2");
e2.setState(IltOSI.State.Administrative.Locked);
e2.getAlarmState().setNewAlarmCount(IltAlarm.Severity.Critical, 1);
e2.setAttributeValue(IltEmptySlot.PositionAttribute, 
  new IlpShelfItemPosition(2, 0, 1, 1));
dataSource.addObject(e2);
dataSource.setParent(e0.getIdentifier(), s1.getIdentifier());
dataSource.setParent(e2.getIdentifier(), s1.getIdentifier());
The result looks like this:
Image4.gif
A shelf with two empty slots, one of them showing an alarm