public class RandomGenerator extends Object implements IGenerator
handlers package for implemented handlers.| Constructor and Description |
|---|
RandomGenerator(IHandler stringHandler,
IHandler integerHandler,
IHandler numberHandler,
IHandler booleanHandler,
IHandler enumHandler,
IHandler objectHandler,
IHandler arrayHandler) |
| Modifier and Type | Method and Description |
|---|---|
Iterator<org.json.JSONObject> |
createIterator(JSONSchema schema,
int documentDepth,
boolean canGenerateInvalid)
Creates an iterator over the documents this generator can produce up to the
given document depth.
|
Iterator<org.json.JSONObject> |
createIterator(JSONSchema schema,
int documentDepth,
boolean canGenerateInvalid,
Random rand) |
org.json.JSONObject |
generate(JSONSchema schema,
int maxTreeSize,
boolean canGenerateInvalid) |
org.json.JSONObject |
generate(JSONSchema schema,
int maxTreeSize,
boolean canGenerateInvalid,
Random rand) |
Object |
generateAccordingToConstraints(JSONSchema schema,
int maxTreeSize,
boolean canGenerateInvalid,
Random rand)
Generates a value according to the constraints given by
schema. |
IHandler |
getArrayHandler() |
IHandler |
getBooleanHandler() |
IHandler |
getEnumHandler() |
IHandler |
getIntegerHandler() |
IHandler |
getNumberHandler() |
IHandler |
getObjectHandler() |
IHandler |
getStringHandler() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreateIterator, createIterator, createIteratorpublic Iterator<org.json.JSONObject> createIterator(JSONSchema schema, int documentDepth, boolean canGenerateInvalid)
IGeneratornext().
The depth of the documents is bounded, i.e., in any document, there can only
be at most maxDocumentDepth nested objects and arrays.
Note that if the bound is set too low, only invalid documents may be
generated as the deepest objects or arrays may not be correct.
In particular, no documents will be generated with a depth of zero.
Invalid documents can be generated if canGenerateInvalid is
true.
Note that valid documents can still be generated, no matter the value of
canGenerateInvalid.createIterator in interface IGeneratorschema - The schemadocumentDepth - The maximal depth of the documentscanGenerateInvalid - Whether invalid documents can be generatedpublic Iterator<org.json.JSONObject> createIterator(JSONSchema schema, int documentDepth, boolean canGenerateInvalid, Random rand)
public org.json.JSONObject generate(JSONSchema schema, int maxTreeSize, boolean canGenerateInvalid) throws JSONSchemaException, org.json.JSONException, GeneratorException
JSONSchemaExceptionorg.json.JSONExceptionGeneratorExceptionpublic org.json.JSONObject generate(JSONSchema schema, int maxTreeSize, boolean canGenerateInvalid, Random rand) throws JSONSchemaException, org.json.JSONException, GeneratorException
JSONSchemaExceptionorg.json.JSONExceptionGeneratorExceptionpublic IHandler getStringHandler()
public IHandler getIntegerHandler()
public IHandler getNumberHandler()
public IHandler getObjectHandler()
public IHandler getArrayHandler()
public IHandler getBooleanHandler()
public IHandler getEnumHandler()
public Object generateAccordingToConstraints(JSONSchema schema, int maxTreeSize, boolean canGenerateInvalid, Random rand) throws org.json.JSONException, JSONSchemaException, GeneratorException
schema.schema - The JSON schemamaxTreeSize - The maximal tree depth that can be generatedrand - The random generatororg.json.JSONExceptionJSONSchemaExceptionGeneratorExceptionCopyright © 2022. All rights reserved.