class CTMTopicMapReader extends AbstractTopicMapReader {

  @Override
  protected TopicMapIF read(TopicMapStoreFactoryIF store_factory)
      throws IOException {
    TopicMapStoreIF store = store_factory.createStore();
    TopicMapIF topicmap = store.getTopicMap();

    // Set base address on in-memory store
    if ((store instanceof net.ontopia.topicmaps.impl.utils.AbstractTopicMapStore) &&
        store.getBaseAddress() == null)
      ((net.ontopia.topicmaps.impl.utils.AbstractTopicMapStore)store)
          .setBaseAddress(getBaseAddress());

    // Parse!
    try (Reader reader = makeReader((String) null, new CTMEncodingSniffer())) {
      CTMLexer lexer = new CTMLexer(reader);
      lexer.setDocuri(getBaseAddress().getAddress());
      CTMParser parser = new CTMParser(lexer);
      parser.setBase(getBaseAddress());
      parser.setTopicMap(topicmap, null);
      parser.init();
      parser.topicmap();
      reader.close();
    } catch (AntlrWrapException ex) {
      throw (IOException) ex.getException();
    } catch (RecognitionException ex) {
      throw new IOException("Lexical error at " + getBaseAddress().getAddress()
          + ":" + ex.line + ":" + ex.column + ": "+ ex.getMessage());
    } catch (TokenStreamRecognitionException e) {
      RecognitionException ex = e.recog;
      throw new IOException("Lexical error at " + getBaseAddress().getAddress()
          + ":" + ex.line + ":" + ex.column + ": "+ ex.getMessage());
    } catch (TokenStreamIOException ex) {
      throw ex.io;
    } catch (TokenStreamException ex) {
      throw new IOException("Lexical error: " + ex.getMessage());
    } catch (java.io.CharConversionException e) {
      throw new IOException("Problem decoding character encoding."
                            + "Did you declare the right encoding?");
    }

    ClassInstanceUtils.resolveAssociations2(topicmap);
    return topicmap;
  }

  public  CTMTopicMapReader(URL url);
  public  CTMTopicMapReader(URL url, LocatorIF base_address);
  public  CTMTopicMapReader(Reader reader, LocatorIF base_address);
  public  CTMTopicMapReader(InputStream stream, LocatorIF base_address);
  public  CTMTopicMapReader(File file);

}