Package com.networknt.schema
Class CollectorContext
- java.lang.Object
-
- com.networknt.schema.CollectorContext
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCollectorContext.Scope
-
Constructor Summary
Constructors Constructor Description CollectorContext()CollectorContext(boolean disableUnevaluatedItems, boolean disableUnevaluatedProperties)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <E> voidadd(String name, Collector<E> collector)Adds a collector with give name.<E> voidadd(String name, Object object)Adds a collector or a simple object with give name.voidcombineWithCollector(String name, Object data)Combines data with Collector identified by the given name.CollectorContext.ScopeenterDynamicScope()Creates a new scopeCollectorContext.ScopeenterDynamicScope(JsonSchema containingSchema)Creates a new scopeCollectorContext.ScopeexitDynamicScope()Restores the previous, parent scopeObjectget(String name)Gets the data associated with a given name.Map<String,Object>getAll()Returns all the collected data.CollectorContext.ScopegetDynamicScope()Provides the currently active scopeCollection<String>getEvaluatedItems()Identifies which array items have been evaluated.Collection<String>getEvaluatedProperties()Identifies which properties have been evaluated.JsonSchemagetOutermostSchema()
-
-
-
Method Detail
-
enterDynamicScope
public CollectorContext.Scope enterDynamicScope()
Creates a new scope- Returns:
- the previous, parent scope
-
enterDynamicScope
public CollectorContext.Scope enterDynamicScope(JsonSchema containingSchema)
Creates a new scope- Parameters:
containingSchema- the containing schema- Returns:
- the previous, parent scope
-
exitDynamicScope
public CollectorContext.Scope exitDynamicScope()
Restores the previous, parent scope- Returns:
- the exited scope
-
getDynamicScope
public CollectorContext.Scope getDynamicScope()
Provides the currently active scope- Returns:
- the active scope
-
getOutermostSchema
public JsonSchema getOutermostSchema()
-
getEvaluatedItems
public Collection<String> getEvaluatedItems()
Identifies which array items have been evaluated.- Returns:
- the set of evaluated items (never null)
-
getEvaluatedProperties
public Collection<String> getEvaluatedProperties()
Identifies which properties have been evaluated.- Returns:
- the set of evaluated properties (never null)
-
add
public <E> void add(String name, Collector<E> collector)
Adds a collector with give name. Preserving this method for backward compatibility.- Type Parameters:
E- element- Parameters:
name- Stringcollector- Collector
-
add
public <E> void add(String name, Object object)
Adds a collector or a simple object with give name.- Type Parameters:
E- element- Parameters:
object- Objectname- String
-
get
public Object get(String name)
Gets the data associated with a given name. Please note if you are collectingCollectorinstances you should wait till the validation is complete to gather all data.When
CollectorContextis used to collectCollectorinstances for a particular key, this method will return theCollectorinstance as long asloadCollectors()method is not called. Once theloadCollectors()method is called this method will return the actual data collected by collector.- Parameters:
name- String- Returns:
- Object
-
getAll
public Map<String,Object> getAll()
Returns all the collected data. Please look intoget(String)method for more details.- Returns:
- Map
-
-