public final class SimpleEvaluationContext extends ObjectSE implements EvaluationContext
EvaluationContext
の基本的な実装で、単純な条件評価と特定のデータバインディングシナリオを対象としています。 多くの場合、SpEL 言語の全範囲は必須ではなく、意味のある制限が必要です。例には、データバインディング式、プロパティベースのフィルターなどが含まれます。そのために、SimpleEvaluationContext
は SpEL 言語構文のサブセットのみをサポートするように調整されています。Java 型、コンストラクター、Bean 参照への参照を除外します。
SimpleEvaluationContext
を作成するときは、SpEL 式でのプロパティアクセスに必要なサポートのレベルを選択する必要があります。
PropertyAccessor
(通常、反射ベースではない)、DataBindingPropertyAccessor
と組み合わせる可能性 便利なことに、forReadOnlyDataBinding()
は DataBindingPropertyAccessor
を介してプロパティへの読み取りアクセスを可能にします。forReadWriteDataBinding()
でも書き込みアクセスが必要な場合と同じです。または、forPropertyAccessors(org.springframework.expression.PropertyAccessor...)
を使用してカスタムアクセサーを構成し、ビルダーを介してメソッド解決や型コンバーターをアクティブ化することもできます。
通常、SimpleEvaluationContext
にはデフォルトのルートオブジェクトが設定されていません。代わりに、一度作成され、EvaluationContext
とルートオブジェクトの両方を引数として使用して、事前にコンパイルされた Expression
の getValue
呼び出しを通じて繰り返し使用されることを意図しています: Expression.getValue(EvaluationContext, Object)
。
パワーと柔軟性を高めるため、特に内部構成のシナリオでは、代わりに StandardEvaluationContext
の使用を検討してください。
forPropertyAccessors(org.springframework.expression.PropertyAccessor...)
, forReadOnlyDataBinding()
, forReadWriteDataBinding()
, StandardEvaluationContext
, StandardTypeConverter
, DataBindingPropertyAccessor
修飾子と型 | クラスと説明 |
---|---|
static class | SimpleEvaluationContext.Builder SimpleEvaluationContext のビルダー。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public TypedValue getRootObject()
EvaluationContext
の getRootObject
public ListSE<PropertyAccessor> getPropertyAccessors()
PropertyAccessor
デリゲートがある場合はそれを返します。public ListSE<ConstructorResolver> getConstructorResolvers()
EvaluationContext
の getConstructorResolvers
public ListSE<MethodResolver> getMethodResolvers()
MethodResolver
デリゲートがある場合はそれを返します。@Nullable public BeanResolver getBeanResolver()
SimpleEvaluationContext
は、Bean 参照の使用をサポートしていません。EvaluationContext
の getBeanResolver
null
public TypeLocator getTypeLocator()
SimpleEvaluationContext
は型参照の使用をサポートしていません。EvaluationContext
の getTypeLocator
SpelMessage.TYPE_NOT_FOUND
で SpelEvaluationException
を発生させる TypeLocator
実装。public TypeConverter getTypeConverter()
TypeConverter
。 デフォルトでは、これは StandardTypeConverter
です。
public TypeComparator getTypeComparator()
StandardTypeComparator
のインスタンスを返します。EvaluationContext
の getTypeComparator
public OperatorOverloader getOperatorOverloader()
StandardOperatorOverloader
のインスタンスを返します。EvaluationContext
の getOperatorOverloader
public void setVariable(StringSE name, @Nullable ObjectSE value)
EvaluationContext
EvaluationContext
の setVariable
name
- 設定する変数 value
- 変数に入れる値 @Nullable public ObjectSE lookupVariable(StringSE name)
EvaluationContext
EvaluationContext
の lookupVariable
name
- 検索する変数 null
public static SimpleEvaluationContext.Builder forPropertyAccessors(PropertyAccessor... accessors)
PropertyAccessor
デリゲートの SimpleEvaluationContext
を作成します。通常は、ユースケースに固有のカスタム PropertyAccessor
(カスタムデータ構造での属性解決など)です。プロパティの逆参照も必要な場合は、DataBindingPropertyAccessor
と組み合わせる可能性があります。accessors
- 使用するアクセサーデリゲート DataBindingPropertyAccessor.forReadOnlyAccess()
, DataBindingPropertyAccessor.forReadWriteAccess()
public static SimpleEvaluationContext.Builder forReadOnlyDataBinding()
DataBindingPropertyAccessor
を介してパブリックプロパティに読み取り専用でアクセスする SimpleEvaluationContext
を作成します。public static SimpleEvaluationContext.Builder forReadWriteDataBinding()
DataBindingPropertyAccessor
を介してパブリックプロパティへの読み取り / 書き込みアクセス用の SimpleEvaluationContext
を作成します。