/*
 * Copyright 2012-2015 MarkLogic Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.marklogic.client.document;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.marklogic.client.util.RequestParameters;

/**
 * ServerTransform specifies the invocation of a transform on the server
 * including both the name of the transform and the parameters passed
 * to the transform.
 */
public class ServerTransform extends RequestParameters {
	private String name;

	/**
	 * Specifies invocation of the named transform on the server.
	 * @param name	the transform installed on the server
	 */
	public ServerTransform(String name) {
		super();
    	this.name = name;
	}

	/**
	 * Gets the name of the invoked transform.
	 * @return	the name of the transform installed on the server
	 */
	public String getName() {
		return name;
	}

	/**
	 * Merges the transform and its parameters with other parameters
	 * of the request.
	 * 
	 * Ordinarily, and application does not need to call this method.
	 * @param currentParams	the other parameters
	 * @return	the union of the other parameters and the transform parameters
	 */
	public Map<String,List<String>> merge(Map<String,List<String>> currentParams) {
		Map<String,List<String>> params = (currentParams != null) ?
				currentParams : new RequestParameters();

		params.put("transform", Arrays.asList(getName()));

		for (Map.Entry<String, List<String>> entry: entrySet()) {
			params.put("trans:"+entry.getKey(), entry.getValue());
		}

		return params;
	}
}

@@ -1376,32 +1376,322 @@
 eturn name;%0A%09%7D%0A%0A
+%09/**%0A%09 * Appends a value to the list for a parameter and returns this instance for%0A%09 * method chaining.%0A%09 * @param name%09the parameter%0A%09 * @param value%09the value to add to the list%0A%09 */%0A%09public ServerTransform addParameter(String name, String value) %7B%0A%09%09add(name, value);%0A%09%09return this;%0A%09%7D%0A%0A
 %09/**%0A%09 * Merges 

add method ServerTransform.addParameter