package scriptbuilder.structures; import java.util.ArrayList; /** * Aggregation of several information fields relevant to each timeslice. * * @author Bryan McGuffin */ public class CadData implements I_XML_Writable { public CadData() { locInfo = new ArrayList(); } /** * Constructor to add type and location, where TruncLoc is the first 5 letters of the fullloc. * @param Header_Type * @param Header_FullLoc */ public CadData(String Header_Type, String Header_FullLoc) { this.Header_Type = Header_Type; this.Header_FullLoc = Header_FullLoc; // if(Header_FullLoc.length()>10) // { // this.Header_TruncLoc = Header_FullLoc.substring(0,9); // } this.Header_TruncLoc = Header_FullLoc; locInfo = new ArrayList(); } public TimeSlice tSlice; public String Header_Type = ""; public String Header_Beat = ""; public String Header_TruncLoc = ""; public String Header_FullLoc = ""; public String Master_Inc_Num = ""; public String P = ""; public String Info_Type = ""; public String Info_Type_Code = ""; public String Agy = ""; public String General_Title = ""; public String General_Text = ""; public String Location_Beat = ""; public String Location_Address = ""; public String Location_Loc = ""; public String Location_City = ""; public String Location_Area = ""; public String Location_Fire = ""; public String Location_Law = ""; public String Location_Ems = ""; public ArrayList locInfo; @Override public String toXML() { String output = ""; if (!Master_Inc_Num.equals("")) { output += XMLBuilder.simpleTag(Master_Inc_Num, ELEMENT.MASTER_INC_NUM); } if (!P.equals("")) { output += XMLBuilder.simpleTag(P, ELEMENT.P); } if (hasAdditionalInfo()) { output += XMLBuilder.openTag(ELEMENT.ADDITIONAL_INFO.tag); output += XMLBuilder.simpleTag(Info_Type_Code, ELEMENT.TYPE_CODE); output += XMLBuilder.simpleTag(Info_Type, ELEMENT.TYPE); output += XMLBuilder.closeTag(ELEMENT.ADDITIONAL_INFO.tag); } if (hasLocation()) { output += XMLBuilder.openTag(ELEMENT.LOCATION.tag); if (!Location_Beat.equals("")) { output += XMLBuilder.simpleTag(Location_Beat, ELEMENT.BEAT); } if (!Location_Address.equals("")) { output += XMLBuilder.simpleTag(Location_Address, ELEMENT.ADDRESS); } if (!Location_Loc.equals("")) { output += XMLBuilder.simpleTag(Location_Loc, ELEMENT.LOC); } if (!Location_City.equals("")) { output += XMLBuilder.simpleTag(Location_City, ELEMENT.CITY); } if (!Location_Area.equals("")) { output += XMLBuilder.simpleTag(Location_Area, ELEMENT.AREA); } if (!Location_Fire.equals("")) { output += XMLBuilder.simpleTag(Location_Fire, ELEMENT.FIRE); } if (!Location_Law.equals("")) { output += XMLBuilder.simpleTag(Location_Law, ELEMENT.LAW); } if (!Location_Ems.equals("")) { output += XMLBuilder.simpleTag(Location_Ems, ELEMENT.EMS); } output += XMLBuilder.closeTag(ELEMENT.LOCATION.tag); } if (!Agy.equals("")) { output += XMLBuilder.openTag(ELEMENT.GENERAL.tag); output += XMLBuilder.simpleTag(Agy, ELEMENT.AGY); output += XMLBuilder.closeTag(ELEMENT.GENERAL.tag); } if (hasHeaderInfo()) //checking to see if header info is always necessary { //todo: make this logic trigger only once per incident output += XMLBuilder.openTag(ELEMENT.HEADER_INFO.tag); output += XMLBuilder.simpleTag(Header_Type, ELEMENT.Type); output += XMLBuilder.simpleTag(Header_Beat, ELEMENT.Beat); output += XMLBuilder.simpleTag(Header_TruncLoc, ELEMENT.TruncLoc); output += XMLBuilder.simpleTag(Header_FullLoc, ELEMENT.FullLoc); output += XMLBuilder.closeTag(ELEMENT.HEADER_INFO.tag); } if (locInfo.size() > 0) { for (Location_Info li : locInfo) { output += li.toXML(); } } return output; } public boolean hasHeaderInfo() { return !Header_Type.equals("") || !Header_Beat.equals("") || !Header_FullLoc.equals("") || !Header_TruncLoc.equals(""); } public boolean hasLocation() { return !Location_Address.equals("") || !Location_Area.equals("") || !Location_Beat.equals("") || !Location_City.equals("") || !Location_Ems.equals("") || !Location_Fire.equals("") || !Location_Law.equals("") || !Location_Loc.equals(""); } public boolean hasGeneralInfo() { return !General_Text.equals("") || !General_Title.equals(""); } public boolean hasAdditionalInfo() { return !Info_Type.equals("") || !Info_Type_Code.equals(""); } public boolean hasCadData() { return hasHeaderInfo() || hasLocation() || hasAdditionalInfo() || !Master_Inc_Num.equals("") || !P.equals("") || !Agy.equals("") || locInfo.size() > 0; } }