package com.subgraph.orchid.directory;
import java.nio.ByteBuffer;
import com.subgraph.orchid.ConsensusDocument;
import com.subgraph.orchid.KeyCertificate;
import com.subgraph.orchid.RouterDescriptor;
import com.subgraph.orchid.RouterMicrodescriptor;
import com.subgraph.orchid.directory.certificate.KeyCertificateParser;
import com.subgraph.orchid.directory.consensus.ConsensusDocumentParser;
import com.subgraph.orchid.directory.parsing.DocumentFieldParser;
import com.subgraph.orchid.directory.parsing.DocumentParser;
import com.subgraph.orchid.directory.parsing.DocumentParserFactory;
import com.subgraph.orchid.directory.router.RouterDescriptorParser;
import com.subgraph.orchid.directory.router.RouterMicrodescriptorParser;
public class DocumentParserFactoryImpl implements DocumentParserFactory {
public DocumentParser<KeyCertificate> createKeyCertificateParser(ByteBuffer buffer) {
return new KeyCertificateParser(new DocumentFieldParserImpl(buffer));
}
public DocumentParser<RouterDescriptor> createRouterDescriptorParser(ByteBuffer buffer, boolean verifySignatures) {
return new RouterDescriptorParser(new DocumentFieldParserImpl(buffer), verifySignatures);
}
public DocumentParser<RouterMicrodescriptor> createRouterMicrodescriptorParser(ByteBuffer buffer) {
buffer.rewind();
DocumentFieldParser dfp = new DocumentFieldParserImpl(buffer);
return new RouterMicrodescriptorParser(dfp);
}
public DocumentParser<ConsensusDocument> createConsensusDocumentParser(ByteBuffer buffer) {
return new ConsensusDocumentParser(new DocumentFieldParserImpl(buffer));
}
}