test_class.declarator: validURI_NoPlaceholders = "http://sysmo-db.org/sops/"
test_class.modifier: final
test_class.original_string: final String validURI_NoPlaceholders = "http://sysmo-db.org/sops/";
test_class.type: String
test_class.var_name: validURI_NoPlaceholders
test_class.declarator: validURI_PlaceholdersInMainPartOfURIOnly = "http://sysmo-db.org/sops/{sop_id}/experimental_conditions/{cond_id}"
test_class.modifier: final
test_class.original_string: final String validURI_PlaceholdersInMainPartOfURIOnly = "http://sysmo-db.org/sops/{sop_id}/experimental_conditions/{cond_id}";
test_class.type: String
test_class.var_name: validURI_PlaceholdersInMainPartOfURIOnly
test_class.declarator: validURI_PlaceholdersInQueryStringOnly = "http://sandbox.myexperiment.org/user.xml?id={user_id}&verbose=true"
test_class.modifier: final
test_class.original_string: final String validURI_PlaceholdersInQueryStringOnly = "http://sandbox.myexperiment.org/user.xml?id={user_id}&verbose=true";
test_class.type: String
test_class.var_name: validURI_PlaceholdersInQueryStringOnly
test_class.declarator: validURI_3MixedPlaceholders = "http://sysmo-db.org/sops/{sop_id}/experimental_conditions/{cond_id}?condition_unit={unit}"
test_class.modifier: final
test_class.original_string: final String validURI_3MixedPlaceholders = "http://sysmo-db.org/sops/{sop_id}/experimental_conditions/{cond_id}?condition_unit={unit}";
test_class.type: String
test_class.var_name: validURI_3MixedPlaceholders
test_class.declarator: badURI_nullURI = null
test_class.modifier: final
test_class.original_string: final String badURI_nullURI = null;
test_class.type: String
test_class.var_name: badURI_nullURI
test_class.declarator: badURI_emptyURI = ""
test_class.modifier: final
test_class.original_string: final String badURI_emptyURI = "";
test_class.type: String
test_class.var_name: badURI_emptyURI
test_class.declarator: badURI_SingleOpeningSymbolNoClosingSymbol = "http://sysmo-db.org/sops/{sop_id/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_SingleOpeningSymbolNoClosingSymbol = "http://sysmo-db.org/sops/{sop_id/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_SingleOpeningSymbolNoClosingSymbol
test_class.declarator: badURI_SingleClosingSymbolNoOpeningSymbol = "http://sysmo-db.org/sops/sop_id}/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_SingleClosingSymbolNoOpeningSymbol = "http://sysmo-db.org/sops/sop_id}/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_SingleClosingSymbolNoOpeningSymbol
test_class.declarator: badURI_DoubleOpeningSymbolsNoClosingSymbol = "http://sysmo-db.org/sops/{{sop_id/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_DoubleOpeningSymbolsNoClosingSymbol = "http://sysmo-db.org/sops/{{sop_id/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_DoubleOpeningSymbolsNoClosingSymbol
test_class.declarator: badURI_DoubleOpeningSymbols = "http://sysmo-db.org/sops/{{sop_id}/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_DoubleOpeningSymbols = "http://sysmo-db.org/sops/{{sop_id}/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_DoubleOpeningSymbols
test_class.declarator: badURI_DoubleOpeningSymbolsSpaced = "http://sysmo-db.org/sops/{sop_{id}/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_DoubleOpeningSymbolsSpaced = "http://sysmo-db.org/sops/{sop_{id}/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_DoubleOpeningSymbolsSpaced
test_class.declarator: badURI_DoubleClosingSymbols = "http://sysmo-db.org/sops/{sop_id}}/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_DoubleClosingSymbols = "http://sysmo-db.org/sops/{sop_id}}/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_DoubleClosingSymbols
test_class.declarator: badURI_DoubleClosingSymbolsSpaced = "http://sysmo-db.org/sops/{sop}_id}/experimental_conditions"
test_class.modifier: final
test_class.original_string: final String badURI_DoubleClosingSymbolsSpaced = "http://sysmo-db.org/sops/{sop}_id}/experimental_conditions";
test_class.type: String
test_class.var_name: badURI_DoubleClosingSymbolsSpaced
test_class.declarator: badURI_NestedPlaceholders = "http://sandbox.myexperiment.org/user.xml?id={user_{id}}&verbose=true"
test_class.modifier: final
test_class.original_string: final String badURI_NestedPlaceholders = "http://sandbox.myexperiment.org/user.xml?id={user_{id}}&verbose=true";
test_class.type: String
test_class.var_name: badURI_NestedPlaceholders
test_class.declarator: badURI_NestedPlaceholdersSpaced = "http://sandbox.myexperiment.org/user.xml?id={us{er}_id}&verbose=true"
test_class.modifier: final
test_class.original_string: final String badURI_NestedPlaceholdersSpaced = "http://sandbox.myexperiment.org/user.xml?id={us{er}_id}&verbose=true";
test_class.type: String
test_class.var_name: badURI_NestedPlaceholdersSpaced
test_class.declarator: badURI_DuplicatePlaceholders = "http://sandbox.myexperiment.org/user.xml?id={user_id}&verbose={user_id}"
test_class.modifier: final
test_class.original_string: final String badURI_DuplicatePlaceholders = "http://sandbox.myexperiment.org/user.xml?id={user_id}&verbose={user_id}";
test_class.type: String
test_class.var_name: badURI_DuplicatePlaceholders
test_class.declarator: badURI_DuplicatePlaceholdersWithOthers = "http://sysmo-db.org/sops/{unit}/experimental_conditions/{cond_id}?condition_unit={unit}"
test_class.modifier: final
test_class.original_string: final String badURI_DuplicatePlaceholdersWithOthers = "http://sysmo-db.org/sops/{unit}/experimental_conditions/{cond_id}?condition_unit={unit}";
test_class.type: String
test_class.var_name: badURI_DuplicatePlaceholdersWithOthers
test_class.declarator: validURI_MultipleQueryString =
              "http://dr-site.esrin.esa.int/{catalogue}/genesi/ASA_IMS_1P/rdf/?count={count?}&startPage={startPage?}&startIndex={startIndex?}&q={searchTerms?}"
