Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
URIDumpUtil.java
Go to the documentation of this file.
1package jau.test.net;
2
3import java.net.MalformedURLException;
4import java.net.URI;
5import java.net.URISyntaxException;
6import java.net.URL;
7
8import org.jau.net.Uri;
9
10public class URIDumpUtil {
11 public static void showURX(final String urx) throws MalformedURLException, URISyntaxException {
12 System.err.println("WWWWWW "+urx);
13 showURL(new URL(urx));
14 showURI(new URI(urx));
15 System.err.println("WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW");
16 }
17
18 public static void showURL(final URL url) {
19 System.err.println("XXXXXX URL "+url.toString());
20 System.err.println("protocol: "+url.getProtocol());
21 System.err.println("auth: "+url.getAuthority());
22 System.err.println("host: "+url.getHost());
23 System.err.println("port: "+url.getPort() + " ( " + url.getDefaultPort() + " ) " );
24 System.err.println("file: "+url.getFile() + " ( path " + url.getPath() + ", query " + url.getQuery() + " ) " );
25 System.err.println("ref: "+url.getRef());
26 }
27
28 public static void showURI(final URI uri) {
29 showURI("YYYYYY URI "+uri+", isOpaque "+uri.isOpaque()+", isAbs "+uri.isAbsolute(), uri);
30 }
31 public static void showURI(final String message, final URI uri) {
32 System.err.println(message);
33
34 System.err.println("0.0.0 string: "+uri.toString());
35 System.err.println("0.0.0 ascii : "+uri.toASCIIString());
36
37 System.err.println("1.0.0 scheme: "+uri.getScheme());
38 System.err.println("2.0.0 scheme-part: "+uri.getRawSchemeSpecificPart()+" (raw), "+uri.getSchemeSpecificPart()+" (dec)");
39 System.err.println("2.1.0 auth: "+uri.getRawAuthority()+" (raw), "+uri.getAuthority()+" (dec)");
40 System.err.println("2.1.1 user-info: "+uri.getRawUserInfo()+" (raw), "+uri.getUserInfo()+" (dec)");
41 System.err.println("2.1.1 host: "+uri.getHost());
42 System.err.println("2.1.1 port: "+uri.getPort());
43 System.err.println("2.2.0 path: "+uri.getRawPath()+" (raw), "+uri.getPath()+" (dec)");
44 System.err.println("2.3.0 query: "+uri.getRawQuery()+" (raw), "+uri.getQuery()+" (dec)");
45 System.err.println("3.0.0 fragment: "+uri.getRawFragment()+" (raw), "+uri.getFragment()+" (dec)");
46 }
47
48 public static void showUri(final Uri uri) throws URISyntaxException {
49 showUri("ZZZZZZ Uri "+uri+", isOpaque "+uri.opaque+", isAbs "+uri.absolute+", hasAuth "+uri.hasAuthority, uri);
50 }
51
52 public static void showUri(final String message, final Uri uri) throws URISyntaxException {
53 System.err.println(message);
54
55 System.err.println("0.0.0 string: "+uri.toString());
56 System.err.println("0.0.0 ascii : "+uri.toASCIIString());
57 System.err.println("0.0.0 native-file: "+uri.toFile());
58 System.err.println("0.0.0 contained: "+uri.getContainedUri());
59
60 System.err.println("1.0.0 scheme: "+uri.scheme);
61 System.err.println("2.0.0 scheme-part: "+uri.schemeSpecificPart+" (raw), "+Uri.decode(uri.schemeSpecificPart)+" (dec)");
62 System.err.println("2.1.0 auth: "+uri.authority+" (raw), "+Uri.decode(uri.authority)+" (dec)");
63 System.err.println("2.1.1 user-info: "+uri.userInfo+" (raw), "+Uri.decode(uri.userInfo)+" (dec)");
64 System.err.println("2.1.1 host: "+uri.host);
65 System.err.println("2.1.1 port: "+uri.port);
66 System.err.println("2.2.0 path: "+uri.path+" (raw), "+Uri.decode(uri.path)+" (dec)");
67 System.err.println("2.3.0 query: "+uri.query+" (raw), "+Uri.decode(uri.query)+" (dec)");
68 System.err.println("3.0.0 fragment: "+uri.fragment+" (raw), "+Uri.decode(uri.fragment)+" (dec)");
69 }
70
71 /**
72 * Just showing different encoding of Uri -> URI
73 *
74 * @param uri
75 * @throws URISyntaxException
76 */
77 public static void showReencodedURIOfUri(final Uri uri) throws URISyntaxException {
78 final URI recomposedURI = uri.toURIReencoded();
79 showURI("YYYYYY Recomposed URI "+recomposedURI+", isOpaque "+recomposedURI.isOpaque()+", isAbs "+recomposedURI.isAbsolute(), recomposedURI);
80 final String recomposedURIStr = recomposedURI.toString();
81 final boolean equalsRecompURI = uri.input.toString().equals(recomposedURIStr);
82 System.err.println("source Uri: "+uri.input);
83 System.err.println("recomp URI: "+recomposedURIStr+" - "+(equalsRecompURI?"EQUAL":"UNEQUAL"));
84 }
85
86 /**
87 * Just showing different encoding of URI -> Uri
88 *
89 * @param uri
90 * @throws URISyntaxException
91 */
92 public static void showReencodedUriOfURI(final URI uri) throws URISyntaxException {
93 final Uri recomposedUri = Uri.valueOf(uri);
94 showUri("ZZZZZZ Recomposed Uri "+recomposedUri+", isOpaque "+recomposedUri.opaque+", isAbs "+recomposedUri.absolute+", hasAuth "+recomposedUri.hasAuthority, recomposedUri);
95 final String recomposedUriStr = recomposedUri.toString();
96 final boolean equalsRecompUri = uri.toString().equals(recomposedUriStr);
97 System.err.println("source URI: "+uri.toString());
98 System.err.println("recomp Uri: "+recomposedUriStr+" - "+(equalsRecompUri?"EQUAL":"UNEQUAL"));
99 }
100}
static void showUri(final Uri uri)
static void showURX(final String urx)
static void showURI(final URI uri)
static void showUri(final String message, final Uri uri)
static void showReencodedUriOfURI(final URI uri)
Just showing different encoding of URI -> Uri.
static void showURI(final String message, final URI uri)
static void showURL(final URL url)
static void showReencodedURIOfUri(final Uri uri)
Just showing different encoding of Uri -> URI.