-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4850b5
commit d478310
Showing
5 changed files
with
241 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {EntryHandlerPredicate} from "../entryhandler/EntryHandlerPredicate"; | ||
import {ParsingContext} from "../ParsingContext"; | ||
import {Util} from "../Util"; | ||
import {IContainerHandler} from "./IContainerHandler"; | ||
|
||
/** | ||
* Container handler for @type. | ||
* | ||
* This will add this entry to the parent node, and use the current key as an rdf:type value. | ||
*/ | ||
export class ContainerHandlerType implements IContainerHandler { | ||
|
||
public async handle(parsingContext: ParsingContext, util: Util, keys: string[], value: any, depth: number) | ||
: Promise<void> { | ||
if (!Array.isArray(value)) { | ||
// Handle the value of this node, which will also cause the type predicate from above to be emitted. | ||
await parsingContext.newOnValueJob(keys, value, depth - 1, true); | ||
|
||
// Identify the type to emit. | ||
const keyOriginal = keys[depth]; | ||
const context = await parsingContext.getContext(keys); | ||
const type = util.createVocabOrBaseTerm(context, keyOriginal); | ||
if (type) { | ||
// Push the type to the stack using the rdf:type predicate | ||
await EntryHandlerPredicate.handlePredicateObject(parsingContext, util, keys, depth + 1, null, | ||
util.rdfType, type, false); | ||
} | ||
|
||
// Flush any pending flush buffers | ||
await parsingContext.handlePendingContainerFlushBuffers(); | ||
} | ||
|
||
parsingContext.emittedStack[depth] = false; // Don't emit the predicate owning this container. | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters