implemented importer für Bandhaus Leipzug
Signed-off-by: Stephan Richter <s.richter@srsoftware.de>
This commit is contained in:
@@ -11,8 +11,12 @@ import de.srsoftware.cal.api.Coords;
|
||||
import de.srsoftware.tools.Payload;
|
||||
import de.srsoftware.tools.Result;
|
||||
import de.srsoftware.tools.Tag;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
@@ -75,6 +79,14 @@ public class Util {
|
||||
return String.join("\r\n",lines);
|
||||
}
|
||||
|
||||
public static void dump(Tag tag){
|
||||
try {
|
||||
Files.writeString(Path.of("/tmp/dump.txt"),tag.toString(4));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<Coords> extractCoords(String coords) {
|
||||
if (coords == null) return error("Argument is null");
|
||||
if (coords.isBlank()) return error("Argument is blank");
|
||||
@@ -197,6 +209,14 @@ public class Util {
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<Integer> parseInt(String s){
|
||||
try {
|
||||
return Payload.of(Integer.parseInt(s));
|
||||
} catch (NumberFormatException e){
|
||||
return error(e,"Failed to parse %s as integer!",s);
|
||||
}
|
||||
}
|
||||
|
||||
public static Result<URL> url(Result<String> urlResult) {
|
||||
if (urlResult.optional().isEmpty()) return transform(urlResult);
|
||||
var url = urlResult.optional().get();
|
||||
|
||||
Reference in New Issue
Block a user