public PathTemplate parse(String path) throws PathParseException {
		String pathString;
		String tailString = null;
		if((terminator != null)&&(!terminator.isEmpty())) {
			int terminatorIndex = path.lastIndexOf(terminator);
			if(terminatorIndex != -1) {
				pathString = path.substring(0, terminatorIndex);
				tailString = path.substring(terminatorIndex + 1, path.length());
			} else 
				pathString = path;
		} else {
			pathString = path;
		}
		PathTemplate result = new PathTemplate(delimiter, terminator, tailString);

		String elements[] = tokenize(delimiter, pathString); 
		boolean isFirst = true;
		boolean foundGreedy = false;
		for(String element : elements) {
			if(foundGreedy)
				throw new PathParseException(String.format("The path element '%s' follows a greedy template in the path template '%s'",
						element, path));
			if((isFirst)&&((element == null) || (element.isEmpty()))) {
				isFirst = false;
				continue;
			}
			PathElementTemplate pet = toTemplate(element);
			if(pet instanceof GreedyTemplate)
				foundGreedy = true;
			result.add(pet);
			isFirst = false;
		}
		
		return result;
	}