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