// Path: src/com/bridgewalkerapp/androidclient/BitcoinURI.java
// public class BitcoinURI {
// 	private static final double BTC_BASE_AMOUNT = Math.pow(10, 8);
// 	
// 	private String address;
// 	private long amount;
// 	private String currency;
// 	private String bluetoothAddress;
// 	
// 	public BitcoinURI(String address, long amount, String currency) {
// 		this(address, amount, currency, null);
// 	}
// 
// 	public BitcoinURI(String address, long amount, String currency, String bluetoothAddress) {
// 		this.address = address;
// 		this.amount = amount;
// 		this.currency = currency;
// 		this.bluetoothAddress = bluetoothAddress;
// 	}
// 	
// 	public String getAddress() {
// 		return address;
// 	}
// 	
// 	public long getAmount() {
// 		return amount;
// 	}
// 	
// 	public String getCurrency() {
// 		return currency;
// 	}
// 	
// 	public String getBluetoothAddress() {
// 		return bluetoothAddress;
// 	}
// 	
// 	public static BitcoinURI parse(String uriString) {
// 		Pattern pattern = Pattern.compile("(bitcoin:(//)?)?([^?]*)(\\?(.*))?");
// 		Matcher matcher = pattern.matcher(uriString);
// 		
// 		if (matcher.matches()) {
// 			// group 0 is the whole match
// 			String bitcoinAddress = matcher.group(3);
// 			String queryPart = matcher.group(5);	// might be null
// 			
// 			if (queryPart == null)
// 				return new BitcoinURI(bitcoinAddress, 0, "BTC");
// 
// 			// try to parse amount, currency and bluetooth address
// 			long amount = 0;
// 			String currency = "BTC";
// 			String bluetoothAddress = null;
// 			Pattern amountSubpattern = Pattern.compile("amount=(.*)");
// 			Pattern currencySubpattern = Pattern.compile("currency=(.*)");
// 			Pattern bluetoothSubpattern = Pattern.compile("bt=(.*)");
// 			String[] parameters = queryPart.split("&");
// 			for (String parameter : parameters) {
// 				// amount
// 				Matcher submatcher = amountSubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					String asString = submatcher.group(1);
// 					try {
// 						double asDouble = Double.parseDouble(asString);
// 						amount = Math.round(asDouble * BTC_BASE_AMOUNT);
// 					} catch (NumberFormatException e) { /* ignore */ }
// 				}
// 				
// 				// currency
// 				submatcher = currencySubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					currency = submatcher.group(1);
// 				}
// 				
// 				// bluetooth address
// 				submatcher = bluetoothSubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					bluetoothAddress = submatcher.group(1);
// 				}
// 			}
// 			
// 			return new BitcoinURI(bitcoinAddress, amount, currency, bluetoothAddress);
// 		} else {
// 			return null;
// 		}
// 	}
// }


import com.bridgewalkerapp.androidclient.BitcoinURI;
import junit.framework.TestCase;
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
	
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=42",
					"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 4200000000L); 		
	}

	public void testMalformedAmount() {
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=asdf",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);		
	}
	
	public void testMultipleParameters() {
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?desc=test&amount=1",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=1&desc=test",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?desc=test&amount=1&desc=test",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
	}
	
	public void testCurrencyParameter() {
// Path: src/com/bridgewalkerapp/androidclient/BitcoinURI.java
// public class BitcoinURI {
// 	private static final double BTC_BASE_AMOUNT = Math.pow(10, 8);
// 	
// 	private String address;
// 	private long amount;
// 	private String currency;
// 	private String bluetoothAddress;
// 	
// 	public BitcoinURI(String address, long amount, String currency) {
// 		this(address, amount, currency, null);
// 	}
// 
// 	public BitcoinURI(String address, long amount, String currency, String bluetoothAddress) {
// 		this.address = address;
// 		this.amount = amount;
// 		this.currency = currency;
// 		this.bluetoothAddress = bluetoothAddress;
// 	}
// 	
// 	public String getAddress() {
// 		return address;
// 	}
// 	
// 	public long getAmount() {
// 		return amount;
// 	}
// 	
// 	public String getCurrency() {
// 		return currency;
// 	}
// 	
// 	public String getBluetoothAddress() {
// 		return bluetoothAddress;
// 	}
// 	
// 	public static BitcoinURI parse(String uriString) {
// 		Pattern pattern = Pattern.compile("(bitcoin:(//)?)?([^?]*)(\\?(.*))?");
// 		Matcher matcher = pattern.matcher(uriString);
// 		
// 		if (matcher.matches()) {
// 			// group 0 is the whole match
// 			String bitcoinAddress = matcher.group(3);
// 			String queryPart = matcher.group(5);	// might be null
// 			
// 			if (queryPart == null)
// 				return new BitcoinURI(bitcoinAddress, 0, "BTC");
// 
// 			// try to parse amount, currency and bluetooth address
// 			long amount = 0;
// 			String currency = "BTC";
// 			String bluetoothAddress = null;
// 			Pattern amountSubpattern = Pattern.compile("amount=(.*)");
// 			Pattern currencySubpattern = Pattern.compile("currency=(.*)");
// 			Pattern bluetoothSubpattern = Pattern.compile("bt=(.*)");
// 			String[] parameters = queryPart.split("&");
// 			for (String parameter : parameters) {
// 				// amount
// 				Matcher submatcher = amountSubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					String asString = submatcher.group(1);
// 					try {
// 						double asDouble = Double.parseDouble(asString);
// 						amount = Math.round(asDouble * BTC_BASE_AMOUNT);
// 					} catch (NumberFormatException e) { /* ignore */ }
// 				}
// 				
// 				// currency
// 				submatcher = currencySubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					currency = submatcher.group(1);
// 				}
// 				
// 				// bluetooth address
// 				submatcher = bluetoothSubpattern.matcher(parameter);
// 				if (submatcher.matches()) {
// 					bluetoothAddress = submatcher.group(1);
// 				}
// 			}
// 			
// 			return new BitcoinURI(bitcoinAddress, amount, currency, bluetoothAddress);
// 		} else {
// 			return null;
// 		}
// 	}
// }


// Path: src/com/bridgewalkerapp/androidclient/tests/BitcoinURITest.java
import com.bridgewalkerapp.androidclient.BitcoinURI;
import junit.framework.TestCase;

		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
	
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=42",
					"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 4200000000L); 		
	}

	public void testMalformedAmount() {
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=asdf",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 0);		
	}
	
	public void testMultipleParameters() {
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?desc=test&amount=1",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=1&desc=test",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
		
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?desc=test&amount=1&desc=test",
				"14Z1mazY4HfysZyMaKudFr63EwHqQT2njz", 100000000L);
	}
	
	public void testCurrencyParameter() {
		helper("14Z1mazY4HfysZyMaKudFr63EwHqQT2njz?amount=1&currency=BTC",