/*
 * Copyright 2012-2013 The Open Source Electronic Health Record Agent
 *
 * 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 org.osehra.vista.camel.rpc.codec;

import org.osehra.vista.camel.api.EmptyParameter;
import org.osehra.vista.camel.api.GlobalParameter;
import org.osehra.vista.camel.api.LiteralParameter;
import org.osehra.vista.camel.api.Parameter;
import org.osehra.vista.camel.api.ReferenceParameter;
import org.osehra.vista.camel.rpc.RpcConstants;
import org.osehra.vista.camel.rpc.RpcRequest;


public class RpcCommandsSupport {

	public static RpcRequest connect() {
	    return request()
	    	.code("10304")
	    	.version(null)
	    	.name("TCPConnect")
	    	.parameter(literal("localhost"))
	    	.parameter(literal("0"))
	    	.parameter(literal("localhost"));	
	}
	public static RpcRequest disconnect() {
	    return request()
	    	.code("10304")
	    	.version(null)
	    	.name("#BYE#");	
	}

	public static RpcRequest request() {
		return new RpcRequest()
		    .namespace(RpcConstants.RPC_DEFAULT_NS)
	    	.code(RpcConstants.RPC_DEFAULT_CODE)
		    .version(RpcConstants.RPC_VERSION);
	}

	public static Parameter literal(String value) {
		return new LiteralParameter(value);
	}
	public static Parameter ref(String value) {
		return new ReferenceParameter(value);
	}
	public static Parameter global(String key, String value) {
		return new GlobalParameter(key, value);
	}
	public static Parameter empty() {
		return new EmptyParameter();
	}

	protected RpcCommandsSupport() {
		// TODO: allow inheritance for convenience or enforce static utility class?
	}
}

@@ -1424,16 +1424,389 @@
 #%22);%09%0A%09%7D
+%0A%09public static RpcRequest login(String access, String verify) %7B%0A%09%09StringBuffer av = new StringBuffer()%0A            .append(%221%22).append(access).append(%22;%22).append(verify).append(%221%22);%0A%09    return request()%0A%09    %09.name(%22XUS AV CODE%22)%0A%09    %09.parameter(literal(av.toString()));%09%0A%09%7D%0A%09public static RpcRequest signon() %7B%0A%09    return request()%0A%09    %09.name(%22XUS SIGNON SETUP%22);%0A%09%7D
 %0A%0A%09publi

Add a few more rpc commands