001package jmri.jmrit.operations.trains; 002 003import org.jdom2.Attribute; 004import org.jdom2.Element; 005 006/** 007 * Loads and stores the manifest header text strings. 008 * 009 * @author Daniel Boudreau Copyright (C) 2014 010 * 011 */ 012public class TrainManifestHeaderText { 013 014 private static String road = Bundle.getMessage("Road"); // the supported message format options 015 private static String number = Bundle.getMessage("Number"); 016 private static String engine_number = Bundle.getMessage("Number"); 017 private static String type = Bundle.getMessage("Type"); 018 private static String model = Bundle.getMessage("Model"); 019 private static String hp = Bundle.getMessage("HP"); 020 private static String length = Bundle.getMessage("Length"); 021 private static String weight = Bundle.getMessage("Weight"); 022 private static String load = Bundle.getMessage("Load"); 023 private static String load_type = Bundle.getMessage("Load_Type"); 024 private static String color = Bundle.getMessage("Color"); 025 private static String track = Bundle.getMessage("Track"); 026 private static String destination = Bundle.getMessage("Destination"); 027 private static String dest_track = Bundle.getMessage("Dest&Track"); 028 private static String final_dest = Bundle.getMessage("Final_Dest"); 029 private static String final_dest_track = Bundle.getMessage("FD&Track"); 030 private static String location = Bundle.getMessage("Location"); 031 private static String consist = Bundle.getMessage("Consist"); 032 private static String dcc_address = Bundle.getMessage("DCC_Address"); 033 private static String kernel = Bundle.getMessage("Kernel"); 034 private static String owner = Bundle.getMessage("Owner"); 035 private static String division = Bundle.getMessage("Division"); 036 private static String rwe = Bundle.getMessage("RWELabel"); // add "RWE:" in Switch List 037 private static String comment = Bundle.getMessage("Comment"); 038 private static String drop_comment = Bundle.getMessage("SetOut_Msg"); 039 private static String pickup_comment = Bundle.getMessage("PickUp_Msg"); 040 private static String hazardous = Bundle.getMessage("Hazardous"); 041 private static String lastTrain = Bundle.getMessage("LastTrain"); 042 043 public static String getStringHeader_Road() { 044 return road; 045 } 046 047 public static void setStringHeader_Road(String s) { 048 road = s; 049 } 050 051 public static String getStringHeader_Number() { 052 return number; 053 } 054 055 public static void setStringHeader_Number(String s) { 056 number = s; 057 } 058 059 public static String getStringHeader_EngineNumber() { 060 return engine_number; 061 } 062 063 public static void setStringHeader_EngineNumber(String s) { 064 engine_number = s; 065 } 066 067 public static String getStringHeader_Type() { 068 return type; 069 } 070 071 public static void setStringHeader_Type(String s) { 072 type = s; 073 } 074 075 public static String getStringHeader_Model() { 076 return model; 077 } 078 079 public static void setStringHeader_Model(String s) { 080 model = s; 081 } 082 083 public static String getStringHeader_Hp() { 084 return hp; 085 } 086 087 public static void setStringHeader_Hp(String s) { 088 hp = s; 089 } 090 091 public static String getStringHeader_Length() { 092 return length; 093 } 094 095 public static void setStringHeader_Length(String s) { 096 length = s; 097 } 098 099 public static String getStringHeader_Weight() { 100 return weight; 101 } 102 103 public static void setStringHeader_Weight(String s) { 104 weight = s; 105 } 106 107 public static String getStringHeader_Load() { 108 return load; 109 } 110 111 public static void setStringHeader_Load(String s) { 112 load = s; 113 } 114 115 public static String getStringHeader_Load_Type() { 116 return load_type; 117 } 118 119 public static void setStringHeader_Load_Type(String s) { 120 load_type = s; 121 } 122 123 public static String getStringHeader_Color() { 124 return color; 125 } 126 127 public static void setStringHeader_Color(String s) { 128 color = s; 129 } 130 131 public static String getStringHeader_Track() { 132 return track; 133 } 134 135 public static void setStringHeader_Track(String s) { 136 track = s; 137 } 138 139 public static String getStringHeader_Destination() { 140 return destination; 141 } 142 143 public static void setStringHeader_Destination(String s) { 144 destination = s; 145 } 146 147 public static String getStringHeader_Dest_Track() { 148 return dest_track; 149 } 150 151 public static void setStringHeader_Dest_Track(String s) { 152 dest_track = s; 153 } 154 155 public static String getStringHeader_Final_Dest() { 156 return final_dest; 157 } 158 159 public static void setStringHeader_Final_Dest(String s) { 160 final_dest = s; 161 } 162 163 public static String getStringHeader_Final_Dest_Track() { 164 return final_dest_track; 165 } 166 167 public static void setStringHeader_Final_Dest_Track(String s) { 168 final_dest_track = s; 169 } 170 171 public static String getStringHeader_Location() { 172 return location; 173 } 174 175 public static void setStringHeader_Location(String s) { 176 location = s; 177 } 178 179 public static String getStringHeader_Consist() { 180 return consist; 181 } 182 183 public static void setStringHeader_Consist(String s) { 184 consist = s; 185 } 186 187 public static String getStringHeader_Kernel() { 188 return kernel; 189 } 190 191 public static void setStringHeader_Kernel(String s) { 192 kernel = s; 193 } 194 195 public static String getStringHeader_Owner() { 196 return owner; 197 } 198 199 public static void setStringHeader_Owner(String s) { 200 owner = s; 201 } 202 203 public static String getStringHeader_Division() { 204 return division; 205 } 206 207 public static void setStringHeader_Division(String s) { 208 division = s; 209 } 210 211 public static String getStringHeader_RWE() { 212 return rwe; 213 } 214 215 public static void setStringHeader_RWE(String s) { 216 rwe = s; 217 } 218 219 public static String getStringHeader_Comment() { 220 return comment; 221 } 222 223 public static void setStringHeader_Comment(String s) { 224 comment = s; 225 } 226 227 public static String getStringHeader_Drop_Comment() { 228 return drop_comment; 229 } 230 231 public static void setStringHeader_Drop_Comment(String s) { 232 drop_comment = s; 233 } 234 235 public static String getStringHeader_Pickup_Comment() { 236 return pickup_comment; 237 } 238 239 public static void setStringHeader_Pickup_Comment(String s) { 240 pickup_comment = s; 241 } 242 243 public static String getStringHeader_Hazardous() { 244 return hazardous; 245 } 246 247 public static void setStringHeader_Hazardous(String s) { 248 hazardous = s; 249 } 250 251 public static String getStringHeader_DCC_Address() { 252 return dcc_address; 253 } 254 255 public static void setStringHeader_DCC_Address(String s) { 256 dcc_address = s; 257 } 258 259 public static String getStringHeader_Last_Train() { 260 return lastTrain; 261 } 262 263 public static void setStringHeader_Last_Train(String s) { 264 lastTrain = s; 265 } 266 267 // must synchronize changes with operation-config.dtd 268 public static Element store() { 269 Element values; 270 Element e = new Element(Xml.MANIFEST_HEADER_TEXT_STRINGS); 271 // only save strings that have been modified 272 if (!getStringHeader_Road().equals(Bundle.getMessage("Road"))) { 273 e.addContent(values = new Element(Xml.ROAD)); 274 values.setAttribute(Xml.TEXT, getStringHeader_Road()); 275 } 276 if (!getStringHeader_Number().equals(Bundle.getMessage("Number"))) { 277 e.addContent(values = new Element(Xml.NUMBER)); 278 values.setAttribute(Xml.TEXT, getStringHeader_Number()); 279 } 280 if (!getStringHeader_EngineNumber().equals(Bundle.getMessage("Number"))) { 281 e.addContent(values = new Element(Xml.ENGINE_NUMBER)); 282 values.setAttribute(Xml.TEXT, getStringHeader_EngineNumber()); 283 } 284 if (!getStringHeader_Type().equals(Bundle.getMessage("Type"))) { 285 e.addContent(values = new Element(Xml.TYPE)); 286 values.setAttribute(Xml.TEXT, getStringHeader_Type()); 287 } 288 if (!getStringHeader_Model().equals(Bundle.getMessage("Model"))) { 289 e.addContent(values = new Element(Xml.MODEL)); 290 values.setAttribute(Xml.TEXT, getStringHeader_Model()); 291 } 292 if (!getStringHeader_Hp().equals(Bundle.getMessage("HP"))) { 293 e.addContent(values = new Element(Xml.HP)); 294 values.setAttribute(Xml.TEXT, getStringHeader_Hp()); 295 } 296 if (!getStringHeader_Length().equals(Bundle.getMessage("Length"))) { 297 e.addContent(values = new Element(Xml.LENGTH)); 298 values.setAttribute(Xml.TEXT, getStringHeader_Length()); 299 } 300 if (!getStringHeader_Weight().equals(Bundle.getMessage("Weight"))) { 301 e.addContent(values = new Element(Xml.WEIGHT)); 302 values.setAttribute(Xml.TEXT, getStringHeader_Weight()); 303 } 304 if (!getStringHeader_Load().equals(Bundle.getMessage("Load"))) { 305 e.addContent(values = new Element(Xml.LOAD)); 306 values.setAttribute(Xml.TEXT, getStringHeader_Load()); 307 } 308 if (!getStringHeader_Load_Type().equals(Bundle.getMessage("Load_Type"))) { 309 e.addContent(values = new Element(Xml.LOAD_TYPE)); 310 values.setAttribute(Xml.TEXT, getStringHeader_Load_Type()); 311 } 312 if (!getStringHeader_Color().equals(Bundle.getMessage("Color"))) { 313 e.addContent(values = new Element(Xml.COLOR)); 314 values.setAttribute(Xml.TEXT, getStringHeader_Color()); 315 } 316 if (!getStringHeader_Track().equals(Bundle.getMessage("Track"))) { 317 e.addContent(values = new Element(Xml.TRACK)); 318 values.setAttribute(Xml.TEXT, getStringHeader_Track()); 319 } 320 if (!getStringHeader_Destination().equals(Bundle.getMessage("Destination"))) { 321 e.addContent(values = new Element(Xml.DESTINATION)); 322 values.setAttribute(Xml.TEXT, getStringHeader_Destination()); 323 } 324 if (!getStringHeader_Dest_Track().equals(Bundle.getMessage("Dest&Track"))) { 325 e.addContent(values = new Element(Xml.DEST_TRACK)); 326 values.setAttribute(Xml.TEXT, getStringHeader_Dest_Track()); 327 } 328 if (!getStringHeader_Final_Dest().equals(Bundle.getMessage("Final_Dest"))) { 329 e.addContent(values = new Element(Xml.FINAL_DEST)); 330 values.setAttribute(Xml.TEXT, getStringHeader_Final_Dest()); 331 } 332 if (!getStringHeader_Final_Dest_Track().equals(Bundle.getMessage("FD&Track"))) { 333 e.addContent(values = new Element(Xml.FINAL_DEST_TRACK)); 334 values.setAttribute(Xml.TEXT, getStringHeader_Final_Dest_Track()); 335 } 336 if (!getStringHeader_Location().equals(Bundle.getMessage("Location"))) { 337 e.addContent(values = new Element(Xml.LOCATION)); 338 values.setAttribute(Xml.TEXT, getStringHeader_Location()); 339 } 340 if (!getStringHeader_Consist().equals(Bundle.getMessage("Consist"))) { 341 e.addContent(values = new Element(Xml.CONSIST)); 342 values.setAttribute(Xml.TEXT, getStringHeader_Consist()); 343 } 344 if (!getStringHeader_DCC_Address().equals(Bundle.getMessage("DCC_Address"))) { 345 e.addContent(values = new Element(Xml.DCC_ADDRESS)); 346 values.setAttribute(Xml.TEXT, getStringHeader_DCC_Address()); 347 } 348 if (!getStringHeader_Kernel().equals(Bundle.getMessage("Kernel"))) { 349 e.addContent(values = new Element(Xml.KERNEL)); 350 values.setAttribute(Xml.TEXT, getStringHeader_Kernel()); 351 } 352 if (!getStringHeader_Owner().equals(Bundle.getMessage("Owner"))) { 353 e.addContent(values = new Element(Xml.OWNER)); 354 values.setAttribute(Xml.TEXT, getStringHeader_Owner()); 355 } 356 if (!getStringHeader_Division().equals(Bundle.getMessage("Division"))) { 357 e.addContent(values = new Element(Xml.DIVISION)); 358 values.setAttribute(Xml.TEXT, getStringHeader_Division()); 359 } 360 if (!getStringHeader_RWE().equals(Bundle.getMessage("RWELabel"))) { 361 e.addContent(values = new Element(Xml.RWE)); 362 values.setAttribute(Xml.TEXT, getStringHeader_RWE()); 363 } 364 if (!getStringHeader_Comment().equals(Bundle.getMessage("Comment"))) { 365 e.addContent(values = new Element(Xml.COMMENT)); 366 values.setAttribute(Xml.TEXT, getStringHeader_Comment()); 367 } 368 if (!getStringHeader_Drop_Comment().equals(Bundle.getMessage("SetOut_Msg"))) { 369 e.addContent(values = new Element(Xml.DROP_COMMENT)); 370 values.setAttribute(Xml.TEXT, getStringHeader_Drop_Comment()); 371 } 372 if (!getStringHeader_Pickup_Comment().equals(Bundle.getMessage("PickUp_Msg"))) { 373 e.addContent(values = new Element(Xml.PICKUP_COMMENT)); 374 values.setAttribute(Xml.TEXT, getStringHeader_Pickup_Comment()); 375 } 376 if (!getStringHeader_Hazardous().equals(Bundle.getMessage("Hazardous"))) { 377 e.addContent(values = new Element(Xml.HAZARDOUS)); 378 values.setAttribute(Xml.TEXT, getStringHeader_Hazardous()); 379 } 380 if (!getStringHeader_Last_Train().equals(Bundle.getMessage("LastTrain"))) { 381 e.addContent(values = new Element(Xml.LAST_TRAIN)); 382 values.setAttribute(Xml.TEXT, getStringHeader_Last_Train()); 383 } 384 385 return e; 386 } 387 388 public static void load(Element e) { 389 Element emts = e.getChild(Xml.MANIFEST_HEADER_TEXT_STRINGS); 390 if (emts == null) { 391 return; 392 } 393 Attribute a; 394 if (emts.getChild(Xml.ROAD) != null) { 395 if ((a = emts.getChild(Xml.ROAD).getAttribute(Xml.TEXT)) != null) { 396 setStringHeader_Road(a.getValue()); 397 } 398 } 399 if (emts.getChild(Xml.NUMBER) != null) { 400 if ((a = emts.getChild(Xml.NUMBER).getAttribute(Xml.TEXT)) != null) { 401 setStringHeader_Number(a.getValue()); 402 } 403 } 404 if (emts.getChild(Xml.ENGINE_NUMBER) != null) { 405 if ((a = emts.getChild(Xml.ENGINE_NUMBER).getAttribute(Xml.TEXT)) != null) { 406 setStringHeader_EngineNumber(a.getValue()); 407 } 408 } 409 if (emts.getChild(Xml.TYPE) != null) { 410 if ((a = emts.getChild(Xml.TYPE).getAttribute(Xml.TEXT)) != null) { 411 setStringHeader_Type(a.getValue()); 412 } 413 } 414 if (emts.getChild(Xml.MODEL) != null) { 415 if ((a = emts.getChild(Xml.MODEL).getAttribute(Xml.TEXT)) != null) { 416 setStringHeader_Model(a.getValue()); 417 } 418 } 419 if (emts.getChild(Xml.HP) != null) { 420 if ((a = emts.getChild(Xml.HP).getAttribute(Xml.TEXT)) != null) { 421 setStringHeader_Hp(a.getValue()); 422 } 423 } 424 if (emts.getChild(Xml.LENGTH) != null) { 425 if ((a = emts.getChild(Xml.LENGTH).getAttribute(Xml.TEXT)) != null) { 426 setStringHeader_Length(a.getValue()); 427 } 428 } 429 if (emts.getChild(Xml.WEIGHT) != null) { 430 if ((a = emts.getChild(Xml.WEIGHT).getAttribute(Xml.TEXT)) != null) { 431 setStringHeader_Weight(a.getValue()); 432 } 433 } 434 if (emts.getChild(Xml.LOAD) != null) { 435 if ((a = emts.getChild(Xml.LOAD).getAttribute(Xml.TEXT)) != null) { 436 setStringHeader_Load(a.getValue()); 437 } 438 } 439 if (emts.getChild(Xml.LOAD_TYPE) != null) { 440 if ((a = emts.getChild(Xml.LOAD_TYPE).getAttribute(Xml.TEXT)) != null) { 441 setStringHeader_Load_Type(a.getValue()); 442 } 443 } 444 if (emts.getChild(Xml.COLOR) != null) { 445 if ((a = emts.getChild(Xml.COLOR).getAttribute(Xml.TEXT)) != null) { 446 setStringHeader_Color(a.getValue()); 447 } 448 } 449 if (emts.getChild(Xml.TRACK) != null) { 450 if ((a = emts.getChild(Xml.TRACK).getAttribute(Xml.TEXT)) != null) { 451 setStringHeader_Track(a.getValue()); 452 } 453 } 454 if (emts.getChild(Xml.DESTINATION) != null) { 455 if ((a = emts.getChild(Xml.DESTINATION).getAttribute(Xml.TEXT)) != null) { 456 setStringHeader_Destination(a.getValue()); 457 } 458 } 459 if (emts.getChild(Xml.DEST_TRACK) != null) { 460 if ((a = emts.getChild(Xml.DEST_TRACK).getAttribute(Xml.TEXT)) != null) { 461 setStringHeader_Dest_Track(a.getValue()); 462 } 463 } 464 if (emts.getChild(Xml.FINAL_DEST) != null) { 465 if ((a = emts.getChild(Xml.FINAL_DEST).getAttribute(Xml.TEXT)) != null) { 466 setStringHeader_Final_Dest(a.getValue()); 467 } 468 } 469 if (emts.getChild(Xml.FINAL_DEST_TRACK) != null) { 470 if ((a = emts.getChild(Xml.FINAL_DEST_TRACK).getAttribute(Xml.TEXT)) != null) { 471 setStringHeader_Final_Dest_Track(a.getValue()); 472 } 473 } 474 if (emts.getChild(Xml.LOCATION) != null) { 475 if ((a = emts.getChild(Xml.LOCATION).getAttribute(Xml.TEXT)) != null) { 476 setStringHeader_Location(a.getValue()); 477 } 478 } 479 if (emts.getChild(Xml.CONSIST) != null) { 480 if ((a = emts.getChild(Xml.CONSIST).getAttribute(Xml.TEXT)) != null) { 481 setStringHeader_Consist(a.getValue()); 482 } 483 } 484 if (emts.getChild(Xml.DCC_ADDRESS) != null) { 485 if ((a = emts.getChild(Xml.DCC_ADDRESS).getAttribute(Xml.TEXT)) != null) { 486 setStringHeader_DCC_Address(a.getValue()); 487 } 488 } 489 if (emts.getChild(Xml.KERNEL) != null) { 490 if ((a = emts.getChild(Xml.KERNEL).getAttribute(Xml.TEXT)) != null) { 491 setStringHeader_Kernel(a.getValue()); 492 } 493 } 494 if (emts.getChild(Xml.OWNER) != null) { 495 if ((a = emts.getChild(Xml.OWNER).getAttribute(Xml.TEXT)) != null) { 496 setStringHeader_Owner(a.getValue()); 497 } 498 } 499 if (emts.getChild(Xml.DIVISION) != null) { 500 if ((a = emts.getChild(Xml.DIVISION).getAttribute(Xml.TEXT)) != null) { 501 setStringHeader_Division(a.getValue()); 502 } 503 } 504 if (emts.getChild(Xml.RWE) != null) { 505 if ((a = emts.getChild(Xml.RWE).getAttribute(Xml.TEXT)) != null) { 506 setStringHeader_RWE(a.getValue()); 507 } 508 } 509 if (emts.getChild(Xml.COMMENT) != null) { 510 if ((a = emts.getChild(Xml.COMMENT).getAttribute(Xml.TEXT)) != null) { 511 setStringHeader_Comment(a.getValue()); 512 } 513 } 514 if (emts.getChild(Xml.DROP_COMMENT) != null) { 515 if ((a = emts.getChild(Xml.DROP_COMMENT).getAttribute(Xml.TEXT)) != null) { 516 setStringHeader_Drop_Comment(a.getValue()); 517 } 518 } 519 if (emts.getChild(Xml.PICKUP_COMMENT) != null) { 520 if ((a = emts.getChild(Xml.PICKUP_COMMENT).getAttribute(Xml.TEXT)) != null) { 521 setStringHeader_Pickup_Comment(a.getValue()); 522 } 523 } 524 if (emts.getChild(Xml.HAZARDOUS) != null) { 525 if ((a = emts.getChild(Xml.HAZARDOUS).getAttribute(Xml.TEXT)) != null) { 526 setStringHeader_Hazardous(a.getValue()); 527 } 528 } 529 if (emts.getChild(Xml.LAST_TRAIN) != null) { 530 if ((a = emts.getChild(Xml.LAST_TRAIN).getAttribute(Xml.TEXT)) != null) { 531 setStringHeader_Last_Train(a.getValue()); 532 } 533 } 534 } 535}