public abstract class Entry extends Object
Entry
objects are used by instances SettingsNegotiator
during text negotiation of connection and
session parameter. For all parameters that are either declared by the iSCSI initiator or negotiated between the
initiator and the target a separate Entry
takes care of processing the respective key=value pair and
returning the negotiated value, if appropriate.
For brevity, the term "negotiated" will be used in the following in a way that can either mean "declared or negotiated", unless the distinction is evident by context.
Modifier and Type | Field and Description |
---|---|
protected boolean |
alreadyNegotiated
This variable is used to detect illegal attempts to renegotiate a previously negotiated or declared text
parameter.
|
protected KeySet |
keySet
|
protected NegotiationStatus |
negotiationStatus
This variable specifies the progress and necessity of negotiating the parameter managed by this
Entry . |
protected NegotiationType |
negotiationType
Specifies if the
Entry 's parameter is declared or negotiated. |
protected Use |
use
Determines during which stages this
Entry 's parameters may be negotiated. |
protected Object |
value
The currently valid value or
null . |
Constructor and Description |
---|
Entry(KeySet keySet,
NegotiationType negotiationType,
Use use,
NegotiationStatus negotiationStatus,
Object defaultValue)
Abstract constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkAccepted()
|
abstract Entry |
copy()
Returns an exact copy of this
Entry . |
Boolean |
getBooleanValue()
Returns the negotiated (or default) value as a
Boolean . |
Integer |
getIntegerValue()
Returns the negotiated (or default) value as an
Integer . |
NegotiationStatus |
getNegotiationStatus()
Returns
negotiationStatus . |
String |
getStringValue()
Returns the negotiated (or default) value as a
String . |
protected abstract boolean |
inProtocolValueRange(Object values)
This method is used for checking if a sub-class-specific
Object , representing a single, a range, or a
list of values sent by the initiator, is illegal, according to the iSCSI standard. |
boolean |
matchKey(String key)
|
boolean |
negotiate(TargetServer target,
org.jscsi.parser.login.LoginStage loginStage,
boolean leadingConnection,
boolean initialPdu,
String key,
String values,
Collection<String> responseKeyValuePairs)
This method is used for negotiating or declaring the
Entry 's parameter. |
protected abstract Object |
parseOffer(TargetServer target,
String values)
|
protected abstract void |
processDeclaration(Object values)
|
protected abstract String |
processNegotiation(Object values)
Receives a sub-class-specific
Object , representing a list, a range, or a single legal parameter value
offered by the initiator and tries to select a value from that offer. |
void |
resetAlreadyNegotiated()
Sets
alreadyNegotiated back to false . |
protected final KeySet keySet
protected final NegotiationType negotiationType
Entry
's parameter is declared or negotiated.protected final Use use
Entry
's parameters may be negotiated.protected NegotiationStatus negotiationStatus
Entry
.protected Object value
null
.protected boolean alreadyNegotiated
This variable will be set back to false
after each negotiation task (login phase, or text parameter
negotiation stage). Renegotiation accross stages/tasks can be prevented by initializing the use
variable
accordingly.
resetAlreadyNegotiated()
public Entry(KeySet keySet, NegotiationType negotiationType, Use use, NegotiationStatus negotiationStatus, Object defaultValue)
keySet
- contains all relevant keysnegotiationType
- declared or negotiateduse
- determines under which circumstances the parameter may be negotiatednegotiationStatus
- indicates whether there is a default value or if the parameter must be negotiateddefaultValue
- the default value or null
protected abstract Object parseOffer(TargetServer target, String values)
String
parameter and returns a sub-class-specific Object
which represents the
the specified value part a key=value pair.values
- the value part of a key=value pairObject
or null
if the parameter violated the expected formatpublic final boolean negotiate(TargetServer target, org.jscsi.parser.login.LoginStage loginStage, boolean leadingConnection, boolean initialPdu, String key, String values, Collection<String> responseKeyValuePairs)
Entry
's parameter.loginStage
- specifying the current stage or phase of the connection whose parameters are to be negotiatedleadingConnection
- true
if the connection is the first connection in its session,
false
if notinitialPdu
- true
if the key=value pair parameters have been sent in the first login
ProtocolDataUnit
from the initiator, false
if thy have notkey
- the key part from the received key=value pairvalues
- the value part from the received key=value pairresponseKeyValuePairs
- where the reply key=value pair will be added to if necessarytrue
if everything went fine, false
if errors occuredpublic void resetAlreadyNegotiated()
alreadyNegotiated
back to false
.
This method must be used at the end of each negotiation task, i.e. at the end of the login phase and the FFP text negotiation stage.
public Boolean getBooleanValue() throws OperationNotSupportedException
Boolean
.Boolean
OperationNotSupportedException
- if value
is not of the boolean typepublic Integer getIntegerValue() throws OperationNotSupportedException
Integer
.Integer
OperationNotSupportedException
- if value
is not of the integer typepublic String getStringValue() throws OperationNotSupportedException
String
.String
OperationNotSupportedException
- if value
is not a String
public final boolean matchKey(String key)
protected abstract boolean inProtocolValueRange(Object values)
Object
, representing a single, a range, or a
list of values sent by the initiator, is illegal, according to the iSCSI standard.values
- a sub-class-specific Object
, representing a single, a range, or a list of values sent by
the initiatorfalse
if the iSCSI standard has been violated, true
if notprotected abstract void processDeclaration(Object values)
Object
, representing a legal parameter value declared by the initiator and
accepts it as the new value
.values
- sub-class-specific representation of a single value declared by the initiatorprotected abstract String processNegotiation(Object values)
Object
, representing a list, a range, or a single legal parameter value
offered by the initiator and tries to select a value from that offer. If none of the offered values is supported
by the jSCSI Target, null
is returned, otherwise the selection is accepted as the new value
and returned as a String
. value
.values
- a sub-class-specific Object
, representing a list, a range, or a single legal parameter
value offered by the initiatornull
, if the initiator's offer does not overlap with the
values supported by the jSCSI Targetpublic final NegotiationStatus getNegotiationStatus()
negotiationStatus
.negotiationStatus
public abstract Entry copy()
Entry
.Entry
.public boolean checkAccepted()
true
if negotiationStatus
is NegotiationStatus.ACCEPTED
, false
if notCopyright © 2013 University of Konstanz, Distributed Systems Group. All Rights Reserved.