package_1 alternativa.osgi.service.console.variables

This commit is contained in:
Pyogenics
2025-01-26 10:28:25 +00:00
parent 6ba701b0a9
commit 98d9fbb377
14 changed files with 111 additions and 109 deletions

View File

@@ -0,0 +1,77 @@
package alternativa.osgi.service.console.variables
{
import package_5.name_3;
import package_6.name_4;
public class ConsoleVar
{
protected var varName:String;
protected var inputListener:Function;
public function ConsoleVar(varName:String, inputListener:Function = null)
{
super();
this.varName = varName;
this.inputListener = inputListener;
var console:name_4 = name_4(name_3.name_8().name_30(name_4));
if(console != null)
{
console.name_147(this);
}
}
public function name_32() : String
{
return this.varName;
}
public function destroy() : void
{
var console:name_4 = name_4(name_3.name_8().name_30(name_4));
if(console != null)
{
console.name_146(this.varName);
}
this.inputListener = null;
}
public function method_77(console:name_4, params:Array) : void
{
var oldValue:String = null;
var errorText:String = null;
if(params.length == 0)
{
console.name_145(this.varName + " = " + this.toString());
}
else
{
oldValue = this.toString();
errorText = this.acceptInput(params[0]);
if(errorText == null)
{
console.name_145(this.varName + " is set to " + this.toString() + " (was " + oldValue + ")");
if(this.inputListener != null)
{
this.inputListener.call(null,this);
}
}
else
{
console.name_145(errorText);
}
}
}
protected function acceptInput(value:String) : String
{
return "Not implemented";
}
public function toString() : String
{
return "Not implemented";
}
}
}

View File

@@ -0,0 +1,40 @@
package alternativa.osgi.service.console.variables
{
public class ConsoleVarFloat extends ConsoleVar
{
public var value:Number;
private var minValue:Number;
private var maxValue:Number;
public function ConsoleVarFloat(consoleVarName:String, initialValue:Number, minValue:Number, maxValue:Number, changeListener:Function = null)
{
super(consoleVarName,changeListener);
this.value = initialValue;
this.minValue = minValue;
this.maxValue = maxValue;
}
override protected function acceptInput(value:String) : String
{
var f:Number = Number(Number(value));
if(isNaN(f))
{
return "Incorrect number";
}
if(f < this.minValue || f > this.maxValue)
{
return "Value is out of bounds [" + this.minValue + ", " + this.maxValue + "]";
}
this.value = f;
return null;
}
override public function toString() : String
{
return this.value.toString();
}
}
}

View File

@@ -0,0 +1,36 @@
package alternativa.osgi.service.console.variables
{
public class ConsoleVarInt extends ConsoleVar
{
public var value:int;
private var minValue:int;
private var maxValue:int;
public function ConsoleVarInt(consoleVarName:String, initialValue:int, minValue:int, maxValue:int, inputListener:Function = null)
{
super(consoleVarName,inputListener);
this.value = initialValue;
this.minValue = minValue;
this.maxValue = maxValue;
}
override protected function acceptInput(value:String) : String
{
var f:int = int(int(value));
if(f < this.minValue || f > this.maxValue)
{
return "Value is out of bounds [" + this.minValue + ", " + this.maxValue + "]";
}
this.value = f;
return null;
}
override public function toString() : String
{
return this.value.toString();
}
}
}

View File

@@ -0,0 +1,25 @@
package alternativa.osgi.service.console.variables
{
public class ConsoleVarString extends ConsoleVar
{
public var value:String;
public function ConsoleVarString(consoleVarName:String, initialValue:String, inputListener:Function = null)
{
super(consoleVarName,inputListener);
this.value = initialValue;
}
override protected function acceptInput(value:String) : String
{
this.value = value;
return null;
}
override public function toString() : String
{
return this.value;
}
}
}