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