I think this should be:

           if (type == PDataType.CHAR && maxLength != null  && b.length != maxLength) {