@Test public void testParseUri() throws Exception { String uri = "duniter: Map<String,String> result = Format.parseUri(uri); Assert.assertTrue( result.get("uid").equals("uid") && result.get("public_key").equals("pubkey") && result.get("currency").equals("currency")); }
public static Map<String, String> parseUri(String uri){ Map<String, String> result = new HashMap<>(); if(uri.substring(0,Contantes.CONTACT_PATH.length()).equals(Contantes.CONTACT_PATH)){ int index1 = uri.indexOf(Contantes.SEPARATOR1,Contantes.CONTACT_PATH.length()); int index2 = uri.indexOf(Contantes.SEPARATOR2,index1+Contantes.SEPARATOR1.length()); String uid = uri.substring(Contantes.CONTACT_PATH.length(), index1); String publicKey = uri.substring(index1+Contantes.SEPARATOR1.length(),index2); String currency = uri.substring(index2+Contantes.SEPARATOR2.length()); if(!uid.isEmpty()){ result.put(Contantes.UID,uid); } if(!publicKey.isEmpty()){ result.put(Contantes.PUBLICKEY,publicKey); } if(!currency.isEmpty()){ result.put(Contantes.CURRENCY,currency); } }else{ result.put(Contantes.PUBLICKEY,uri); } return result; }
Format { public static Map<String, String> parseUri(String uri){ Map<String, String> result = new HashMap<>(); if(uri.substring(0,Contantes.CONTACT_PATH.length()).equals(Contantes.CONTACT_PATH)){ int index1 = uri.indexOf(Contantes.SEPARATOR1,Contantes.CONTACT_PATH.length()); int index2 = uri.indexOf(Contantes.SEPARATOR2,index1+Contantes.SEPARATOR1.length()); String uid = uri.substring(Contantes.CONTACT_PATH.length(), index1); String publicKey = uri.substring(index1+Contantes.SEPARATOR1.length(),index2); String currency = uri.substring(index2+Contantes.SEPARATOR2.length()); if(!uid.isEmpty()){ result.put(Contantes.UID,uid); } if(!publicKey.isEmpty()){ result.put(Contantes.PUBLICKEY,publicKey); } if(!currency.isEmpty()){ result.put(Contantes.CURRENCY,currency); } }else{ result.put(Contantes.PUBLICKEY,uri); } return result; } }
Format { public static Map<String, String> parseUri(String uri){ Map<String, String> result = new HashMap<>(); if(uri.substring(0,Contantes.CONTACT_PATH.length()).equals(Contantes.CONTACT_PATH)){ int index1 = uri.indexOf(Contantes.SEPARATOR1,Contantes.CONTACT_PATH.length()); int index2 = uri.indexOf(Contantes.SEPARATOR2,index1+Contantes.SEPARATOR1.length()); String uid = uri.substring(Contantes.CONTACT_PATH.length(), index1); String publicKey = uri.substring(index1+Contantes.SEPARATOR1.length(),index2); String currency = uri.substring(index2+Contantes.SEPARATOR2.length()); if(!uid.isEmpty()){ result.put(Contantes.UID,uid); } if(!publicKey.isEmpty()){ result.put(Contantes.PUBLICKEY,publicKey); } if(!currency.isEmpty()){ result.put(Contantes.CURRENCY,currency); } }else{ result.put(Contantes.PUBLICKEY,uri); } return result; }  }
Format { public static Map<String, String> parseUri(String uri){ Map<String, String> result = new HashMap<>(); if(uri.substring(0,Contantes.CONTACT_PATH.length()).equals(Contantes.CONTACT_PATH)){ int index1 = uri.indexOf(Contantes.SEPARATOR1,Contantes.CONTACT_PATH.length()); int index2 = uri.indexOf(Contantes.SEPARATOR2,index1+Contantes.SEPARATOR1.length()); String uid = uri.substring(Contantes.CONTACT_PATH.length(), index1); String publicKey = uri.substring(index1+Contantes.SEPARATOR1.length(),index2); String currency = uri.substring(index2+Contantes.SEPARATOR2.length()); if(!uid.isEmpty()){ result.put(Contantes.UID,uid); } if(!publicKey.isEmpty()){ result.put(Contantes.PUBLICKEY,publicKey); } if(!currency.isEmpty()){ result.put(Contantes.CURRENCY,currency); } }else{ result.put(Contantes.PUBLICKEY,uri); } return result; }  static void initUnit(Context context, TextView textView, long quantitatif, int base, long delay, long dividend, int baseDividend, boolean isFirstAmount, String currencyName); static long convertBase(long value, int base, int newBase); static String minifyPubkey(String pubkey); static String createUri(boolean simple, String uid, String publicKey, String currency); static Map<String, String> parseUri(String uri); static String isNull(String txt); }
Format { public static Map<String, String> parseUri(String uri){ Map<String, String> result = new HashMap<>(); if(uri.substring(0,Contantes.CONTACT_PATH.length()).equals(Contantes.CONTACT_PATH)){ int index1 = uri.indexOf(Contantes.SEPARATOR1,Contantes.CONTACT_PATH.length()); int index2 = uri.indexOf(Contantes.SEPARATOR2,index1+Contantes.SEPARATOR1.length()); String uid = uri.substring(Contantes.CONTACT_PATH.length(), index1); String publicKey = uri.substring(index1+Contantes.SEPARATOR1.length(),index2); String currency = uri.substring(index2+Contantes.SEPARATOR2.length()); if(!uid.isEmpty()){ result.put(Contantes.UID,uid); } if(!publicKey.isEmpty()){ result.put(Contantes.PUBLICKEY,publicKey); } if(!currency.isEmpty()){ result.put(Contantes.CURRENCY,currency); } }else{ result.put(Contantes.PUBLICKEY,uri); } return result; }  static void initUnit(Context context, TextView textView, long quantitatif, int base, long delay, long dividend, int baseDividend, boolean isFirstAmount, String currencyName); static long convertBase(long value, int base, int newBase); static String minifyPubkey(String pubkey); static String createUri(boolean simple, String uid, String publicKey, String currency); static Map<String, String> parseUri(String uri); static String isNull(String txt); static final boolean SIMPLE; static final boolean LONG; }