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
TheScopeclass determines whether a givenFreeColSpecObjectTypefulfills certain requirements.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.StringABILITY_ID_TAGprivate static java.lang.StringABILITY_VALUE_TAGprivate java.lang.StringabilityIdThe object identifier of anAbility.private booleanabilityValueThe value of anAbility.private static java.lang.StringMATCH_NEGATED_TAGprivate static java.lang.StringMATCHES_NULL_TAGprivate booleanmatchesNullTrue if the scope applies to a null object.private booleanmatchNegatedWhether the match is negated.private static java.lang.StringMETHOD_NAME_TAGprivate static java.lang.StringMETHOD_VALUE_TAGprivate java.lang.StringmethodNameThe name of anMethod.private java.lang.StringmethodValueTheStringrepresentation of the value of anMethod.private static java.lang.StringOLD_MATCH_NEGATED_TAGprivate static java.lang.StringOLD_MATCHES_NULL_TAGprivate static java.lang.StringOLD_METHOD_NAME_TAGprivate static java.lang.StringOLD_METHOD_VALUE_TAGstatic java.lang.StringTAGprivate java.lang.StringtypeThe identifier of aFreeColSpecObjectType, orOption.private static java.lang.StringTYPE_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 newScopeinstance from a stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanappliesTo(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.booleanequals(java.lang.Object o)java.lang.StringgetAbilityId()Gets the ability identifier.booleangetAbilityValue()java.lang.StringgetFeatureString()Get a string describing this scope for display within a feature.java.lang.StringgetKey()Get a key to display this scope with.private booleangetMatchesNull()Does this scope match null?booleangetMatchNegated()Is the match negated for this scope?java.lang.StringgetMethodName()java.lang.StringgetMethodValue()java.lang.StringgetType()java.lang.StringgetXMLTagName()Get the serialization tag for this object.inthashCode()protected voidreadAttributes(FreeColXMLReader xr)Reads the attributes of this object from an XML stream.voidsetAbilityId(java.lang.String newAbilityId)Sets the ability identifier.voidsetAbilityValue(boolean newAbilityValue)voidsetMatchesNull(boolean newMatchesNull)Set the match-null value.voidsetMatchNegated(boolean newMatchNegated)voidsetMethodName(java.lang.String newMethodName)voidsetMethodValue(java.lang.String newMethodValue)voidsetType(java.lang.String newType)java.lang.StringtoString()protected voidwriteAttributes(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
TheStringrepresentation 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 newScopeinstance from a stream.- Parameters:
xr- TheFreeColXMLReaderto 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- TheFreeColSpecObjectTypeto 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:
copyInin classFreeColObject- Type Parameters:
T- TheFreeColObjectsubclass 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:
writeAttributesin classFreeColObject- Parameters:
xw- TheFreeColXMLWriterto 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:
readAttributesin classFreeColObject- Parameters:
xr- TheFreeColXMLReaderto 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:
getXMLTagNamein classFreeColObject- Returns:
- The tag.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classFreeColObject
-
hashCode
public int hashCode()
- Overrides:
hashCodein classFreeColObject
-
toString
public java.lang.String toString()
- Overrides:
toStringin classFreeColObject
-
-