| /******************************************************************************* |
| * Copyright (c) 2004-2008 Andras Schmidt, Andras Balogh, Istvan Rath and Daniel Varro |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Andras Schmidt, Andras Balogh, Istvan Rath - initial API and implementation |
| *******************************************************************************/ |
| |
| package org.eclipse.viatra2.buffers; |
| |
| import java.io.StringWriter; |
| |
| import org.eclipse.viatra2.core.IModelSpace; |
| import org.eclipse.viatra2.errors.VPMRuntimeException; |
| import org.eclipse.viatra2.natives.ASMNativeFunction; |
| |
| public class BufferPrint implements ASMNativeFunction { |
| |
| public Object evaluate(IModelSpace msp, Object[] params) |
| throws VPMRuntimeException { |
| if (params[0] instanceof StringWriter) { |
| StringWriter out = (StringWriter) params[0]; |
| int ctr = 0; |
| for (int i = 1; i < params.length; i++) { |
| String s = params[i].toString(); |
| out.write(s); |
| ctr += s.length(); |
| } |
| return ctr; |
| } else |
| return 0; |
| } |
| |
| public String getDescription() { |
| return "Prints output to the given buffer."; |
| } |
| |
| public String getID() { |
| return "bufferPrint"; |
| } |
| |
| public String getName() { |
| return "bufferPrint"; |
| } |
| |
| } |