Changeset View
Changeset View
Standalone View
Standalone View
java/src/main/java/org/softwareheritage/graph/NodesFiltering.java
package org.softwareheritage.graph; | package org.softwareheritage.graph; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
/** | /** | ||||
* <h3>NodesFiltering</h3> | * NodesFiltering | ||||
* <p> | * <p> | ||||
* class that manages the filtering of nodes that have been returned after a visit of the graph. | * class that manages the filtering of nodes that have been returned after a visit of the graph. | ||||
* parameterized by a string that represents either no filtering (*) or a set of node types. | * parameterized by a string that represents either no filtering (*) or a set of node types. | ||||
* </p> | * </p> | ||||
* | * | ||||
* <ul> | * <ul> | ||||
* | * | ||||
* <li>graph/visit/nodes/swh:1:rel:0000000000000000000000000000000000000010 return_types==rev will | * <li>graph/visit/nodes/swh:1:rel:0000000000000000000000000000000000000010 return_types==rev will | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public class NodesFiltering { | ||||
* </p> | * </p> | ||||
* | * | ||||
* @param nodeIds the nodes founded during the visit | * @param nodeIds the nodes founded during the visit | ||||
* @param g the graph in order to find the types of nodes from their id in nodeIds | * @param g the graph in order to find the types of nodes from their id in nodeIds | ||||
* @return a new list with the id of node which have a type in allowedTypes | * @return a new list with the id of node which have a type in allowedTypes | ||||
* | * | ||||
* | * | ||||
*/ | */ | ||||
public ArrayList<Long> filterByNodeTypes(ArrayList<Long> nodeIds, Graph g) { | public ArrayList<Long> filterByNodeTypes(ArrayList<Long> nodeIds, SwhBidirectionalGraph g) { | ||||
ArrayList<Long> filteredNodes = new ArrayList<Long>(); | ArrayList<Long> filteredNodes = new ArrayList<Long>(); | ||||
for (Long node : nodeIds) { | for (Long node : nodeIds) { | ||||
if (this.typeIsAllowed(g.getNodeType(node))) { | if (this.typeIsAllowed(g.getNodeType(node))) { | ||||
filteredNodes.add(node); | filteredNodes.add(node); | ||||
} | } | ||||
} | } | ||||
return filteredNodes; | return filteredNodes; | ||||
} | } | ||||
} | } |