Class JsonValidateCommand
java.lang.Object
com.streamconverter.command.AbstractStreamCommand
com.streamconverter.command.ConsumerCommand
com.streamconverter.command.impl.json.JsonValidateCommand
- All Implemented Interfaces:
IStreamCommand
JSONスキーマバリデーションを行うコマンドクラス
JSONスキーマファイルを使用してJSONデータのバリデーションを実行します。 バリデーションエラーが発生した場合は、詳細なエラー情報とともに例外をスローします。
技術的制約について:
JSON Schema検証では構造全体の検証が必要なため、完全なストリーミング処理は技術的に困難です。 本実装では任意サイズのデータを受け入れつつ、Jackson streaming
APIを使用してメモリ効率を最大化しています。
完全ストリーミング処理について:
真のストリーミング処理が必要な場合はJsonStreamingValidateCommand
の使用を検討してください。
JsonSurferによる完全ストリーミング検証で、任意サイズのデータを一定メモリで処理できます。
使用例:
JsonValidateCommand validator = new JsonValidateCommand("schema/user.json"); validator.consume(jsonInputStream);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
consume
(InputStream inputStream) JSONバリデーションを実行しますスキーマパスを取得Methods inherited from class com.streamconverter.command.ConsumerCommand
executeInternal
Methods inherited from class com.streamconverter.command.AbstractStreamCommand
execute, getCommandDetails
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.streamconverter.command.IStreamCommand
execute
-
Constructor Details
-
JsonValidateCommand
コンストラクタ- Parameters:
schemaPath
- JSONスキーマファイルのパス- Throws:
IllegalArgumentException
- スキーマパスがnullまたは空の場合StreamProcessingException
- スキーマファイルの読み込みに失敗した場合
-
-
Method Details
-
consume
JSONバリデーションを実行します- Specified by:
consume
in classConsumerCommand
- Parameters:
inputStream
- 検証対象のJSONデータを含む入力ストリーム- Throws:
IOException
- I/Oエラーが発生した場合StreamProcessingException
- JSONバリデーションエラーが発生した場合
-
getSchemaPath
スキーマパスを取得- Returns:
- スキーマファイルのパス
-