Class FirstWant


  • public class FirstWant
    extends java.lang.Object
    In the pack negotiation phase (protocol v0/v1), the client sends a list of wants. The first "want" line is special, as it (can) have a list of capabilities appended. E.g. "want oid cap1 cap2 cap3" Do not confuse this line with the first one in the reference advertisement, which is sent by the server, looks like "b8f7c471373b8583ced0025cfad8c9916c484b76 HEAD\0 cap1 cap2 cap3" and is parsed by the BasePackConnection.readAdvertisedRefs method. This class parses the input want line and holds the results: the actual want line and the capabilities.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String agent  
      private static java.lang.String AGENT_PREFIX  
      private java.util.Set<java.lang.String> capabilities  
      private java.lang.String line  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private FirstWant​(java.lang.String line, java.util.Set<java.lang.String> capabilities, java.lang.String agent)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static FirstWant fromLine​(java.lang.String line)
      Parse the first want line in the protocol v0/v1 pack negotiation.
      java.lang.String getAgent()  
      java.util.Set<java.lang.String> getCapabilities()  
      java.lang.String getLine()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • line

        private final java.lang.String line
      • capabilities

        private final java.util.Set<java.lang.String> capabilities
      • agent

        @Nullable
        private final java.lang.String agent
    • Constructor Detail

      • FirstWant

        private FirstWant​(java.lang.String line,
                          java.util.Set<java.lang.String> capabilities,
                          @Nullable
                          java.lang.String agent)
    • Method Detail

      • fromLine

        public static FirstWant fromLine​(java.lang.String line)
                                  throws PackProtocolException
        Parse the first want line in the protocol v0/v1 pack negotiation.
        Parameters:
        line - line from the client.
        Returns:
        an instance of FirstWant
        Throws:
        PackProtocolException - if the line doesn't follow the protocol format.
      • getLine

        public java.lang.String getLine()
        Returns:
        non-capabilities part of the line.
      • getCapabilities

        public java.util.Set<java.lang.String> getCapabilities()
        Returns:
        capabilities parsed from the line as an immutable set (excluding agent).
      • getAgent

        @Nullable
        public java.lang.String getAgent()
        Returns:
        client user agent parsed from the line.