1 packagecom.booway.d3tilor.sdk.framework.config;2
3 importcom.booway.d3tilor.sdk.framework.exception.D3tilorException;4
5 /**
6 * sdk配置类7 *@authorlanjun8 *9 */
10 public classD3tilorConfig11 {12
13 privateD3tilorConfig(D3tilorConfigBuilder builder)14 {15 if (null == builder.dbDriverClass || builder.dbDriverClass.trim().equals(""))16 {17 throw new D3tilorException("请通过D3tilorConfigBuilder.jdbc方法设置数据库驱动类!");18 }19 if (null == builder.dbUrl || builder.dbUrl.trim().equals(""))20 {21 throw new D3tilorException("请通过D3tilorConfigBuilder.jdbc方法设置数据库连接url!");22 }23 if (null == builder.dbUser || builder.dbUser.trim().equals(""))24 {25 throw new D3tilorException("请通过D3tilorConfigBuilder.jdbc方法设置数据库账号!");26 }27 if (null == builder.dbPwd || builder.dbPwd.trim().equals(""))28 {29 throw new D3tilorException("请通过D3tilorConfigBuilder.jdbc方法设置数据库密码!");30 }31 if (null == builder.sevenZExePath || builder.sevenZExePath.trim().equals(""))32 {33 throw new D3tilorException("请通过D3tilorConfigBuilder.sevenZExePath方法设置7z命令全路径!(windows环境一般以7z.exe结尾,linux环境一般以7za结尾)");34 }35 if (null == builder.d3ExePath || builder.d3ExePath.trim().equals(""))36 {37 throw new D3tilorException("请通过D3tilorConfigBuilder.d3ExePath方法设置D3全路径!");38 }39 if (null == builder.tilesPath || builder.tilesPath.trim().equals(""))40 {41 throw new D3tilorException("请通过D3tilorConfigBuilder.tilesPath方法设置Tiles工具全路径!");42 }43 if (null == builder.dataPath || builder.dataPath.trim().equals(""))44 {45 throw new D3tilorException("请通过D3tilorConfigBuilder.dataPath方法设置数据区路径!");46 }47 if (null == builder.tempFilePath || builder.tempFilePath.trim().equals(""))48 {49 throw new D3tilorException("请通过D3tilorConfigBuilder.tempFilePath方法设置临时文件路径!");50 }51 if (null == builder.oriObjxPath || builder.oriObjxPath.trim().equals(""))52 {53 throw new D3tilorException("请通过D3tilorConfigBuilder.oriObjxPath方法设置原点objx文件路径!");54 }55 this.dbDriverClass =builder.dbDriverClass;56 this.dbUrl =builder.dbUrl;57 this.dbUser =builder.dbUser;58 this.dbPwd =builder.dbPwd;59 this.sevenZExePath =builder.sevenZExePath;60 this.d3ExePath =builder.d3ExePath;61 this.tilesPath =builder.tilesPath;62 this.dataPath =builder.dataPath;63 this.tempFilePath =builder.tempFilePath;64 this.timeout = builder.timeout == 0 ? 30: builder.timeout;65 this.oriObjxPath =builder.oriObjxPath;66 }67
68 private finalString dbDriverClass;69
70 private finalString dbUrl;71
72 private finalString dbUser;73
74 private finalString dbPwd;75
76 private finalString sevenZExePath;77
78 private finalString d3ExePath;79
80 private finalString tilesPath;81
82 private finalString dataPath;83
84 private finalString oriObjxPath;85
86 private finalString tempFilePath;87
88 private final inttimeout;89
90 /**
91 * 获取数据库驱动类92 *@return
93 */
94 publicString getDbDriverClass()95 {96 returndbDriverClass;97 }98
99 /**
100 * 获取数据库连接url101 *@return
102 */
103 publicString getDbUrl()104 {105 returndbUrl;106 }107
108 /**
109 * 获取数据库账号110 *@return
111 */
112 publicString getDbUser()113 {114 returndbUser;115 }116
117 /**
118 * 获取数据库密码119 *@return
120 */
121 publicString getDbPwd()122 {123 returndbPwd;124 }125
126 /**
127 * 获取7z执行路径128 *@return
129 */
130 publicString getSevenZExePath()131 {132 returnsevenZExePath;133 }134
135 /**
136 * 获取临时文件路径137 *@return
138 */
139 publicString getTempFilePath()140 {141 returntempFilePath;142 }143
144 /**
145 * 获取数据区路径146 *@return
147 */
148 publicString getDataPath()149 {150 returndataPath;151 }152
153 /**
154 * 解析超时时间155 *@return
156 */
157 public intgetTimeout()158 {159 returntimeout;160 }161
162 /**
163 * D3EXE路径164 *@return
165 */
166 publicString getD3ExePath()167 {168 returnd3ExePath;169 }170
171 /**
172 * tiles工具路径173 *@return
174 */
175 publicString getTilesPath()176 {177 returntilesPath;178 }179
180 /**
181 * 原点objx文件路径182 *@return
183 */
184 publicString getOriObjxPath()185 {186 returnoriObjxPath;187 }188
189 /**
190 * 配置类构造器191 *@authoryhh192 *193 */
194 public static classD3tilorConfigBuilder195 {196 privateString dbDriverClass;197
198 privateString dbUrl;199
200 privateString dbUser;201
202 privateString dbPwd;203
204 privateString sevenZExePath;205
206 privateString d3ExePath;207
208 privateString tilesPath;209
210 privateString tempFilePath;211
212 privateString dataPath;213
214 privateString oriObjxPath;215
216 private inttimeout;217
218 /**
219 * 数据源参数220 *@paramdbDriverClass221 *@paramdbUrl222 *@paramdbUser223 *@paramdbPwd224 *@return
225 */
226 publicD3tilorConfigBuilder jdbc(String dbDriverClass, String dbUrl, String dbUser, String dbPwd)227 {228 this.dbDriverClass =dbDriverClass;229 this.dbUrl =dbUrl;230 this.dbUser =dbUser;231 this.dbPwd =dbPwd;232 return this;233 }234
235 /**
236 * 7z执行全路径237 *@paramsevenZExePath238 *@return
239 */
240 publicD3tilorConfigBuilder sevenZExePath(String sevenZExePath)241 {242 this.sevenZExePath =sevenZExePath;243 return this;244 }245
246 /**
247 * 数据区路径248 *@paramdataPath249 *@return
250 */
251 publicD3tilorConfigBuilder dataPath(String dataPath)252 {253 this.dataPath =dataPath;254 return this;255 }256
257 /**
258 * 临时文件路径259 *@paramtempFilePath260 *@return
261 */
262 publicD3tilorConfigBuilder tempFilePath(String tempFilePath)263 {264 this.tempFilePath =tempFilePath;265 return this;266 }267
268 /**
269 * 解析超时时间(单位:分钟)270 *@paramtimeout271 *@return
272 */
273 public D3tilorConfigBuilder timeout(inttimeout)274 {275 this.timeout =timeout;276 return this;277 }278
279 /**
280 * D3EXE路径281 *@paramd3ExePath282 *@return
283 */
284 publicD3tilorConfigBuilder d3ExePath(String d3ExePath)285 {286 this.d3ExePath =d3ExePath;287 return this;288 }289
290 /**
291 * Tiles工具路径292 *@paramtilesPath293 *@return
294 */
295 publicD3tilorConfigBuilder tilesPath(String tilesPath)296 {297 this.tilesPath =tilesPath;298 return this;299 }300
301 /**
302 * 原点objx路径303 *@paramoriObjxPath304 *@return
305 */
306 publicD3tilorConfigBuilder oriObjxPath(String oriObjxPath)307 {308 this.oriObjxPath =oriObjxPath;309 return this;310 }311
312 /**
313 * 构造配置类对象314 *@return
315 */
316 publicD3tilorConfig build()317 {318 return new D3tilorConfig(this);319 }320 }321
322 }