Exemplo n.º 1
0
  public static NxsDataset instanciate(final URI destination, final boolean withWriteAccess)
      throws NoResultException {
    NxsDataset dataset = null;
    String filePath = destination.getPath();
    if (filePath != null) {
      try {
        dataset = new NxsDataset(new File(filePath), withWriteAccess);
        String fragment = destination.getFragment();

        if (fragment != null && !fragment.isEmpty()) {
          IGroup group = dataset.getRootGroup();
          try {
            String path = URLDecoder.decode(fragment, "UTF-8");
            for (IContainer container : group.findAllContainerByPath(path)) {
              if (container.getModelType().equals(ModelType.Group)) {
                dataset.mRootPhysical = (IGroup) container;
                break;
              }
            }
          } catch (UnsupportedEncodingException e) {
            Factory.getLogger().log(Level.WARNING, e.getMessage());
          }
        }
      } catch (Exception e) {
        throw new NoResultException(e);
      }
    }
    return dataset;
  }