Advertisement
Guest User

constructor

a guest
Feb 6th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. /**
  2.      * Constructor with a raw status line.
  3.      *
  4.      * @param line
  5.      *         A status line.
  6.      *
  7.      * @throws NullPointerException
  8.      *         {@code line} is {@code null}
  9.      *
  10.      * @throws IllegalArgumentException
  11.      *         The number of elements in {@code line} is less than 2.
  12.      *
  13.      * @throws NumberFormatException
  14.      *         Failed to parse the second element in {@code line}
  15.      *         as an integer.
  16.      */
  17.     StatusLine(String line)
  18.     {
  19.         // HTTP-Version Status-Code Reason-Phrase
  20.         String[] elements = line.split(" +", 3);
  21.  
  22.         if (elements.length < 2)
  23.         {
  24.             throw new IllegalArgumentException();
  25.         }
  26.  
  27.         mHttpVersion  = elements[0];
  28.         mStatusCode   = Integer.parseInt(elements[1]);
  29.         mReasonPhrase = (elements.length == 3) ? elements[2] : null;
  30.         mString       = line;
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement