001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 018package org.apache.commons.proxy2.util; 019 020import java.io.IOException; 021import java.io.Serializable; 022 023public class EchoImpl extends AbstractEcho implements DuplicateEcho, Serializable 024{ 025 //********************************************************************************************************************** 026 // Fields 027 //********************************************************************************************************************** 028 029 private static final long serialVersionUID = -4844873352607521103L; 030 031 //********************************************************************************************************************** 032 // Echo Implementation 033 //********************************************************************************************************************** 034 035 @Override 036 public void echo() 037 { 038 } 039 040 @Override 041 public boolean echoBack(boolean b) 042 { 043 return b; 044 } 045 046 @Override 047 public String echoBack(String[] messages) 048 { 049 final StringBuilder sb = new StringBuilder(); 050 for (int i = 0; i < messages.length; i++) 051 { 052 String message = messages[i]; 053 sb.append(message); 054 } 055 return sb.toString(); 056 } 057 058 @Override 059 public String echoBack(String[][] messages) 060 { 061 final StringBuilder sb = new StringBuilder(); 062 for (int i = 0; i < messages.length; i++) 063 { 064 sb.append(echoBack(messages[i])); 065 } 066 return sb.toString(); 067 } 068 069 @Override 070 public String echoBack(String[][][] messages) 071 { 072 final StringBuilder sb = new StringBuilder(); 073 for (int i = 0; i < messages.length; i++) 074 { 075 sb.append(echoBack(messages[i])); 076 } 077 return sb.toString(); 078 } 079 080 @Override 081 public int echoBack(int i) 082 { 083 return i; 084 } 085 086 @Override 087 public String echoBack(String message1, String message2) 088 { 089 return message1 + message2; 090 } 091 092 @Override 093 public void illegalArgument() 094 { 095 throw new IllegalArgumentException("dummy message"); 096 } 097 098 @Override 099 public void ioException() throws IOException 100 { 101 throw new IOException("dummy message"); 102 } 103}