P15GEN2\59518
2024-05-29 d4210c7c4b04abde20037ea8aa0f54ef8a2649aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package foundation.io.define;
 
public enum IODirection {
 
    SheetToTable(IOLocation.Sheet, IOLocation.Table),
    TableToSheet(IOLocation.Table, IOLocation.Sheet),
    TableToTable(IOLocation.Table, IOLocation.Table),
    SheetToMemory(IOLocation.Sheet, IOLocation.Memory),
    ErrorsToSheet(IOLocation.Errors, IOLocation.Sheet);
    
    private IOLocation from;
    private IOLocation to;
    
    public static IODirection parse(String value) {
        if (value == null) {
            return null;
        }
        
        value = value.toLowerCase();
        
        int pos = value.indexOf("-->");
        
        if (pos <= 0) {
            return null;
        }
        
        String from = value.substring(0, pos).trim();
        String to = value.substring(pos + 3).trim();
        
        IOLocation from_location = IOLocation.parse(from);
        IOLocation to_location = IOLocation.parse(to);
        
        if (IOLocation.Sheet == from_location && IOLocation.Table == to_location) {
            return SheetToTable;
        }
        else if (IOLocation.Sheet == from_location && IOLocation.Memory == to_location) {
            return SheetToMemory;
        }
        else if (IOLocation.Table == from_location && IOLocation.Sheet == to_location) {
            return TableToSheet;
        }
        else if (IOLocation.Errors == from_location && IOLocation.Sheet == to_location) {
            return ErrorsToSheet;
        }
        else if (IOLocation.Table == from_location && IOLocation.Table == to_location) {
            return TableToTable;
        }
        
        return null;
    }
    
    private IODirection(IOLocation from, IOLocation to) {
        this.from = from;
        this.to = to;
    }
 
    public IOLocation getFrom() {
        return from;
    }
 
    public IOLocation getTo() {
        return to;
    }
 
}