package com.chenyang.nse.bussiness.engine.infa.powercenter961.createdata;

import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MaskPrepertyBean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MaskPrepertyReplaceStringbean;
import com.chenyang.nse.bussiness.engine.infa.powercenter961.pubbean.MaskPrepertyStringBean;
import java.util.ArrayList;
import java.util.List;

public class MaskPropertyUtil {
   public String integerRandomNoMasking() {
      StringBuffer sb = new StringBuffer();
      sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
      sb.append("&lt;PORT_INFORMATION&gt;");
      sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
      sb.append("&lt;PORTINFO&gt;");
      sb.append("&lt;PORT DATA_TYPE=&quot;integer&quot; MASKING_OPTION=&quot;Random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;10&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot; &gt;");
      sb.append("&lt;/PORT&gt;");
      sb.append("&lt;/PORTINFO&gt;");
      sb.append("&lt;/PORT_INFORMATION&gt;");
      return sb.toString();
   }

   public String getIntegerRandomString(MaskPrepertyBean mb) {
      if (mb.isBlur()) {
         if (mb.isFix()) {
            StringBuffer sb = new StringBuffer();
            String max = "&quot;" + mb.getMaxnum() + "&quot;";
            String min = "&quot;" + mb.getMinnum() + "&quot;";
            String h_range = "&quot;" + mb.getHigh_range() + "&quot;";
            String l_range = "&quot;" + mb.getLow_range() + "&quot;";
            sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
            sb.append("&lt;PORT_INFORMATION&gt;");
            sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
            sb.append("&lt;PORTINFO&gt;");
            sb.append("&lt;PORT DATA_TYPE=&quot;integer&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;10&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
            sb.append("&lt;NUMERIC BLUR=&quot;Fixed&quot; BLURRING=&quot;TRUE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;" + h_range + "&quot; LOW_RANGE=&quot;" + l_range + "&quot; MAXIMUM=&quot;" + max + "&quot;MINIMUM=&quot;" + min + "&quot;/&gt;");
            sb.append("&lt;/PORT&gt;");
            sb.append("&lt;/PORTINFO&gt;");
            sb.append("&lt;/PORT_INFORMATION&gt;");
            return sb.toString();
         } else {
            StringBuffer sb = new StringBuffer();
            String max = "&quot;" + mb.getMaxnum() + "&quot;";
            String min = "&quot;" + mb.getMinnum() + "&quot;";
            String h_range = "&quot;" + mb.getHigh_range() + "&quot;";
            String l_range = "&quot;" + mb.getLow_range() + "&quot;";
            sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
            sb.append("&lt;PORT_INFORMATION&gt;");
            sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
            sb.append("&lt;PORTINFO&gt;");
            sb.append("&lt;PORT DATA_TYPE=&quot;integer&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;10&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
            sb.append("&lt;NUMERIC BLUR=&quot;Percent&quot; BLURRING=&quot;TRUE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;" + h_range + "&quot; LOW_RANGE=&quot;" + l_range + "&quot; MAXIMUM=&quot;" + max + "&quot;MINIMUM=&quot;" + min + "&quot;/&gt;");
            sb.append("&lt;/PORT&gt;");
            sb.append("&lt;/PORTINFO&gt;");
            sb.append("&lt;/PORT_INFORMATION&gt;");
            return sb.toString();
         }
      } else {
         String max = "&quot;" + mb.getMaxnum() + "&quot;";
         String min = "&quot;" + mb.getMinnum() + "&quot;";
         StringBuffer sb = new StringBuffer();
         sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
         sb.append("&lt;PORT_INFORMATION&gt;");
         sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
         sb.append("&lt;PORTINFO&gt;");
         sb.append("&lt;PORT DATA_TYPE=&quot;integer&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;10&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
         sb.append("&lt;NUMERIC BLUR=&quot;Fixed&quot; BLURRING=&quot;FALSE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;&quot; LOW_RANGE=&quot;&quot; MAXIMUM=" + max + " MINIMUM=" + min + "/&gt;");
         sb.append("&lt;/PORT&gt;");
         sb.append("&lt;/PORTINFO&gt;");
         sb.append("&lt;/PORT_INFORMATION&gt;");
         return sb.toString();
      }
   }

   public String getIntegerExpString() {
      StringBuffer sb = new StringBuffer();
      sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
      sb.append("&lt;PORT_INFORMATION&gt;");
      sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
      sb.append("&lt;PORTINFO&gt;");
      sb.append("&lt;PORT DATA_TYPE=&quot;integer&quot; MASKING_OPTION=&quot;Expression&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;10&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot; &gt;");
      sb.append("&lt;/PORT&gt;");
      sb.append("&lt;/PORTINFO&gt;");
      sb.append("&lt;/PORT_INFORMATION&gt;");
      return sb.toString();
   }

   public String getStringRandomString(MaskPrepertyStringBean msb) {
      String RANDOM_STRING = "";
      String MAXIMUM_WIDTH = "";
      String MINIMUM_WIDTH = "";
      String PRECISION = "&quot;" + msb.getPrecision() + "&quot;";
      String filter_source_option = "&quot;" + msb.getFilter_source_option() + "&quot;";
      String filter_target_option = "&quot;" + msb.getFilter_target_option() + "&quot;";
      String source_characters = "&quot;" + msb.getSource_characters() + "&quot;";
      String target_characters = "&quot;" + msb.getTarget_characters() + "&quot;";
      String MASK_FORMAT = "";
      String filter_source_characters = "&quot;" + msb.getFilter_source_characters() + "&quot;";
      String filter_target_characters = "&quot;" + msb.getFilter_target_characters() + "&quot;";
      if (!"".equals(msb.getMask_format()) && msb.getMask_format() != null) {
         RANDOM_STRING = "&quot;FALSE&quot;";
         MAXIMUM_WIDTH = "&quot;10&quot;";
         MINIMUM_WIDTH = "&quot;1&quot;";
         MASK_FORMAT = "&quot;" + msb.getTarget_characters() + "&quot;";
      } else {
         RANDOM_STRING = "&quot;TRUE&quot;";
         MAXIMUM_WIDTH = "&quot;" + msb.getMaximum_width() + "&quot;";
         MINIMUM_WIDTH = "&quot;" + msb.getMinimum_width() + "&quot;";
         MASK_FORMAT = "&quot;R&quot;";
      }

      StringBuffer sb = new StringBuffer();
      sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
      sb.append("&lt;PORT_INFORMATION&gt;");
      sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
      sb.append("&lt;PORTINFO&gt;");
      sb.append("&lt;PORT DATA_TYPE=&quot;string&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=" + PRECISION + " SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;2&quot; &gt;");
      sb.append("&lt;STRING  FILTER_SOURCE_CHARACTERS=" + filter_source_characters + " FILTER_SOURCE_OPTION=" + filter_source_option + " FILTER_TARGET_CHARACTERS=" + filter_target_characters + " FILTER_TARGET_OPTION=" + filter_target_option + " MASK_FORMAT=" + MASK_FORMAT + " MAXIMUM_WIDTH=" + MAXIMUM_WIDTH + " MINIMUM_WIDTH=" + MINIMUM_WIDTH + " RANDOM_STRING=" + RANDOM_STRING + " SOURCE_CHARACTERS=" + source_characters + " TARGET_CHARACTERS=" + target_characters + "  /&gt;");
      sb.append("&lt;/PORT&gt;");
      sb.append("&lt;/PORTINFO&gt;");
      sb.append("&lt;/PORT_INFORMATION&gt;");
      return sb.toString();
   }

   public String getStringReplaceString(MaskPrepertyReplaceStringbean mspb) {
      String PRECISION = "&quot;" + mspb.getPrecision() + "&quot;";
      String COLUMNNAME = "&quot;" + mspb.getColumnname() + "&quot;";
      String DATASOURCE = "&quot;" + mspb.getDatasource() + "&quot;";
      String TABLENAME = "&quot;" + mspb.getTablename() + "&quot;";
      StringBuffer sb = new StringBuffer();
      sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
      sb.append("&lt;PORT_INFORMATION&gt;");
      sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
      sb.append("&lt;PORTINFO&gt;");
      sb.append("&lt;PORT DATA_TYPE=&quot;string&quot; MASKING_OPTION=&quot;replace&quot; NAME=&quot;IN_PARAM&quot; PRECISION=" + PRECISION + " SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;14&quot;  SEED=&quot;&quot; &gt;");
      sb.append("&lt;SUBSTITUTION  COLUMNNAME=" + COLUMNNAME + " CONDITIONCOLUMN=&quot;&quot; DATASOURCE=" + DATASOURCE + " DICTCOLUMN=" + COLUMNNAME + " FILEENCODING=&quot;0&quot; FILELOCALE=&quot;&quot; INPUTPORT=&quot;IN_PARAM&quot; IS_DICTIONARY_RELATIONAL=&quot;TRUE&quot; IS_KEY_MASKED=&quot;FALSE&quot; IS_OUTPUT_UNIQUE=&quot;FALSE&quot; IS_PARAMETRIZED=&quot;FALSE&quot; IS_SHUFFLE=&quot;FALSE&quot; UNIQUE_COLUMN=&quot;IN_PARAM &quot; TABLENAME=" + TABLENAME + "/&gt;");

      for(int i = 0; i < mspb.getColumnname().size(); ++i) {
         sb.append("&lt;TABLECOLUMN NAME=&quot;" + (String)mspb.getColumnname().get(i) + "&quot;/&gt;");
      }

      List<String> list = new ArrayList();

      for(int i = 0; i < mspb.getColumnname().size(); ++i) {
         if (!((String)mspb.getColumnname().get(i)).equals(mspb.getRepalcecolumnname())) {
            list.add(mspb.getColumnname().get(i));
         }
      }

      for(int i = 0; i < list.size(); ++i) {
         sb.append("&lt;TABLECOLUMNSTR NAMESTR=&quot;" + (String)list.get(i) + "&quot;/&gt;");
      }

      sb.append("&lt;/SUBSTITUTION;");
      sb.append("&lt;/PORT&gt;");
      sb.append("&lt;/PORTINFO&gt;");
      sb.append("&lt;/PORT_INFORMATION&gt;");
      return sb.toString();
   }

   public String getDateRandomString(MaskPrepertyBean mb) {
      String max = "&quot;" + mb.getMaxnum() + "&quot;";
      String min = "&quot;" + mb.getMinnum() + "&quot;";
      StringBuffer sb = new StringBuffer();
      sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
      sb.append("&lt;PORT_INFORMATION&gt;");
      sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
      sb.append("&lt;PORTINFO&gt;");
      sb.append("&lt;PORT DATA_TYPE=&quot;date/time&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;29&quot; SCALE=&quot;9&quot; SPECIAL=&quot;&quot; TYPE=&quot;4&quot;&gt;");
      sb.append("&lt;DATE MAX=" + max + " MIN=" + min + " UNIT=&quot;year&quot; VALUE_SUBSTITUTION=&quot;Random&quot;/&gt;");
      sb.append("&lt;/PORT&gt;");
      sb.append("&lt;/PORTINFO&gt;");
      sb.append("&lt;/PORT_INFORMATION&gt;");
      return sb.toString();
   }

   public String getDoubleRandomString(MaskPrepertyBean mb) {
      if (mb.isBlur()) {
         if (mb.isFix()) {
            StringBuffer sb = new StringBuffer();
            String max = "&quot;" + mb.getMaxnum() + "&quot;";
            String min = "&quot;" + mb.getMinnum() + "&quot;";
            String h_range = "&quot;" + mb.getHigh_range() + "&quot;";
            String l_range = "&quot;" + mb.getLow_range() + "&quot;";
            sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
            sb.append("&lt;PORT_INFORMATION&gt;");
            sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
            sb.append("&lt;PORTINFO&gt;");
            sb.append("&lt;PORT DATA_TYPE=&quot;double&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;15&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
            sb.append("&lt;NUMERIC BLUR=&quot;Fixed&quot; BLURRING=&quot;TRUE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;" + h_range + "&quot; LOW_RANGE=&quot;" + l_range + "&quot; MAXIMUM=&quot;" + max + "&quot;MINIMUM=&quot;" + min + "&quot;/&gt;");
            sb.append("&lt;/PORT&gt;");
            sb.append("&lt;/PORTINFO&gt;");
            sb.append("&lt;/PORT_INFORMATION&gt;");
            return sb.toString();
         } else {
            StringBuffer sb = new StringBuffer();
            String max = "&quot;" + mb.getMaxnum() + "&quot;";
            String min = "&quot;" + mb.getMinnum() + "&quot;";
            String h_range = "&quot;" + mb.getHigh_range() + "&quot;";
            String l_range = "&quot;" + mb.getLow_range() + "&quot;";
            sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
            sb.append("&lt;PORT_INFORMATION&gt;");
            sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
            sb.append("&lt;PORTINFO&gt;");
            sb.append("&lt;PORT DATA_TYPE=&quot;double&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;15&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
            sb.append("&lt;NUMERIC BLUR=&quot;Fixed&quot; BLURRING=&quot;TRUE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;" + h_range + "&quot; LOW_RANGE=&quot;" + l_range + "&quot; MAXIMUM=&quot;" + max + "&quot;MINIMUM=&quot;" + min + "&quot;/&gt;");
            sb.append("&lt;/PORT&gt;");
            sb.append("&lt;/PORTINFO&gt;");
            sb.append("&lt;/PORT_INFORMATION&gt;");
            return sb.toString();
         }
      } else {
         String max = "&quot;" + mb.getMaxnum() + "&quot;";
         String min = "&quot;" + mb.getMinnum() + "&quot;";
         StringBuffer sb = new StringBuffer();
         sb.append("&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-16&quot; standalone=&quot;no&quot; ?&gt;");
         sb.append("&lt;PORT_INFORMATION&gt;");
         sb.append("&lt;CODEPAGE ID=&quot;en_US&quot; NAME=&quot;English&quot;/&gt;");
         sb.append("&lt;PORTINFO&gt;");
         sb.append("&lt;PORT DATA_TYPE=&quot;double&quot; MASKING_OPTION=&quot;random&quot; NAME=&quot;IN_PARAM&quot; PRECISION=&quot;15&quot; SCALE=&quot;0&quot; SPECIAL=&quot;&quot; TYPE=&quot;1&quot;&gt;");
         sb.append("&lt;NUMERIC BLUR=&quot;Fixed&quot; BLURRING=&quot;FALSE&quot; BOUNDS=&quot;TRUE&quot; HIGH_RANGE=&quot;&quot; LOW_RANGE=&quot;&quot; MAXIMUM=" + max + " MINIMUM=" + min + "/&gt;");
         sb.append("&lt;/PORT&gt;");
         sb.append("&lt;/PORTINFO&gt;");
         sb.append("&lt;/PORT_INFORMATION&gt;");
         return sb.toString();
      }
   }
}