test_class.modifier: final
test_class.original_string: final String validURI_MultipleQueryString =
              "http://dr-site.esrin.esa.int/{catalogue}/genesi/ASA_IMS_1P/rdf/?count={count?}&startPage={startPage?}&startIndex={startIndex?}&q={searchTerms?}";
test_class.type: String
test_class.var_name: validURI_MultipleQueryString
test_class.file: taverna-rest-activity/src/test/java/org/apache/taverna/activities/rest/URISignatureHandlerTest.java
test_class.identifier: URISignatureHandlerTest
test_case.body: @SuppressWarnings("serial")
  	@Test
  	public void generateCompleteURI_signatureWithPlaceholders_missingParameterURIGeneration_FailureNotExpected() {
  		String uriSignature = "http://sysmo-db.org/sops/{sop_id}/experimental_conditions/{cond_id}?condition_unit={unit}";
  		Map<String, String> parameters = new HashMap<String, String>() {
  			{
  				put("sop_id", "111");
  				put("cond_id", "2222");
  			}
  		};
  
  		String completeURI = URISignatureHandler.generateCompleteURI(
  				uriSignature, parameters, true);
  
  		assertEquals(
  				"http://sysmo-db.org/sops/111/experimental_conditions/2222",
  				completeURI);
  	}
