package com.inspect.patrol.linkage.block;

import com.inspect.base.core.utils.DateUtils;
import com.inspect.base.core.utils.StringUtils;

public class CimeXmlFormat {
   private String header;
   private String classBegin;
   private String classEnd;
   private String headerName;
   private String headerVersion = "V1.0";
   private String headerTime = DateUtils.getTime();
   private String className = "DeviceInfo";
   private String description;
   private String endDescription;

   public CimeXmlFormat(String headerName, String description) {
      this.headerName = headerName;
      this.description = description;
   }

   public CimeXmlFormat(String headerName, String description, String endDescription) {
      this.headerName = headerName;
      this.description = description;
      this.endDescription = endDescription;
   }

   public String getHeaderName() {
      return this.headerName;
   }

   public void setHeaderName(String headerName) {
      this.headerName = headerName;
   }

   public String getHeaderVersion() {
      return this.headerVersion;
   }

   public void setHeaderVersion(String headerVersion) {
      this.headerVersion = headerVersion;
   }

   public String getHeaderTime() {
      return this.headerTime;
   }

   public void setHeaderTime(String headerTime) {
      this.headerTime = headerTime;
   }

   public String getClassName() {
      return this.className;
   }

   public void setClassName(String className) {
      this.className = className;
   }

   public String getDescription() {
      return this.description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public String getHeader() {
      return String.format("<!Entity=%s\tver='%s'\ttime='%s'(文件最新时间)!>\n", new Object[]{this.headerName, this.headerVersion, this.headerTime});
   }

   public void setHeader(String header) {
      this.header = header;
   }

   public String getClassBegin() {
      return String.format("<%s::%s>\n", new Object[]{this.className, this.description});
   }

   public void setClassBegin(String classBegin) {
      this.classBegin = classBegin;
   }

   public String getClassEnd() {
      if(StringUtils.isEmpty(this.endDescription)) {
         this.endDescription = this.description;
      }

      return String.format("</%s::%s>\n", new Object[]{this.className, this.endDescription});
   }

   public void setClassEnd(String classEnd) {
      this.classEnd = classEnd;
   }
}
