
cz.jalasoft.transportation.czechrailway.page.TrainStopPageFragment.scala Maven / Gradle / Ivy
The newest version!
package cz.jalasoft.transportation.czechrailway.page
import cz.jalasoft.util.text.TextFragment
import scala.collection.JavaConversions._
final class SchedulePageFragment(fragment : TextFragment) {
private val FIRST_STOP_FRAGMENT_BEGIN = ""
private val FIRST_STOP_FRAGMENT_END = ""
private val REGULAR_STOP_FRAGMENT_BEGIN = ""
private val REGULAR_STOP_FRAGMENT_END = ""
private val LAST_STOP_FRAGMENT_BEGIN = ""
private val LAST_STOP_FRAGMENT_END = ""
def firstStation : TrainStopPageFragment = {
val firstStops = fragment.findFragmentsBetween(FIRST_STOP_FRAGMENT_BEGIN, FIRST_STOP_FRAGMENT_END)
new TrainStopPageFragment(firstStops.first())
}
def regularStations : Seq[TrainStopPageFragment] = {
val regularStops = fragment.findFragmentsBetween(REGULAR_STOP_FRAGMENT_BEGIN, REGULAR_STOP_FRAGMENT_END);
regularStops.map { new TrainStopPageFragment(_)}.toSeq
}
def lastStation : TrainStopPageFragment = {
val lastStops = fragment.findFragmentsBetween(LAST_STOP_FRAGMENT_BEGIN, LAST_STOP_FRAGMENT_END)
new TrainStopPageFragment(lastStops.first)
}
}
class TrainStopPageFragment(fragment : TextFragment) {
private val PATTERN = "(.*)\\s(.*)\\s(.*)\\s"
private lazy val matcher = {
val result = fragment.findFragmentsMatching(PATTERN)
result
}
def station : String = {
val k = matcher.get(3)
k.text()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy