commit 1637078249720ac9d725d1eef4d8ebb5f7994f62 Author: Tinglyyy Date: Sun Jan 18 14:40:25 2026 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..480bdf5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ +.kotlin + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..ab1f416 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,10 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Ignored default folder with query files +/queries/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6111a9a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..8306744 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..dbc55a0 --- /dev/null +++ b/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + + org.openautonomousconnection.infonamelib + InfoNameLib + 1.0.0-BETAS.1.0 + + + 22 + 22 + UTF-8 + + + + org.projectlombok + lombok + 1.18.38 + provided + + + org.junit.jupiter + junit-jupiter + 6.0.0 + test + + + + \ No newline at end of file diff --git a/src/main/java/org/openautonomousconnection/infonamelib/InfoNameURLStreamHandlerFactory.java b/src/main/java/org/openautonomousconnection/infonamelib/InfoNameURLStreamHandlerFactory.java new file mode 100644 index 0000000..566df08 --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/InfoNameURLStreamHandlerFactory.java @@ -0,0 +1,24 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib; + +import org.openautonomousconnection.infonamelib.protocols.ftp.FTPInfoNameURLStreamHandler; +import org.openautonomousconnection.infonamelib.protocols.web.WebInfoNameURLStreamHandler; + +import java.net.URLStreamHandler; +import java.net.URLStreamHandlerFactory; + +public class InfoNameURLStreamHandlerFactory implements URLStreamHandlerFactory { + @Override + public URLStreamHandler createURLStreamHandler(String protocol) { + return switch (protocol) { + case "web" -> new WebInfoNameURLStreamHandler(); + case "ftp" -> new FTPInfoNameURLStreamHandler(); + default -> null; + }; + + + } +} diff --git a/src/main/java/org/openautonomousconnection/infonamelib/InfoNames.java b/src/main/java/org/openautonomousconnection/infonamelib/InfoNames.java new file mode 100644 index 0000000..04ba44c --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/InfoNames.java @@ -0,0 +1,16 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib; + +import java.net.URL; + +public class InfoNames { + /** + * Switches accepted Schemes in URLs to InfoName ones + */ + public static void registerOACInfoNameProtocols() { + URL.setURLStreamHandlerFactory(new InfoNameURLStreamHandlerFactory()); + } +} diff --git a/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLConnection.java b/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLConnection.java new file mode 100644 index 0000000..cde274e --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLConnection.java @@ -0,0 +1,26 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib.protocols.ftp; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +public class FTPInfoNameURLConnection extends URLConnection { + /** + * Constructs a URL connection to the specified URL. A connection to + * the object referenced by the URL is not created. + * + * @param url the specified URL. + */ + protected FTPInfoNameURLConnection(URL url) { + super(url); + } + + @Override + public void connect() throws IOException { + + } +} diff --git a/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLStreamHandler.java b/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLStreamHandler.java new file mode 100644 index 0000000..ab6841f --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/protocols/ftp/FTPInfoNameURLStreamHandler.java @@ -0,0 +1,17 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib.protocols.ftp; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +public class FTPInfoNameURLStreamHandler extends URLStreamHandler { + @Override + protected URLConnection openConnection(URL url) throws IOException { + return new FTPInfoNameURLConnection(url); + } +} diff --git a/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLConnection.java b/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLConnection.java new file mode 100644 index 0000000..8f6872c --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLConnection.java @@ -0,0 +1,26 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib.protocols.web; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; + +public class WebInfoNameURLConnection extends URLConnection { + /** + * Constructs a URL connection to the specified URL. A connection to + * the object referenced by the URL is not created. + * + * @param url the specified URL. + */ + protected WebInfoNameURLConnection(URL url) { + super(url); + } + + @Override + public void connect() throws IOException { + + } +} diff --git a/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLStreamHandler.java b/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLStreamHandler.java new file mode 100644 index 0000000..9930204 --- /dev/null +++ b/src/main/java/org/openautonomousconnection/infonamelib/protocols/web/WebInfoNameURLStreamHandler.java @@ -0,0 +1,17 @@ +/* Author: Maple + * Jan. 18 2026 + * */ + +package org.openautonomousconnection.infonamelib.protocols.web; + +import java.io.IOException; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + +public class WebInfoNameURLStreamHandler extends URLStreamHandler { + @Override + protected URLConnection openConnection(URL url) throws IOException { + return new WebInfoNameURLConnection(url); + } +} diff --git a/src/test/java/org/openautonomousconnection/infonamelib/test/URLTests.java b/src/test/java/org/openautonomousconnection/infonamelib/test/URLTests.java new file mode 100644 index 0000000..ce69eca --- /dev/null +++ b/src/test/java/org/openautonomousconnection/infonamelib/test/URLTests.java @@ -0,0 +1,28 @@ +package org.openautonomousconnection.infonamelib.test; + +import org.junit.jupiter.api.Test; +import org.openautonomousconnection.infonamelib.InfoNames; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; + +public class URLTests { + @Test + public void createWebUrl() { + System.out.println("Registering OAC protocols"); + + InfoNames.registerOACInfoNameProtocols(); + + System.out.println("Creating url to: web://localhost:8080"); + + URI uri = URI.create("web://localhost:8080"); + + try { + URL url = uri.toURL(); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + + } +}