Package net.sf.freecol.common.model
Class Scope
- java.lang.Object
-
- net.sf.freecol.common.model.FreeColObject
-
- net.sf.freecol.common.model.Scope
-
- All Implemented Interfaces:
java.lang.Comparable<FreeColObject>
,ObjectWithId
- Direct Known Subclasses:
Operand
public class Scope extends FreeColObject
TheScope
class determines whether a givenFreeColSpecObjectType
fulfills certain requirements.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
ABILITY_ID_TAG
private static java.lang.String
ABILITY_VALUE_TAG
private java.lang.String
abilityId
The object identifier of anAbility
.private boolean
abilityValue
The value of anAbility
.private static java.lang.String
MATCH_NEGATED_TAG
private static java.lang.String
MATCHES_NULL_TAG
private boolean
matchesNull
True if the scope applies to a null object.private boolean
matchNegated
Whether the match is negated.private static java.lang.String
METHOD_NAME_TAG
private static java.lang.String
METHOD_VALUE_TAG
private java.lang.String
methodName
The name of anMethod
.private java.lang.String
methodValue
TheString
representation of the value of anMethod
.private static java.lang.String
OLD_MATCH_NEGATED_TAG
private static java.lang.String
OLD_MATCHES_NULL_TAG
private static java.lang.String
OLD_METHOD_NAME_TAG
private static java.lang.String
OLD_METHOD_VALUE_TAG
static java.lang.String
TAG
private java.lang.String
type
The identifier of aFreeColSpecObjectType
, orOption
.private static java.lang.String
TYPE_TAG
-
Fields inherited from class net.sf.freecol.common.model.FreeColObject
ARRAY_SIZE_TAG, DEFAULT_CLASS_INDEX, fcoComparator, ID_ATTRIBUTE_TAG, logger, PARTIAL_ATTRIBUTE_TAG, VALUE_TAG
-
-
Constructor Summary
Constructors Constructor Description Scope()
Deliberately empty constructor.Scope(FreeColXMLReader xr)
Creates a newScope
instance from a stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
appliesTo(FreeColObject object)
Does this scope apply to a given object?<T extends FreeColObject>
booleancopyIn(T other)
Copy another FreeColObject into this one if it is compatible.boolean
equals(java.lang.Object o)
java.lang.String
getAbilityId()
Gets the ability identifier.boolean
getAbilityValue()
java.lang.String
getFeatureString()
Get a string describing this scope for display within a feature.java.lang.String
getKey()
Get a key to display this scope with.private boolean
getMatchesNull()
Does this scope match null?boolean
getMatchNegated()
Is the match negated for this scope?java.lang.String
getMethodName()
java.lang.String
getMethodValue()
java.lang.String
getType()
java.lang.String
getXMLTagName()
Get the serialization tag for this object.int
hashCode()
protected void
readAttributes(FreeColXMLReader xr)
Reads the attributes of this object from an XML stream.void
setAbilityId(java.lang.String newAbilityId)
Sets the ability identifier.void
setAbilityValue(boolean newAbilityValue)
void
setMatchesNull(boolean newMatchesNull)
Set the match-null value.void
setMatchNegated(boolean newMatchNegated)
void
setMethodName(java.lang.String newMethodName)
void
setMethodValue(java.lang.String newMethodValue)
void
setType(java.lang.String newType)
java.lang.String
toString()
protected void
writeAttributes(FreeColXMLWriter xw)
Write the attributes of this object to a stream.-
Methods inherited from class net.sf.freecol.common.model.FreeColObject
addAbility, addFeatures, addModifier, addPropertyChangeListener, addPropertyChangeListener, apply, apply, applyModifiers, applyModifiers, arrayKey, compareIds, compareTo, containsAbilityKey, containsModifierKey, copy, copy, copy, copy, copyInCast, dumpObject, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAbilities, getAbilities, getAbilities, getAbilities, getClassIndex, getDefenceModifiers, getDisplayObject, getFeatureContainer, getFreeColObjectClass, getFreeColObjectClassByName, getGame, getId, getIdNumber, getIdType, getIdTypeByName, getModifiers, getModifiers, getModifiers, getModifiers, getObjectClassIndex, getPropertyChangeListeners, getPropertyChangeListeners, getPropertyChangeSupport, getSortedAbilities, getSortedModifiers, getSpecification, getSuffix, getSuffix, hasAbility, hasAbility, hasAbility, hasListeners, hasModifier, hasModifier, hasModifier, idEquals, invokeMethod, logFreeColObjects, readChild, readChildren, readFromXML, readFromXMLPartial, removeAbilities, removeAbility, removeFeatures, removeModifier, removeModifiers, removePropertyChangeListener, removePropertyChangeListener, save, save, save, save, serialize, serialize, serialize, serialize, setGame, setId, setSpecification, toXML, toXML, toXMLPartial, toXMLPartial, writeChildren
-
-
-
-
Field Detail
-
TAG
public static final java.lang.String TAG
- See Also:
- Constant Field Values
-
type
private java.lang.String type
The identifier of aFreeColSpecObjectType
, orOption
.
-
abilityId
private java.lang.String abilityId
The object identifier of anAbility
.
-
abilityValue
private boolean abilityValue
The value of anAbility
.
-
methodName
private java.lang.String methodName
The name of anMethod
.
-
methodValue
private java.lang.String methodValue
TheString
representation of the value of anMethod
.
-
matchesNull
private boolean matchesNull
True if the scope applies to a null object.
-
matchNegated
private boolean matchNegated
Whether the match is negated.
-
ABILITY_ID_TAG
private static final java.lang.String ABILITY_ID_TAG
- See Also:
- Constant Field Values
-
ABILITY_VALUE_TAG
private static final java.lang.String ABILITY_VALUE_TAG
- See Also:
- Constant Field Values
-
MATCH_NEGATED_TAG
private static final java.lang.String MATCH_NEGATED_TAG
- See Also:
- Constant Field Values
-
MATCHES_NULL_TAG
private static final java.lang.String MATCHES_NULL_TAG
- See Also:
- Constant Field Values
-
METHOD_NAME_TAG
private static final java.lang.String METHOD_NAME_TAG
- See Also:
- Constant Field Values
-
METHOD_VALUE_TAG
private static final java.lang.String METHOD_VALUE_TAG
- See Also:
- Constant Field Values
-
TYPE_TAG
private static final java.lang.String TYPE_TAG
- See Also:
- Constant Field Values
-
OLD_MATCH_NEGATED_TAG
private static final java.lang.String OLD_MATCH_NEGATED_TAG
- See Also:
- Constant Field Values
-
OLD_MATCHES_NULL_TAG
private static final java.lang.String OLD_MATCHES_NULL_TAG
- See Also:
- Constant Field Values
-
OLD_METHOD_NAME_TAG
private static final java.lang.String OLD_METHOD_NAME_TAG
- See Also:
- Constant Field Values
-
OLD_METHOD_VALUE_TAG
private static final java.lang.String OLD_METHOD_VALUE_TAG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Scope
public Scope()
Deliberately empty constructor.
-
Scope
public Scope(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Creates a newScope
instance from a stream.- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is an error reading the stream.
-
-
Method Detail
-
getKey
public java.lang.String getKey()
Get a key to display this scope with.- Returns:
- A suitable key, or null if none found.
-
getFeatureString
public java.lang.String getFeatureString()
Get a string describing this scope for display within a feature.- Returns:
- A suitable string.
-
getMatchesNull
private boolean getMatchesNull()
Does this scope match null?- Returns:
- True if this scope matches null.
-
setMatchesNull
public void setMatchesNull(boolean newMatchesNull)
Set the match-null value. Public for the test suite.- Parameters:
newMatchesNull
- The new match-null value.
-
getMatchNegated
public boolean getMatchNegated()
Is the match negated for this scope?- Returns:
- True if this match is negated.
-
setMatchNegated
public void setMatchNegated(boolean newMatchNegated)
-
getType
public java.lang.String getType()
-
setType
public void setType(java.lang.String newType)
-
getAbilityId
public java.lang.String getAbilityId()
Gets the ability identifier.- Returns:
- The ability id.
-
setAbilityId
public void setAbilityId(java.lang.String newAbilityId)
Sets the ability identifier.- Parameters:
newAbilityId
- The new ability id.
-
getAbilityValue
public boolean getAbilityValue()
-
setAbilityValue
public void setAbilityValue(boolean newAbilityValue)
-
getMethodName
public java.lang.String getMethodName()
-
setMethodName
public void setMethodName(java.lang.String newMethodName)
-
getMethodValue
public java.lang.String getMethodValue()
-
setMethodValue
public void setMethodValue(java.lang.String newMethodValue)
-
appliesTo
public boolean appliesTo(FreeColObject object)
Does this scope apply to a given object?- Parameters:
object
- TheFreeColSpecObjectType
to test.- Returns:
- True if the scope is applicable.
-
copyIn
public <T extends FreeColObject> boolean copyIn(T other)
Copy another FreeColObject into this one if it is compatible.- Overrides:
copyIn
in classFreeColObject
- Type Parameters:
T
- TheFreeColObject
subclass of the object to copy in.- Parameters:
other
- The other object.- Returns:
- True if the copy in is succesful.
-
writeAttributes
protected void writeAttributes(FreeColXMLWriter xw) throws javax.xml.stream.XMLStreamException
Write the attributes of this object to a stream. To be overridden if required by any object that has attributes and uses the toXML(FreeColXMLWriter, String) call.- Overrides:
writeAttributes
in classFreeColObject
- Parameters:
xw
- TheFreeColXMLWriter
to write to.- Throws:
javax.xml.stream.XMLStreamException
- if there are any problems writing to the stream.
-
readAttributes
protected void readAttributes(FreeColXMLReader xr) throws javax.xml.stream.XMLStreamException
Reads the attributes of this object from an XML stream.- Overrides:
readAttributes
in classFreeColObject
- Parameters:
xr
- TheFreeColXMLReader
to read from.- Throws:
javax.xml.stream.XMLStreamException
- if there is a problem reading the stream.
-
getXMLTagName
public java.lang.String getXMLTagName()
Get the serialization tag for this object.- Specified by:
getXMLTagName
in classFreeColObject
- Returns:
- The tag.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classFreeColObject
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classFreeColObject
-
toString
public java.lang.String toString()
- Overrides:
toString
in classFreeColObject
-
-