OSCMessage implements OSCPacket { @SuppressWarnings("WeakerAccess") public static boolean isValidAddress(final String address) { return (address != null) && !address.isEmpty() && ( address.equals("#reply") || ( (address.charAt(0) == '/') && !address.contains(" && !ILLEGAL_ADDRESS_CHAR.matcher(address).find() )); } OSCMessage(final String address);  OSCMessage(final String address, final List<?> arguments);  OSCMessage(final String address, final List<?> arguments, final OSCMessageInfo info);   OSCMessage(final String address, final List<?> arguments, final OSCMessageInfo info, final boolean checkAddress); String getAddress(); List<Object> getArguments(); OSCMessageInfo getInfo(); @SuppressWarnings("WeakerAccess") boolean isInfoSet(); @SuppressWarnings("WeakerAccess") void setInfo(final OSCMessageInfo info); @SuppressWarnings("WeakerAccess") static boolean isValidAddress(final String address);  }
@Test public void testAddressValidation() { Assert.assertFalse(OSCMessage.isValidAddress(null)); Assert.assertFalse(OSCMessage.isValidAddress("")); Assert.assertFalse(OSCMessage.isValidAddress("hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/ hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/#hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/*hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/,hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/?hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/[hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/]hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/{hello/world")); Assert.assertFalse(OSCMessage.isValidAddress("/}hello/world")); Assert.assertFalse(OSCMessage.isValidAddress(" Assert.assertFalse(OSCMessage.isValidAddress("#abc")); Assert.assertFalse(OSCMessage.isValidAddress("#replyx")); Assert.assertFalse(OSCMessage.isValidAddress("#replx")); Assert.assertTrue( OSCMessage.isValidAddress("/hello")); Assert.assertTrue( OSCMessage.isValidAddress("/hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/hello/world/two")); Assert.assertTrue( OSCMessage.isValidAddress("/123/world/two")); Assert.assertTrue( OSCMessage.isValidAddress("/!hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/~hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/`hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/@hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/$hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/%hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/€hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/^hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/&hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/(hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/)hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/-hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/_hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/+hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/=hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/.hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/<hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/>hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/;hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/:hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/'hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("/\"hello/world")); Assert.assertTrue( OSCMessage.isValidAddress("#reply")); }