BIG FORMATING COMMIT
This commit is contained in:
@@ -4,48 +4,47 @@ import lua.TableTools;
|
||||
import lua.NativeStringTools;
|
||||
|
||||
class Request {
|
||||
public final id:String;
|
||||
public final field:String;
|
||||
public final index: Null<Int>;
|
||||
public final operation: Operation;
|
||||
public final id:String;
|
||||
public final field:String;
|
||||
public final index:Null<Int>;
|
||||
public final operation:Operation;
|
||||
|
||||
public function new(id:String, field:String, index:Null<Int>, operation:Operation) {
|
||||
this.id = id;
|
||||
this.field = field;
|
||||
this.index = index;
|
||||
this.operation = operation;
|
||||
}
|
||||
public function new(id:String, field:String, index:Null<Int>, operation:Operation) {
|
||||
this.id = id;
|
||||
this.field = field;
|
||||
this.index = index;
|
||||
this.operation = operation;
|
||||
}
|
||||
|
||||
/**
|
||||
Example:
|
||||
"myfield[2]@myid"
|
||||
"myfield@myid"
|
||||
**/
|
||||
public static function fromString(locator:String):Request {
|
||||
if (StringTools.contains(locator, "[")) {
|
||||
var f = TableTools.pack(NativeStringTools.gmatch(locator, "(%a+)%[([%d]+)%]@(%a+)")());
|
||||
|
||||
/**
|
||||
Example:
|
||||
"myfield[2]@myid"
|
||||
"myfield@myid"
|
||||
**/
|
||||
public static function fromString(locator: String): Request {
|
||||
if (StringTools.contains(locator,"[")){
|
||||
var f = TableTools.pack(NativeStringTools.gmatch(locator, "(%a+)%[([%d]+)%]@(%a+)")());
|
||||
var field = f[1];
|
||||
var index = Std.parseInt(f[2]);
|
||||
var id = f[3];
|
||||
|
||||
var field = f[1];
|
||||
var index = Std.parseInt(f[2]);
|
||||
var id = f[3];
|
||||
return new Request(id, field, index, Get);
|
||||
} else {
|
||||
var f = TableTools.pack(NativeStringTools.gmatch(locator, "(%a+)@(%a+)")());
|
||||
|
||||
return new Request(id, field, index, Get);
|
||||
}else{
|
||||
var f = TableTools.pack(NativeStringTools.gmatch(locator, "(%a+)@(%a+)")());
|
||||
var field = f[1];
|
||||
var id = f[2];
|
||||
|
||||
var field = f[1];
|
||||
var id = f[2];
|
||||
|
||||
return new Request(id, field, null, Get);
|
||||
}
|
||||
}
|
||||
return new Request(id, field, null, Get);
|
||||
}
|
||||
}
|
||||
|
||||
public function toString() {
|
||||
if (index == null){
|
||||
return field + "@" + id;
|
||||
}else{
|
||||
return field + "[" + index + "]@" + id;
|
||||
}
|
||||
}
|
||||
public function toString() {
|
||||
if (index == null) {
|
||||
return field + "@" + id;
|
||||
} else {
|
||||
return field + "[" + index + "]@" + id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user