// Path: core/src/main/java/net/javacrumbs/mocksocket/connection/data/SocketData.java
// public interface SocketData {
// 
// 	public InputStream getData();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/util/Utils.java
// public class Utils {
// 	private Utils()
// 	{
// 		//empty
// 	}
// 	
// 	public static final byte[] toByteArray(InputStream stream)
// 	{
// 		try 
// 		{
// 			return IOUtils.toByteArray(stream);
// 		} 
// 		catch (IOException e)
// 		{
// 			throw new MockSocketException("Can not read data.",e);
// 		}
// 		finally
// 		{
// 			IOUtils.closeQuietly(stream);
// 		}
// 	}
// }


import net.javacrumbs.mocksocket.connection.data.SocketData;
import net.javacrumbs.mocksocket.util.Utils;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
/*
 * Copyright 2005-2010 the original author or authors.
 *
 * 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 net.javacrumbs.mocksocket.matchers;



public class DataMatcher extends AbstractSocketMatcher<SocketData> {


	public DataMatcher(Matcher<byte[]> wrappedMatcher) {
		super(wrappedMatcher);
	}

	public void describeTo(Description description) {
		description.appendText("data ").appendDescriptionOf(getWrappedMatcher());
	}

	public boolean matches(Object item) {
		if (item instanceof SocketData) {
// Path: core/src/main/java/net/javacrumbs/mocksocket/connection/data/SocketData.java
// public interface SocketData {
// 
// 	public InputStream getData();
// }
// 
// Path: core/src/main/java/net/javacrumbs/mocksocket/util/Utils.java
// public class Utils {
// 	private Utils()
// 	{
// 		//empty
// 	}
// 	
// 	public static final byte[] toByteArray(InputStream stream)
// 	{
// 		try 
// 		{
// 			return IOUtils.toByteArray(stream);
// 		} 
// 		catch (IOException e)
// 		{
// 			throw new MockSocketException("Can not read data.",e);
// 		}
// 		finally
// 		{
// 			IOUtils.closeQuietly(stream);
// 		}
// 	}
// }


// Path: core/src/main/java/net/javacrumbs/mocksocket/matchers/DataMatcher.java
import net.javacrumbs.mocksocket.connection.data.SocketData;
import net.javacrumbs.mocksocket.util.Utils;
import org.hamcrest.Description;
import org.hamcrest.Matcher;

/*
 * Copyright 2005-2010 the original author or authors.
 *
 * 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 net.javacrumbs.mocksocket.matchers;



public class DataMatcher extends AbstractSocketMatcher<SocketData> {


	public DataMatcher(Matcher<byte[]> wrappedMatcher) {
		super(wrappedMatcher);
	}

	public void describeTo(Description description) {
		description.appendText("data ").appendDescriptionOf(getWrappedMatcher());
	}

	public boolean matches(Object item) {
		if (item instanceof SocketData) {
			return getWrappedMatcher().matches(Utils.toByteArray(((SocketData) item).getData()));