Changeset 46 in tmcsimulator-scriptbuilder for trunk/src/scriptbuilder/structures/Location_Info.java


Ignore:
Timestamp:
08/07/2017 04:20:08 PM (9 years ago)
Author:
bmcguffin
Message:

Added file: XMLWriter, in package Scriptbuilder.structures. It holds static methods which ither classes that implement I_XML_Writable may find useful. Also restructured the toXML method of many classes to utilize this new class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/scriptbuilder/structures/Location_Info.java

    r44 r46  
    2121    public String toXML() 
    2222    { 
    23         String output = openTag(ELEMENT.LOCATION_INFO.tag + " ID=\"" + Location_ID + "\""); 
     23        String output = XMLWriter.openTag(ELEMENT.LOCATION_INFO.tag + " ID=\"" + Location_ID + "\""); 
    2424 
    25         output += openTag(ELEMENT.Route.tag); 
    26         output += Route; 
    27         output += closeTag(ELEMENT.Route.tag); 
     25        output += XMLWriter.simpleTag(Route, ELEMENT.Route); 
    2826 
    29         output += openTag(ELEMENT.Direction.tag); 
    30         output += Direction; 
    31         output += closeTag(ELEMENT.Direction.tag); 
     27        output += XMLWriter.simpleTag(Direction, ELEMENT.Direction); 
    3228 
    33         output += openTag(ELEMENT.Postmile.tag); 
    34         output += Postmile; 
    35         output += closeTag(ELEMENT.Postmile.tag); 
     29        output += XMLWriter.simpleTag(Postmile, ELEMENT.Postmile); 
    3630 
    37         output += openTag(ELEMENT.Location_type.tag); 
    38         output += Location_type; 
    39         output += closeTag(ELEMENT.Location_type.tag); 
     31        output += XMLWriter.simpleTag(Location_type, ELEMENT.Location_type); 
    4032 
    41         output += closeTag(ELEMENT.LOCATION_INFO.tag); 
     33        output += XMLWriter.closeTag(ELEMENT.LOCATION_INFO.tag); 
    4234 
    4335        return output; 
    4436    } 
    45  
    46     @Override 
    47     public String openTag(String s) 
    48     { 
    49         return "<" + s + ">"; 
    50     } 
    51  
    52     @Override 
    53     public String closeTag(String s) 
    54     { 
    55         return "</" + s + ">\n"; 
    56     } 
    57  
    58     @Override 
    59     public String emptyTag(String s) 
    60     { 
    61         return "<" + s + "/>\n"; 
    62     } 
    6337} 
Note: See TracChangeset for help on using the changeset viewer.