Coverage Report - org.jscsi.target.connection.SessionType
 
Classes in this File Line Coverage Branch Coverage Complexity
SessionType
0%
0/11
0%
0/4
2
 
 1  
 package org.jscsi.target.connection;
 2  
 
 3  
 
 4  
 import org.jscsi.target.settings.TextKeyword;
 5  
 
 6  
 
 7  
 /**
 8  
  * The {@link SessionType} of a {@link TargetSession} determines which stages can be reached in the Full Feature Phase.
 9  
  * 
 10  
  * @author Andreas Ergenzinger
 11  
  */
 12  0
 public enum SessionType {
 13  
 
 14  
     /**
 15  
      * The session is a discovery session. The initiator is only allowed to issue request a list of available target and
 16  
      * close the connection.
 17  
      */
 18  0
     DISCOVERY(TextKeyword.DISCOVERY),
 19  
     /**
 20  
      * The session is a normal session. The initiator is allowed to issue all supported commands.
 21  
      */
 22  0
     NORMAL(TextKeyword.NORMAL);
 23  
 
 24  
     /**
 25  
      * The session type as a text parameter negotiation <i>value</i> (as used in <i>key-value</> pairs).
 26  
      */
 27  
     private final String value;
 28  
 
 29  
     /**
 30  
      * The constructor.
 31  
      * 
 32  
      * @param value the text parameter negotiation <i>value</i> (as used in <i>key-value</> pairs) describing this
 33  
      *            session type.
 34  
      */
 35  0
     private SessionType (final String value) {
 36  0
         this.value = value;
 37  0
     }
 38  
 
 39  
     public final String getValue () {
 40  0
         return value;
 41  
     }
 42  
 
 43  
     /**
 44  
      * Returns a {@link SessionType} based on the <i>value</i>, which must be either <code>Discovery</code> or
 45  
      * <code>Normal</code>. Otherwise the method will return <code>null</code>.
 46  
      * 
 47  
      * @param value <code>Discovery</code> or <code>Normal</code>
 48  
      * @return the specified {@link SessionType} or <code>null</code>
 49  
      */
 50  
     public static final SessionType getSessionType (final String value) {
 51  0
         final SessionType[] values = values();
 52  0
         for (SessionType s : values)
 53  0
             if (s.value.equals(value)) return s;
 54  0
         return null;
 55  
     }
 56  
 }