public Object normalize ( Map < String , Object > dataset ) throws JsonLdError { // create quads and map bnodes to their associated quads final List < Object > quads = new ArrayList < Object > ( ) ; final Map < String , Object > bnodes = newMap ( ) ; for ( String graphName : dataset . keySet ( ) ) { final List < Map < String , Object > > triples = ( List < Map < String , Object > > ) dataset . get ( graphName ) ; if ( JsonLdConsts . DEFAULT . equals ( graphName ) ) { graphName = null ; } for ( final Map < String , Object > quad : triples ) { if ( graphName != null ) { if ( graphName . indexOf ( "_:" ) == 0 ) { final Map < String , Object > tmp = newMap ( ) ; tmp . put ( "type" , "blank node" ) ; tmp . put ( "value" , graphName ) ; quad . put ( "name" , tmp ) ; } else { final Map < String , Object > tmp = newMap ( ) ; tmp . put ( "type" , "IRI" ) ; tmp . put ( "value" , graphName ) ; quad . put ( "name" , tmp ) ; } } quads . add ( quad ) ; final String [ ] attrs = new String [ ] { "subject" , "object" , "name" } ; for ( final String attr : attrs ) { if ( quad . containsKey ( attr ) && "blank node" . equals ( ( ( Map < String , Object > ) quad . get ( attr ) ) . get ( "type" ) ) ) { final String id = ( String ) ( ( Map < String , Object > ) quad . get ( attr ) ) . get ( "value" ) ; if ( ! bnodes . containsKey ( id ) ) { bnodes . put ( id , new LinkedHashMap < String , List < Object > > ( ) { { put ( "quads" , new ArrayList < Object > ( ) ) ; } } ) ; } ( ( List < Object > ) ( ( Map < String , Object > ) bnodes . get ( id ) ) . get ( "quads" ) ) . add ( quad ) ; } } } } // mapping complete, start canonical naming final NormalizeUtils normalizeUtils = new NormalizeUtils ( quads , bnodes , new UniqueNamer ( "_:c14n" ) , opts ) ; return normalizeUtils . hashBlankNodes ( bnodes . keySet ( ) ) ; }
Performs RDF normalization on the given JSON - LD input .