All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.uci.ics.jung.io.graphml.parser.ParserContext Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) 2008, The JUNG Authors
 *
 * All rights reserved.
 *
 * This software is open-source under the BSD license; see either
 * "license.txt" or
 * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
 */

package edu.uci.ics.jung.io.graphml.parser;

import com.google.common.base.Function;

import edu.uci.ics.jung.graph.Hypergraph;
import edu.uci.ics.jung.io.graphml.EdgeMetadata;
import edu.uci.ics.jung.io.graphml.GraphMetadata;
import edu.uci.ics.jung.io.graphml.HyperEdgeMetadata;
import edu.uci.ics.jung.io.graphml.KeyMap;
import edu.uci.ics.jung.io.graphml.NodeMetadata;

/**
 * Provides resources related to the current parsing context. 
 * 
 * @author Nathan Mittler - [email protected]
 *
 * @param  The graph type
 * @param  The vertex type
 * @param  The edge type
 */
public class ParserContext, V, E> {

    private final KeyMap keyMap;
    private final ElementParserRegistry elementParserRegistry;
    private final Function graphTransformer;
    private final Function vertexTransformer;
    private final Function edgeTransformer;
    private final Function hyperEdgeTransformer;
    
    public ParserContext(ElementParserRegistry elementParserRegistry, 
            KeyMap keyMap,
            Function graphTransformer,
            Function vertexTransformer,
            Function edgeTransformer,                        
            Function hyperEdgeTransformer ) {
        this.elementParserRegistry = elementParserRegistry;
        this.keyMap = keyMap;
        this.graphTransformer = graphTransformer;
        this.vertexTransformer = vertexTransformer;
        this.edgeTransformer = edgeTransformer;                
        this.hyperEdgeTransformer = hyperEdgeTransformer;                
    }

    public ElementParserRegistry getElementParserRegistry() {
        return elementParserRegistry;
    }
    
    public KeyMap getKeyMap() {
        return keyMap;
    }
    
    public G createGraph(GraphMetadata metadata) {
        return graphTransformer.apply(metadata);
    }
    
    public V createVertex(NodeMetadata metadata) {
        return vertexTransformer.apply(metadata);
    }
    
    public E createEdge(EdgeMetadata metadata) {
        return edgeTransformer.apply(metadata);
    }
    
    public E createHyperEdge(HyperEdgeMetadata metadata) {
        return hyperEdgeTransformer.apply(metadata);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy