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