@NotNull
  @Override
  public SModel load(@NotNull DataSource dataSource, @NotNull Map<String, String> options)
      throws IOException {
    if (!(dataSource instanceof StreamDataSource)) {
      throw new UnsupportedDataSourceException(dataSource);
    }

    StreamDataSource source = (StreamDataSource) dataSource;
    SModelHeader binaryModelHeader;
    try {
      binaryModelHeader = BinaryPersistence.readHeader(source);
    } catch (ModelReadException e) {
      if (e.getCause() instanceof IOException) {
        throw (IOException) e.getCause();
      }
      throw new IOException(e.getMessageEx(), e);
    }
    if (Boolean.parseBoolean(options.get(MetaModelInfoProvider.OPTION_KEEP_READ_METAINFO))) {
      binaryModelHeader.setMetaInfoProvider(
          new StuffedMetaModelInfo(
              new RegularMetaModelInfo(binaryModelHeader.getModelReference())));
    }
    return new DefaultSModelDescriptor(new PersistenceFacility(this, source), binaryModelHeader);
  }
Beispiel #2
0
 @NotNull
 @Override
 public Iterable<Problem> getProblems() {
   return Collections.<Problem>singleton(
       new PersistenceProblem(
           Kind.Load,
           myCause == null ? "Couldn't read model." : myCause.getMessageEx(),
           null,
           true));
 }