Class AbstractScriptProcess
- java.lang.Object
-
- com.realtime.crossfire.jxclient.scripts.AbstractScriptProcess
-
- All Implemented Interfaces:
ScriptProcess,java.lang.Comparable<ScriptProcess>,java.lang.Runnable
- Direct Known Subclasses:
DefaultScriptProcess
public abstract class AbstractScriptProcess extends java.lang.Object implements java.lang.Runnable, ScriptProcess
Default implementation forScriptProcesses.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractScriptProcess(int scriptId, @NotNull java.lang.String filename, @NotNull CommandQueue commandQueue, @NotNull CrossfireServerConnection crossfireServerConnection, @NotNull Stats stats, @NotNull FloorView floorView, @NotNull ItemSet itemSet, @NotNull java.lang.Iterable<Spell> spellsManager, @NotNull MapUpdaterState mapUpdaterState, @NotNull SkillSet skillSet)Creates a new instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddScriptProcessListener(@NotNull ScriptProcessListener scriptProcessListener)Adds aScriptProcessListenerto be notified.voidcommandSent(@NotNull java.lang.String cmd)Sends a message to the script process.intcompareTo(@NotNull ScriptProcess o)booleanequals(@Nullable java.lang.Object obj)@NotNull java.lang.StringgetFilename()Returns the script's filename.intgetScriptId()Returns the script ID identifying this script instance.inthashCode()protected abstract @Nullable java.lang.StringreadFromScript()Reads a line from the script process.voidrun()@NotNull java.lang.StringtoString()protected abstract @Nullable java.lang.StringwaitForTermination()Waits until the script has terminated.protected abstract voidwriteToScript(@NotNull java.lang.String data)Sends some data to the script process.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.realtime.crossfire.jxclient.scripts.ScriptProcess
killScript
-
-
-
-
Constructor Detail
-
AbstractScriptProcess
protected AbstractScriptProcess(int scriptId, @NotNull @NotNull java.lang.String filename, @NotNull @NotNull CommandQueue commandQueue, @NotNull @NotNull CrossfireServerConnection crossfireServerConnection, @NotNull @NotNull Stats stats, @NotNull @NotNull FloorView floorView, @NotNull @NotNull ItemSet itemSet, @NotNull @NotNull java.lang.Iterable<Spell> spellsManager, @NotNull @NotNull MapUpdaterState mapUpdaterState, @NotNull @NotNull SkillSet skillSet)Creates a new instance.- Parameters:
scriptId- the script ID identifying the new scriptfilename- the command including arguments to executecommandQueue- the command queue for sending commandscrossfireServerConnection- the server connectionstats- the stats instance to watchfloorView- the floor view to useitemSet- the item set instance to usespellsManager- the spells manager instance to usemapUpdaterState- the map updater state instance to useskillSet- the skill set for looking up skill names
-
-
Method Detail
-
getScriptId
public int getScriptId()
Description copied from interface:ScriptProcessReturns the script ID identifying this script instance.- Specified by:
getScriptIdin interfaceScriptProcess- Returns:
- the script ID
-
getFilename
@NotNull public @NotNull java.lang.String getFilename()
Description copied from interface:ScriptProcessReturns the script's filename.- Specified by:
getFilenamein interfaceScriptProcess- Returns:
- the script's filename
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
readFromScript
@Nullable protected abstract @Nullable java.lang.String readFromScript() throws java.io.IOExceptionReads a line from the script process.- Returns:
- the line or
nullif the script has exited - Throws:
java.io.IOException- if reading failed
-
waitForTermination
@Nullable protected abstract @Nullable java.lang.String waitForTermination()
Waits until the script has terminated.- Returns:
- the termination reason or
nullif the script exited normally
-
commandSent
public void commandSent(@NotNull @NotNull java.lang.String cmd)Description copied from interface:ScriptProcessSends a message to the script process.- Specified by:
commandSentin interfaceScriptProcess- Parameters:
cmd- the message to send
-
writeToScript
protected abstract void writeToScript(@NotNull @NotNull java.lang.String data) throws java.io.IOExceptionSends some data to the script process.- Parameters:
data- the data- Throws:
java.io.IOException- if sending fails
-
toString
@NotNull public @NotNull java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addScriptProcessListener
public void addScriptProcessListener(@NotNull @NotNull ScriptProcessListener scriptProcessListener)Description copied from interface:ScriptProcessAdds aScriptProcessListenerto be notified.- Specified by:
addScriptProcessListenerin interfaceScriptProcess- Parameters:
scriptProcessListener- the listener to add
-
compareTo
public int compareTo(@NotNull @NotNull ScriptProcess o)- Specified by:
compareToin interfacejava.lang.Comparable<ScriptProcess>
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(@Nullable @Nullable java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
-