Package dev.roanh.gmark
Class ConfigParser
java.lang.Object
dev.roanh.gmark.ConfigParser
Parser to read complete gMark task configurations.
-
Field Summary
Modifier and TypeFieldDescriptionFunction to cast nodes to elements. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic final void
forEach
(NamedNodeMap data, BiConsumer<String, String> consumer) Invokes the given consumer with the name and value of each entry in the given named node map.static final Element
getElement
(Element elem, String name) Gets the the child element from the given element with the given tag name.static final Configuration
parse
(InputStream in) Parses a gMark XML configuration from the given input stream.static final Configuration
Parses a gMark XML configuration from the given file.private static final Distribution
parseDistribution
(Element elem, String key) Parses a distribution section (indistribution
oroutdistribution
) of the configuration XML.parsePredicates
(Element elem) Parses thepredicates
section from the configuration OutputXML.private static final Schema
Parses theschema
section of the configuration XML.parseTypes
(Element elem) Parses thetypes
section of the configuration OutputXML.Returns a stream over all the child elements with the given tag name in the given element.Returns a stream over all the nodes in the given node list.
-
Field Details
-
TO_ELEMENT
Function to cast nodes to elements.
-
-
Constructor Details
-
ConfigParser
private ConfigParser()Prevent instantiation.
-
-
Method Details
-
parse
Parses a gMark XML configuration from the given file.- Parameters:
file
- The file to read from.- Returns:
- The parsed gMark configuration.
- Throws:
ConfigException
- When something when wrong while parsing the configuration.
-
parse
Parses a gMark XML configuration from the given input stream.- Parameters:
in
- The input stream to read from.- Returns:
- The parsed gMark configuration.
- Throws:
ConfigException
- When something when wrong while parsing the configuration.
-
parseSchema
Parses theschema
section of the configuration XML.- Parameters:
elem
- The schema XML element to parse.types
- A list of already parsed configuration node types.predicates
- A list of already parsed configuration predicates.- Returns:
- The parsed graph schema.
-
parseDistribution
Parses a distribution section (indistribution
oroutdistribution
) of the configuration XML.- Parameters:
elem
- The element to parse.key
- The name of the tag to parse of the element (indistribution
oroutdistribution
).- Returns:
- The parsed distribution.
-
parseTypes
Parses thetypes
section of the configuration OutputXML. This section has the following format:<types> <size>5</size> <alias type="0">researcher</alias> <proportion type="0">0.5</proportion> <alias type="1">paper</alias> <proportion type="1">0.3</proportion> <alias type="2">journal</alias> <proportion type="2">0.1</proportion> <alias type="3">conference</alias> <proportion type="3">0.1</proportion> <alias type="4">city</alias> <fixed type="4">100</fixed> </types>
- Parameters:
elem
- The element to parse with the type data.- Returns:
- The types parsed from the element sorted by ID.
-
parsePredicates
Parses thepredicates
section from the configuration OutputXML. This section has the following format:<predicates> <size>4</size> <alias symbol="0">authors</alias> <proportion symbol="0">0.5</proportion> <alias symbol="1">publishedIn</alias> <proportion symbol="1">0.3<</proportion> <alias symbol="2">heldIn</alias> <proportion symbol="2">0.01</proportion> <alias symbol="3">extendedTo</alias> <proportion symbol="3">0.19</proportion> </predicates>
- Parameters:
elem
- The element to parse with the predicate data.- Returns:
- The parsed predicates from the element sorted by ID.
-
stream
Returns a stream over all the child elements with the given tag name in the given element.- Parameters:
elem
- The element whose children to stream.name
- The tag name to filter by.- Returns:
- A stream over all child elements with the given tag name.
-
stream
Returns a stream over all the nodes in the given node list.- Parameters:
list
- The node list to stream.- Returns:
- A stream over all node list elements.
- See Also:
-
getElement
Gets the the child element from the given element with the given tag name. If there are multiple elements that match the given tag name only the first is returned.- Parameters:
elem
- The element whose child to get.name
- The tag name of the child to get.- Returns:
- The child element with the given tag name.
-
forEach
Invokes the given consumer with the name and value of each entry in the given named node map.- Parameters:
data
- The named node map to iterate.consumer
- The consumer to invoke with each name value pair.- See Also:
-