public class ReflectivePropertyAccessor extends ObjectSE implements PropertyAccessor
PropertyAccessor
。プロパティは、パブリック getter メソッド(読み取り時)またはパブリック setter メソッド(書き込み時)を通じて、およびパブリックフィールドとしても参照できます。
StandardEvaluationContext
, SimpleEvaluationContext
, DataBindingPropertyAccessor
修飾子と型 | クラスと説明 |
---|---|
static class | ReflectivePropertyAccessor.OptimalPropertyAccessor リフレクションを使用するが、特定のクラスの特定のプロパティにアクセスする方法のみを知っている PropertyAccessor の最適化された形式。 |
コンストラクターと説明 |
---|
ReflectivePropertyAccessor() 読み取りおよび書き込み用の新しいプロパティアクセサーを作成します。 |
ReflectivePropertyAccessor(boolean allowWrite) 読み取りおよび場合によっては書き込み用の新しいプロパティアクセサーを作成します。 |
修飾子と型 | メソッドと説明 |
---|---|
boolean | canRead(EvaluationContext context, ObjectSE target, StringSE name) リゾルバーインスタンスが指定されたターゲットオブジェクトの指定されたプロパティにアクセスできるかどうかを判断するために呼び出されます。 |
boolean | canWrite(EvaluationContext context, ObjectSE target, StringSE name) リゾルバーインスタンスが指定されたターゲットオブジェクトの指定されたプロパティに書き込むことができるかどうかを判断するために呼び出されます。 |
PropertyAccessor | createOptimalAccessor(EvaluationContext context, ObjectSE target, StringSE name) 特定のクラスの特定の名前のプロパティに合わせて最適化されたプロパティアクセサーを作成しようとします。 |
protected FieldSE | findField(StringSE name, ClassSE<?> clazz, boolean mustBeStatic) 指定されたクラスで特定の名前のフィールドを検索します。 |
protected MethodSE | findGetterForProperty(StringSE propertyName, ClassSE<?> clazz, boolean mustBeStatic) 指定されたプロパティの getter メソッドを見つけます。 |
protected MethodSE | findSetterForProperty(StringSE propertyName, ClassSE<?> clazz, boolean mustBeStatic) 指定されたプロパティの setter メソッドを見つけます。 |
MemberSE | getLastReadInvokerPair() 使用すべきではありません。 4.3.15 の時点で、フレームワーク内で使用されなくなったため |
protected StringSE | getPropertyMethodSuffix(StringSE propertyName) 特定のプロパティ名のメソッドサフィックスを返します。 |
protected StringSE[] | getPropertyMethodSuffixes(StringSE propertyName) 指定されたプロパティ名のメソッドサフィックスを返します。 |
ClassSE<?>[] | getSpecificTargetClasses() null を返します。これは、これが汎用アクセサーであることを意味します。 |
protected boolean | isCandidateForProperty(MethodSE method, ClassSE<?> targetClass) 指定された Method が、指定されたターゲットクラスのインスタンスのプロパティアクセスの候補であるかどうかを判断します。 |
TypedValue | read(EvaluationContext context, ObjectSE target, StringSE name) 指定されたターゲットオブジェクトからプロパティを読み取るために呼び出されます。 |
void | write(EvaluationContext context, ObjectSE target, StringSE name, ObjectSE newValue) 指定されたターゲットオブジェクトのプロパティに書き込むために呼び出されます。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public ReflectivePropertyAccessor()
public ReflectivePropertyAccessor(boolean allowWrite)
allowWrite
- ターゲットインスタンスで書き込み操作を許可するかどうか canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
@Nullable public ClassSE<?>[] getSpecificTargetClasses()
null
を返します。これは、これが汎用アクセサーであることを意味します。PropertyAccessor
の getSpecificTargetClasses
null
)public boolean canRead(EvaluationContext context, @Nullable ObjectSE target, StringSE name) throws AccessException
PropertyAccessor
PropertyAccessor
の canRead
context
- アクセスが試行されている評価コンテキスト target
- プロパティがアクセスされるターゲットオブジェクト name
- アクセスされるプロパティの名前 AccessException
- プロパティを読み取ることができるかどうかを判断する際に問題がある場合 public TypedValue read(EvaluationContext context, @Nullable ObjectSE target, StringSE name) throws AccessException
PropertyAccessor
PropertyAccessor.canRead(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
も true
を返す場合にのみ成功します。PropertyAccessor
の read
context
- アクセスが試行されている評価コンテキスト target
- プロパティがアクセスされるターゲットオブジェクト name
- アクセスされるプロパティの名前 AccessException
- プロパティ値へのアクセスに問題がある場合 public boolean canWrite(EvaluationContext context, @Nullable ObjectSE target, StringSE name) throws AccessException
PropertyAccessor
PropertyAccessor
の canWrite
context
- アクセスが試行されている評価コンテキスト target
- プロパティがアクセスされるターゲットオブジェクト name
- アクセスされるプロパティの名前 AccessException
- プロパティを書き込むことができるかどうかを判断する際に問題がある場合 public void write(EvaluationContext context, @Nullable ObjectSE target, StringSE name, @Nullable ObjectSE newValue) throws AccessException
PropertyAccessor
PropertyAccessor.canWrite(org.springframework.expression.EvaluationContext, java.lang.Object, java.lang.String)
も true
を返す場合にのみ成功します。PropertyAccessor
の write
context
- アクセスが試行されている評価コンテキスト target
- プロパティがアクセスされるターゲットオブジェクト name
- アクセスされるプロパティの名前 newValue
- プロパティの新しい値 AccessException
- プロパティ値への書き込みに問題がある場合 @DeprecatedSE @Nullable public MemberSE getLastReadInvokerPair()
@Nullable protected MethodSE findGetterForProperty(StringSE propertyName, ClassSE<?> clazz, boolean mustBeStatic)
@Nullable protected MethodSE findSetterForProperty(StringSE propertyName, ClassSE<?> clazz, boolean mustBeStatic)
protected boolean isCandidateForProperty(MethodSE method, ClassSE<?> targetClass)
Method
が、指定されたターゲットクラスのインスタンスのプロパティアクセスの候補であるかどうかを判断します。 デフォルトの実装では、Object
SE 基本クラスでユーザーが宣言していないプロパティであっても、すべてのメソッドが候補と見なされます。
method
- 評価する方法 targetClass
- イントロスペクトされている具体的なターゲットクラス protected StringSE[] getPropertyMethodSuffixes(StringSE propertyName)
protected StringSE getPropertyMethodSuffix(StringSE propertyName)
@Nullable protected FieldSE findField(StringSE name, ClassSE<?> clazz, boolean mustBeStatic)
public PropertyAccessor createOptimalAccessor(EvaluationContext context, @Nullable ObjectSE target, StringSE name)
メモ: 最適なアクセサーは現在、読み取り試行のみに使用できます。読み取り / 書き込みアクセサーが必要な場合は、このメソッドを呼び出さないでください。