001 /* 002 * Copyright 2002-2004 The Apache Software Foundation 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.apache.commons.clazz.reflect.common; 017 018 import org.apache.commons.clazz.reflect.ReflectedClazz; 019 020 /** 021 * Holds parse results for individual accessor methods for a 022 * scalar property. 023 * 024 * @author <a href="mailto:dmitri@apache.org">Dmitri Plotnikov</a> 025 * @version $Id: ReflectedScalarPropertyParseResults.java 155436 2005-02-26 13:17:48Z dirkv $ 026 */ 027 public class ReflectedScalarPropertyParseResults 028 extends ReflectedPropertyParseResults 029 { 030 /** 031 * Constructor for ReflectedScalarPropertyParseResults. 032 */ 033 public ReflectedScalarPropertyParseResults( 034 ReflectedClazz clazz, String propertyName) 035 { 036 super(clazz, propertyName); 037 } 038 039 protected String getPropertyCategory() { 040 return "scalar"; 041 } 042 043 public boolean checkConsistency() { 044 if (!super.checkConsistency()) { 045 return false; 046 } 047 048 if (readMethodParseResults == null) { 049 return false; 050 } 051 052 Class type = readMethodParseResults.getType(); 053 if (writeMethodParseResults != null) { 054 if (!type.equals(writeMethodParseResults.getType())) { 055 return false; 056 } 057 } 058 return true; 059 } 060 061 protected boolean appendInconsistencyDescriptions(StringBuffer buffer) { 062 if (!super.appendInconsistencyDescriptions(buffer)) { 063 return false; 064 } 065 066 if (readMethodParseResults == null) { 067 buffer.append("\n - Does not have a get() method"); 068 return true; 069 } 070 071 Class type = readMethodParseResults.getType(); 072 if (writeMethodParseResults != null) { 073 if (!type.equals(writeMethodParseResults.getType())) { 074 buffer.append("\n - Get() and set(v) types do not match"); 075 } 076 } 077 return true; 078 } 079 }