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; } }