test_case.class_method_signature: URISignatureHandlerTest.generateCompleteURI_signatureWithPlaceholders_missingParameterURIGeneration_FailureNotExpected()
test_case.full_signature: @SuppressWarnings("serial") @Test public void generateCompleteURI_signatureWithPlaceholders_missingParameterURIGeneration_FailureNotExpected()
test_case.identifier: generateCompleteURI_signatureWithPlaceholders_missingParameterURIGeneration_FailureNotExpected
test_case.invocations: put put generateCompleteURI assertEquals
test_case.modifiers: @SuppressWarnings("serial") @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void generateCompleteURI_signatureWithPlaceholders_missingParameterURIGeneration_FailureNotExpected()
focal_class.declarator: logger = Logger.getLogger(URISignatureHandler.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(URISignatureHandler.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: PLACEHOLDER_START_SYMBOL = '{'
focal_class.modifier: public static final
focal_class.original_string: public static final char PLACEHOLDER_START_SYMBOL = '{';
focal_class.type: char
focal_class.var_name: PLACEHOLDER_START_SYMBOL
focal_class.declarator: PLACEHOLDER_END_SYMBOL = '}'
focal_class.modifier: public static final
focal_class.original_string: public static final char PLACEHOLDER_END_SYMBOL = '}';
focal_class.type: char
focal_class.var_name: PLACEHOLDER_END_SYMBOL
focal_class.file: taverna-rest-activity/src/main/java/org/apache/taverna/activities/rest/URISignatureHandler.java
focal_class.identifier: URISignatureHandler
focal_class.class_method_signature: URISignatureHandler.extractPlaceholdersWithPositions(
  			String uriSignature)
focal_class.full_signature: public static LinkedHashMap<String, Integer> extractPlaceholdersWithPositions(
  			String uriSignature)
focal_class.identifier: extractPlaceholdersWithPositions
focal_class.modifiers: public static
focal_class.parameters: (
  			String uriSignature)
focal_class.return: LinkedHashMap<String, Integer>
focal_class.signature: LinkedHashMap<String, Integer> extractPlaceholdersWithPositions(
  			String uriSignature)
focal_class.class_method_signature: URISignatureHandler.extractPlaceholders(String uriSignature)
focal_class.full_signature: public static List<String> extractPlaceholders(String uriSignature)
focal_class.identifier: extractPlaceholders
focal_class.modifiers: public static
focal_class.parameters: (String uriSignature)
focal_class.return: List<String>
focal_class.signature: List<String> extractPlaceholders(String uriSignature)
focal_class.class_method_signature: URISignatureHandler.validate(String uriSignature)
focal_class.full_signature: public static void validate(String uriSignature)
focal_class.identifier: validate
focal_class.modifiers: public static
focal_class.parameters: (String uriSignature)
focal_class.return: void
focal_class.signature: void validate(String uriSignature)
focal_class.class_method_signature: URISignatureHandler.checkForUnsafeCharacters(String candidateURLSignature)
focal_class.full_signature: public static void checkForUnsafeCharacters(String candidateURLSignature)
focal_class.identifier: checkForUnsafeCharacters
focal_class.modifiers: public static
focal_class.parameters: (String candidateURLSignature)
focal_class.return: void
focal_class.signature: void checkForUnsafeCharacters(String candidateURLSignature)
focal_class.class_method_signature: URISignatureHandler.isValid(String uriSignature)
focal_class.full_signature: public static boolean isValid(String uriSignature)
focal_class.identifier: isValid
focal_class.modifiers: public static
focal_class.parameters: (String uriSignature)
focal_class.return: boolean
focal_class.signature: boolean isValid(String uriSignature)
focal_class.class_method_signature: URISignatureHandler.generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_class.full_signature: public static String generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_class.identifier: generateCompleteURI
focal_class.modifiers: public static
focal_class.parameters: (String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_class.return: String
focal_class.signature: String generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_class.class_method_signature: URISignatureHandler.urlEncodeQuery(String query)
focal_class.full_signature: public static String urlEncodeQuery(String query)
focal_class.identifier: urlEncodeQuery
focal_class.modifiers: public static
focal_class.parameters: (String query)
focal_class.return: String
focal_class.signature: String urlEncodeQuery(String query)
focal_method.body: public static String generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
  			throws URISignatureParsingException,
  			URIGenerationFromSignatureException {
  		StringBuilder completeURI = new StringBuilder(uriSignature);
  
  		// no need to make any checks on the uriSignature - it is
  		// already handled by extractPlaceholdersWithPositions() --
  		// if something goes wrong a runtime exception will be thrown
  		// during placeholder extraction
  		LinkedHashMap<String, Integer> placeholdersWithPositions = extractPlaceholdersWithPositions(uriSignature);
  
  		// check that the URI signature contains some placeholders
  		if (placeholdersWithPositions.keySet().size() > 0) {
  			Map<String, String> parameters;
  			// some work will actually have to be done to replace placeholders
  			// with real values;
  			// check that the parameter map contains some values
  			if (specifiedParameters == null || specifiedParameters.isEmpty()) {
  				parameters = Collections.emptyMap();
  			} else {
  				parameters = specifiedParameters;
  			}
  
  			// the 'placeholders' linked list is guaranteed to be in the order
  			// of occurrence of placeholders in the URI signature;
  			// this will allow to traverse the URI signature and replace the
  			// placeholders in the reverse order --
  			// this way it is possible to use the indices of placeholders that
  			// were already found during their extraction to
  			// improve performance
  			LinkedList<String> placeholders = new LinkedList<String>(
  					placeholdersWithPositions.keySet());
  			Collections.reverse(placeholders);
  			Iterator<String> placeholdersIterator = placeholders.iterator();
  
  			while (placeholdersIterator.hasNext()) {
  				String placeholder = placeholdersIterator.next();
  				int placeholderStartPos = placeholdersWithPositions
  						.get(placeholder) - 1;
  				int placeholderEndPos = placeholderStartPos
  						+ placeholder.length() + 2;
  				if (parameters.containsKey(placeholder)) {
  					if (escapeParameters) {
  						completeURI.replace(placeholderStartPos,
  								placeholderEndPos, urlEncodeQuery(parameters
  										.get(placeholder)));
  					} else {
  						completeURI.replace(placeholderStartPos,
  								placeholderEndPos, parameters.get(placeholder));
  					}
  				} else {
  					int qnPos = completeURI.lastIndexOf("?", placeholderStartPos);
   					int ampPos = completeURI.lastIndexOf("&", placeholderStartPos);
   					int slashPos = completeURI.lastIndexOf("/", placeholderStartPos);
   					int startParamPos = Math.max(qnPos, ampPos);
  					if (startParamPos > -1 && startParamPos > slashPos) {
   						// We found an optional parameter, so delete all of it
   						if (qnPos > ampPos) {
   							// It might be the first or only parameter so delete carefully
   							if (placeholderEndPos >= (completeURI.length() - 1)) {
   								// No parameters
   								completeURI.replace(startParamPos, placeholderEndPos, "");
   							} else {
   								// Remove the & from the following parameter, not the ? that starts
   								completeURI.replace(startParamPos + 1, placeholderEndPos + 1, "");
   							}
  						} else {
   							// Just delete the optional parameter in total
  							completeURI.replace(startParamPos, placeholderEndPos, "");
   						}
   					} else {
   						throw new URIGenerationFromSignatureException(
   								"Parameter map does not contain a key/value for \""
   										+ placeholder + "\" mandatory placeholder");
   					}
  				}
  			}
  		}
  		/*
  		 * else { NO PLACEHOLDERS, SO NOTHING TO REPLACE WITH REAL VALUES - JUST
  		 * RETURN THE ORIGINAL 'uriSignature' }
  		 */
  
  		return (completeURI.toString());
  	}
focal_method.class_method_signature: URISignatureHandler.generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_method.full_signature: public static String generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_method.identifier: generateCompleteURI
focal_method.invocations: extractPlaceholdersWithPositions size keySet isEmpty emptyMap keySet reverse iterator hasNext next get length containsKey replace urlEncodeQuery get replace get lastIndexOf lastIndexOf lastIndexOf max length replace replace replace toString
focal_method.modifiers: public static
focal_method.parameters: (String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)
focal_method.return: String
focal_method.signature: String generateCompleteURI(String uriSignature,
  			Map<String, String> specifiedParameters, boolean escapeParameters)