## SDAI file

Last update 2003-09-03

### Introduction

SDAI file contains the equivalent information as a part21 (ISO 10303-21) file, but in a binary encoded way which can be much faster processed and needs less storage space. SDAI file can be easily used for exchange.

SDAI file features:

- the format is inherently compressed (ZIP)
- it can easily be converted into the part21 (ISO 10303-21) or part28 (ISO 10303-28) format.
- it allows to include non-STEP files (e.g. jpeg or pdf) bound to an entity instance.
- it can contain several data sections, e.g. one for the ARM and one for the AIM population.
- the format supports all features of SDAI with a couple of extensions.

### Creating SdaiRepository to be stored in SDAI file:

If you want to create a SdaiRepository to be stored in SDAI file then use `createRepository()` method and pass path of SDAI file as a `location` (second) parameter. If the value of the `name` (first) parameter is null or an empty string "", then a SdaiRepository with name derived from SDAI file name will be created. If SdaiRepository with the specified or derived name already exists, then SdaiRepository with modified name (SdaiRepository name plus sequence number) will be created.

> Example
> `// create SdaiRepositories stored in SDAI files
> repo = s.createRepository("MyRepo1", "c:\\myrepos\\MyRepo.sdai");
> repo = s.createRepository("", "c:\\MyRepo2.sdai");
> repo = s.createRepository(null, "c:\\MyRepo2.sdai");
> `

If `createRepository()` method is called with `location` parameter set to null, then SdaiRepository is created into `sdairepos` directory and it's format depends on the value of an additional property `new.repository.format` in jsdai.properties file.

- if property `new.repository.format` does not exists or it's value is equal `DIR` then conventional SdaiRepository is created (SdaiRepository files are stored in SdaiRepository directory).
- if value of property `new.repository.format` is equal `SDAI` then SdaiRepository stored in SDAI file is created (SdaiRepository files are stored in one compressed SDAI file).

> Example
> `//fragment of jsdai.properties file
> new.repository.format = SDAI
> // create SdaiRepository stored in SDAI file in `sdairepos` directory
> repo = s.createRepository("MyRepo", null);
> `

### Linking SdaiRepository stored in SDAI file:

If you want to link an existing SdaiRepository stored in SDAI file then use `linkRepository()` method and pass path of SDAI file as a `location` (second) parameter. If the value of the `name` (first) parameter is null or an empty string "", then SdaiRepository name is derived from SDAI file name. If SdaiRepository with the specified or derived name already exists and `name` parameter was not null, then SdaiRepository with modified name (SdaiRepository name plus sequence number) is linked. If SdaiRepository with the specified or derived name already exists and `name` parameter was null, then `SdaiException` LC_NVLD is thrown.

> Example
> `// link SdaiRepositories stored in SDAI files
> rep = s.linkRepository("MyRepo1", "c:\\myrepos\\MyRepo.sdai");
> rep = s.linkRepository("", "c:\\MyRepo2.sdai");
> rep = s.linkRepository(null, "c:\\MyRepo2.sdai");
> `

During session start all SdaiRepositories (conventional and stored in SDAI files) located in `sdairepos` directory are automatically linked to `known_servers`.

### SDAI file format:

SDAI file format has several advantages:

1. Only one file per SdaiRepository is used. It is very simple to exchange such files between users.
2. Space used to store SdaiRepository is reduced. Over 50% of storage space is saved.

And drawbacks:

1. Reading and writing operations are slower. It is due compression/recompression of data stored in SDAI file.

SDAI file format specification