001package jmri.jmrix.ecos.utilities; 002 003 004/** 005 * This method simply returns a integer value from a string, that is between 006 * two given character positions. 007 * 008 * @author Kevin Dickerson Copyright (C) 2009 009 */ 010public class GetEcosObjectNumber { 011 012 /** 013 * @param s Name of this action, e.g. in menus. 014 * @param start start string. 015 * @param finish finish string. 016 * @return object number. 017 */ 018 static public int getEcosObjectNumber(String s, String start, String finish) { 019 int intStart = 0; 020 int intEnd; 021 if (start != null) { 022 intStart = s.indexOf(start) + start.length(); 023 } 024 if (finish == null) { 025 intEnd = s.length(); 026 } else { 027 /* Make sure that the finish substring is searched for only after the start substring appears in s */ 028 String s2 = s.substring(intStart, s.length()); 029 intEnd = s2.indexOf(finish) + intStart; 030 } 031 int object = Integer.parseInt(s.substring(intStart, intEnd)); 032 return object; 033 } 034 035}