Package org.planit.network.physical
Class PhysicalNetwork.LinkSegments
- java.lang.Object
-
- org.planit.network.physical.PhysicalNetwork.LinkSegments
-
- All Implemented Interfaces:
Iterable<LinkSegment>
- Enclosing class:
- PhysicalNetwork
public class PhysicalNetwork.LinkSegments extends Object implements Iterable<LinkSegment>
Internal class for LinkSegment specific code (non-physical link segments are placed in the zoning)
-
-
Constructor Summary
Constructors Constructor Description LinkSegments()
Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LinkSegment
createDirectionalLinkSegment(Link parentLink, boolean directionAB)
Create directional link segmentLinkSegment
getLinkSegment(long id)
Get link segment by idLinkSegment
getLinkSegmentByExternalId(Object externalId)
Retrieve a link segment by its external Id This method is not efficient, since it loops through all the registered modes in order to find the required link segment.LinkSegment
getLinkSegmentByExternalId(Object externalId, boolean convertToLong)
Retrieve a link segment by its external Id This method has the option to convert the external Id parameter into a long value, to find the link segment type when link segment type objects use long values for external ids.LinkSegment
getLinkSegmentByStartAndEndNodeId(long startId, long endId)
Find a LinkSegment by the external Ids of its start and end nodesint
getNumberOfLinkSegments()
Return number of registered link segmentsIterator<LinkSegment>
iterator()
Iterator over available nodesvoid
registerLinkSegment(Link parentLink, LinkSegment linkSegment, boolean directionAB)
Register a link segmentprotected void
registerLinkSegment(LinkSegment linkSegment)
Register a link segment on the network-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
registerLinkSegment
protected void registerLinkSegment(LinkSegment linkSegment) throws PlanItException
Register a link segment on the network- Parameters:
linkSegment
- the link segment to be registered- Throws:
PlanItException
- thrown if the current link segment external Id has already been assigned
-
iterator
public Iterator<LinkSegment> iterator()
Iterator over available nodes- Specified by:
iterator
in interfaceIterable<LinkSegment>
-
getLinkSegmentByStartAndEndNodeId
public LinkSegment getLinkSegmentByStartAndEndNodeId(long startId, long endId)
Find a LinkSegment by the external Ids of its start and end nodes- Parameters:
startId
- reference to start nodeendId
- reference to end node- Returns:
- the linkSegment found
-
createDirectionalLinkSegment
public LinkSegment createDirectionalLinkSegment(Link parentLink, boolean directionAB) throws PlanItException
Create directional link segment- Parameters:
parentLink
- the parent link of this link segmentdirectionAB
- direction of travel- Returns:
- the created link segment
- Throws:
PlanItException
- thrown if there is an error
-
registerLinkSegment
public void registerLinkSegment(Link parentLink, LinkSegment linkSegment, boolean directionAB) throws PlanItException
Register a link segment- Parameters:
parentLink
- the parent link which specified link segment will be registered onlinkSegment
- link segment to be registereddirectionAB
- direction of travel- Throws:
PlanItException
- thrown if there is an error
-
getLinkSegment
public LinkSegment getLinkSegment(long id)
Get link segment by id- Parameters:
id
- id of the link segment- Returns:
- retrieved linkSegment
-
getNumberOfLinkSegments
public int getNumberOfLinkSegments()
Return number of registered link segments- Returns:
- number of registered link segments
-
getLinkSegmentByExternalId
public LinkSegment getLinkSegmentByExternalId(Object externalId, boolean convertToLong)
Retrieve a link segment by its external Id This method has the option to convert the external Id parameter into a long value, to find the link segment type when link segment type objects use long values for external ids.- Parameters:
externalId
- the external Id of the specified link segmentconvertToLong
- if true, the external Id is converted into a long before beginning the search- Returns:
- the retrieved link segment, or null if no mode was found
-
getLinkSegmentByExternalId
public LinkSegment getLinkSegmentByExternalId(Object externalId)
Retrieve a link segment by its external Id This method is not efficient, since it loops through all the registered modes in order to find the required link segment. The equivalent method in InputBuilderListener is more efficient and should be used in preference to this in Java code.- Parameters:
externalId
- the external Id of the specified link segment type- Returns:
- the retrieved link segment, or null if no link segment type was found
-
-