Package com.subgraph.orchid.directory

Source Code of com.subgraph.orchid.directory.DocumentParserFactoryImpl

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));
  }
}
TOP

Related Classes of com.subgraph.orchid.directory.DocumentParserFactoryImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.