001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.commons.encoding; 021 022import java.io.IOException; 023import java.util.Arrays; 024 025import org.slf4j.Logger; 026import org.slf4j.LoggerFactory; 027 028public class DebugDataInputExtended extends DataInputExtendedDecorator { 029 030 private static final Logger LOG = LoggerFactory.getLogger(DebugDataInputExtended.class); 031 032 public DebugDataInputExtended(final DataInputExtended input) { 033 super(input); 034 } 035 036 @Override 037 public boolean readBoolean() throws IOException { 038 final boolean b = super.readBoolean(); 039 if (LOG.isDebugEnabled()) { 040 LOG.debug("boolean: " + b); 041 } 042 return b; 043 } 044 045 @Override 046 public byte readByte() throws IOException { 047 final byte b = super.readByte(); 048 if (LOG.isDebugEnabled()) { 049 LOG.debug("byte: " + b); 050 } 051 return b; 052 } 053 054 @Override 055 public byte[] readBytes() throws IOException { 056 final byte[] bs = super.readBytes(); 057 if (LOG.isDebugEnabled()) { 058 LOG.debug("bytes: " + new String(bs)); 059 } 060 return bs; 061 } 062 063 @Override 064 public int readInt() throws IOException { 065 final int i = super.readInt(); 066 if (LOG.isDebugEnabled()) { 067 LOG.debug("int: " + i); 068 } 069 return i; 070 } 071 072 @Override 073 public long readLong() throws IOException { 074 final long l = super.readLong(); 075 if (LOG.isDebugEnabled()) { 076 LOG.debug("long: " + l); 077 } 078 return l; 079 } 080 081 @Override 082 public String readUTF() throws IOException { 083 final String string = super.readUTF(); 084 if (LOG.isDebugEnabled()) { 085 LOG.debug("string: " + string); 086 } 087 return string; 088 } 089 090 @Override 091 public String[] readUTFs() throws IOException { 092 final String[] strings = super.readUTFs(); 093 if (LOG.isDebugEnabled()) { 094 LOG.debug("list: " + Arrays.toString(strings)); 095 } 096 return strings; 097 } 098 099 @Override 100 public <T> T readEncodable(final Class<T> encodableType) throws IOException { 101 final T object = super.readEncodable(encodableType); 102 if (LOG.isDebugEnabled()) { 103 LOG.debug(">>> object"); 104 } 105 return object; 106 } 107 108 @Override 109 public <T> T[] readEncodables(final Class<T> encodableType) throws IOException { 110 final T[] objects = super.readEncodables(encodableType); 111 if (LOG.isDebugEnabled()) { 112 LOG.debug(">>> objects x" + objects.length); 113 } 114 return objects; 115 } 116 117}