List of usage examples for org.apache.commons.lang StringUtils contains
public static boolean contains(String str, String searchStr)
Checks if String contains a search String, handling null
.
From source file:de.hybris.platform.b2bdocumentsfilter.B2BDocumentsSecureMediaFilter.java
@Override public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException { if ((!(request instanceof HttpServletRequest)) || (!(response instanceof HttpServletResponse))) { throw new ServletException("SecureMediaFilter just supports HTTP requests"); }//from ww w . j a v a2s. c o m final HttpServletRequest httpRequest = (HttpServletRequest) request; final HttpServletResponse httpResponse = (HttpServletResponse) response; final String resourcePath = getResourcePath(httpRequest); try { setSecureURLRendererForThread(httpResponse); if (StringUtils.contains(resourcePath, this.secureMediaToken)) { final String mediaPKStr = httpRequest.getParameter(MEDIA_PK); final MediaModel mediaModel = (MediaModel) this.modelService.get(PK.parse(mediaPKStr)); if (mediaModel == null) { httpResponse.sendError(404); return; } else if (!(isAccessGranted(mediaModel))) { httpResponse.sendError(403); return; } final int mediaSize = (mediaModel.getSize() == null) ? 0 : mediaModel.getSize().intValue(); sendData(httpResponse, this.mediaService.getStreamFromMedia(mediaModel), mediaSize); } } finally { chain.doFilter(request, response); clearSecureURLRendererForThread(); } }
From source file:com.att.aro.core.settings.impl.JvmSettings.java
@Override public String getAttribute(String name) { if (!StringUtils.equals("Xmx", name)) { throw new IllegalArgumentException("Not a valid property:" + name); }/*from ww w . j a va2 s .c o m*/ Path path = Paths.get(CONFIG_FILE_PATH); if (!path.toFile().exists()) { return DEFAULT_MEM; } try (Stream<String> lines = Files.lines(path)) { List<String> values = lines.filter((line) -> StringUtils.contains(line, name)) .collect(Collectors.toList()); if (values == null || values.isEmpty()) { LOGGER.error("No xmx entries on vm options file"); return DEFAULT_MEM; } else { return values.get(values.size() - 1).replace("-Xmx", "").replace("m", ""); } } catch (IOException e) { String message = "Counldn't read vm options file"; LOGGER.error(message, e); throw new ARORuntimeException(message, e); } }
From source file:au.org.ala.sds.model.SensitiveTaxonStore.java
private void verifyAndInitialiseSpeciesList() { List<SensitiveTaxon> additionalAcceptedTaxons = new ArrayList<SensitiveTaxon>(); for (SensitiveTaxon st : taxonList) { NameSearchResult match = lookupName(st.getTaxonName(), st.getFamily(), st.getRank()); if (match != null) { st.setLsid(match.getLsid()); if (match.isSynonym()) { NameSearchResult accepted = getAcceptedNameFromSynonym(match); if (accepted != null) { String acceptedName = accepted.getRankClassification().getScientificName(); logger.info("Sensitive species '" + st.getName() + "' is not accepted name - using '" + acceptedName + "'"); SensitiveTaxon acceptedTaxon = findByExactMatch(acceptedName); if (acceptedTaxon == null) { acceptedTaxon = new SensitiveTaxon(acceptedName, StringUtils.contains(acceptedName, ' ') ? RankType.SPECIES : RankType.GENUS); acceptedTaxon.setLsid(accepted.getLsid()); if (!additionalAcceptedTaxons.contains(acceptedTaxon)) { additionalAcceptedTaxons.add(acceptedTaxon); logger.info("Accepted name '" + acceptedName + "' (" + acceptedTaxon.getLsid() + ") added to sensitive taxon list"); }//from w w w .ja v a 2 s . com } st.setAcceptedName(acceptedName); } } logger.debug(st.getName() + (st.getAcceptedName() == null ? "" : " (" + st.getAcceptedName() + ")") + "\t" + st.getLsid()); } else { logger.warn("Sensitive species '" + st.getName() + "' not found in NameMatching index"); } } // Add additional accepted sensitive taxa taxonList.addAll(additionalAcceptedTaxons); Collections.sort(taxonList); // Construct lookup maps and deal with synonym sensitivity instances for (int i = 0; i < this.taxonList.size(); i++) { SensitiveTaxon st = taxonList.get(i); String lsid = st.getLsid(); if (StringUtils.isNotBlank(lsid)) { lsidMap.put(st.getLsid(), i); } if (st.getAcceptedName() != null) { SensitiveTaxon acceptedTaxon = findByExactMatch(st.getAcceptedName()); if (acceptedTaxon != null) { for (SensitivityInstance si : st.getInstances()) { if (!acceptedTaxon.getInstances().contains(si)) { acceptedTaxon.getInstances().add(si); } } st.setAcceptedTaxon(acceptedTaxon); } else { logger.error("Accepted taxon '" + st.getAcceptedName() + "' not found in taxon list"); } } else { if (StringUtils.isNotBlank(lsid)) { nameMap.put(st.getName(), i); logger.debug("Added '" + st.getName() + "' to nameMap"); } } } }
From source file:com.baidu.cc.web.filter.AuthCheckFilter.java
@Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) servletRequest; HttpServletResponse response = (HttpServletResponse) servletResponse; String path = request.getServletPath(); if (request.getParameter("method") != null) { path = path + "?method=" + request.getParameter("method"); }/*from w w w. j a v a 2 s . c o m*/ // ?includePath ??? if (UrlUtils.urlMatch(includePathv, path)) { if (StringUtils.contains("/project/editProject.action;/project/saveProject.action;", path)) { // ?????projectId????? String tmpProjectId = request.getParameter("reqParam.project.id"); if (StringUtils.isEmpty(tmpProjectId)) { tmpProjectId = request.getParameter("reqParam.projectId"); } Long pid = NumberUtils.toLong(tmpProjectId, 0); if (pid < 1L) { filterChain.doFilter(request, response); return; } } String authCheck = request.getParameter("authCheck"); Long projectId = SysUtils.getProjectIdFromAuthcheck(authCheck); Long userId = SysUtils.getUserIdFromAuthcheck(authCheck); Long cookieUserId = SysUtils.getUserIdFromCookie(request); // authCheck?? if (projectId == 0L || userId == 0L || !cookieUserId.equals(userId) || !accessSettingService.checkAuth(userId, SysUtils.ACCESS_SETTING_TYPE_PROJECT, projectId)) { throw new AuthException("??"); } } filterChain.doFilter(request, response); }
From source file:com.hangum.tadpole.sql.util.sqlscripts.scripts.MSSQL_8_LE_DDLScript.java
@Override public String getTableScript(TableDAO tableDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); List<HashMap> srcList = client.queryForList("getTableScript", tableDAO.getName()); StringBuilder result = new StringBuilder(""); result.append("/* DROP TABLE " + tableDAO.getName() + " CASCADE CONSTRAINT; */ \n\n"); result.append("CREATE TABLE " + tableDAO.getName() + "( \n"); for (int i = 0; i < srcList.size(); i++) { HashMap<String, Object> source = srcList.get(i); result.append("\t"); if (i > 0) result.append(","); result.append(source.get("COLUMN_NAME")).append(" "); result.append(source.get("DATA_TYPE")); if (source.get("DATA_PRECISION") != null && ((Integer) source.get("DATA_PRECISION")).intValue() > 0) { result.append("(" + source.get("DATA_PRECISION")); if (source.get("DATA_SCALE") != null && ((Integer) source.get("DATA_SCALE")).intValue() > 0) { result.append("," + source.get("DATA_SCALE")); }// ww w . j a va2 s . c o m result.append(")"); } else if (!StringUtils.contains((String) source.get("DATA_TYPE"), "DATE") && !StringUtils.contains((String) source.get("DATA_TYPE"), "NUMBER") && ((Integer) source.get("DATA_LENGTH")).intValue() > 0) { result.append("(" + source.get("DATA_LENGTH") + ")"); } else { result.append(" "); } if (source.get("DATA_DEFAULT") != null) { if (StringUtils.contains((String) source.get("DATA_TYPE"), "CHAR")) { result.append(" DEFAULT '" + (String) source.get("DATA_DEFAULT") + "'"); } else { result.append(" DEFAULT " + (String) source.get("DATA_DEFAULT")); } } if ("NO".equals(source.get("NULLABLE"))) { result.append(" NOT NULL "); } result.append("\n"); } // primary key List<HashMap> srcPkList = client.queryForList("getTableScript.pk", tableDAO.getName()); for (int i = 0; i < srcPkList.size(); i++) { HashMap<String, Object> source = srcPkList.get(i); if (i == 0) { result.append("\t,CONSTRAINT ").append(source.get("CONSTRAINT_NAME")).append(" PRIMARY KEY "); if ("CLUSTERED".equals(source.get("INDEX_TYPE"))) { result.append(" CLUSTERED "); } result.append(" ( ").append(source.get("COLUMN_NAME")); if ((Boolean) source.get("DESCENDING")) { result.append(" DESC "); } } else { result.append(", " + source.get("COLUMN_NAME")); if ((Boolean) source.get("DESCENDING")) { result.append(" DESC "); } } if (i == srcPkList.size() - 1) { result.append(") \n"); } } result.append("); \n\n"); // table, column comments List<String> srcCommentList = client.queryForList("getTableScript.comments", tableDAO.getName()); for (int i = 0; i < srcCommentList.size(); i++) { result.append(srcCommentList.get(i) + "\n"); } // foreign key // column constraint (? ? ) // partition table define // storage option // iot_type table define // table grant // table trigger // table synonyms return result.toString(); }
From source file:com.microsoft.alm.plugin.idea.common.ui.common.LoginPageModelImpl.java
@Override public void setServerName(final String serverName) { if (!StringUtils.equals(this.serverName, serverName)) { final String newServerName; // Allow just the server name as a short hand if (StringUtils.isNotEmpty(serverName) && !StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR) && !StringUtils.equals(serverName, TfPluginBundle.message(TfPluginBundle.KEY_USER_ACCOUNT_PANEL_VSO_SERVER_NAME)) && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO) && !StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN)) { // no slash, not "Microsoft Account" and does not contain visualstudio.com or tfsallin.net // means it must just be a on-premise TFS server name, so add all the normal stuff newServerName = String.format(DEFAULT_SERVER_FORMAT, serverName); } else if (!StringUtils.contains(serverName, UrlHelper.URL_SEPARATOR) && (StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_VSO) || StringUtils.containsIgnoreCase(serverName, UrlHelper.HOST_TFS_ALL_IN))) { //no slash and contains visualstudio.com or tfsallin.net // means it must be a VSTS account newServerName = String.format(DEFAULT_VSTS_ACCOUNT_FORMAT, serverName); } else {/*from w w w. j a v a2 s .c o m*/ newServerName = serverName; } setServerNameInternal(newServerName); } }
From source file:edu.ku.brc.af.ui.ESTermParser.java
@Override public boolean parse(final String searchTermArg, final boolean parseAsSingleTerm) { instance.fields.clear();// w w w . jav a 2 s.co m //DateWrapper scrDateFormat = AppPrefsCache.getDateWrapper("ui", "formatting", "scrdateformat"); int currentYear = Calendar.getInstance().get(Calendar.YEAR); String searchTerm = searchTermArg; DateParser dd = new DateParser(instance.scrDateFormat.getSimpleDateFormat().toPattern()); //---------------------------------------------------------------------------------------------- // NOTE: If a full date was type in and it was parsed as such // and it couldn't be something else, then it only searches date fields. //---------------------------------------------------------------------------------------------- int cnt = 0; if (searchTerm.length() > 0) { if (StringUtils.contains(searchTerm, '\\')) { return false; } String[] terms; boolean startWith = searchTerm.startsWith("*"); boolean endsWith = searchTerm.endsWith("*"); searchTerm = StringUtils.remove(searchTerm, '*'); if (searchTerm.startsWith("\"") || searchTerm.startsWith("'") || searchTerm.startsWith("`")) { searchTerm = StringUtils.stripStart(searchTerm, "\"'`"); searchTerm = StringUtils.stripEnd(searchTerm, "\"'`"); terms = new String[] { searchTerm }; } else if (parseAsSingleTerm) { terms = new String[] { searchTerm }; } else { terms = StringUtils.split(searchTerm, ' '); } if (terms.length == 1) { terms[0] = (startWith ? "*" : "") + terms[0] + (endsWith ? "*" : ""); } else { terms[0] = (startWith ? "*" : "") + terms[0]; terms[terms.length - 1] = terms[terms.length - 1] + (endsWith ? "*" : ""); } for (String term : terms) { if (StringUtils.isEmpty(term)) { continue; } SearchTermField stf = new SearchTermField(term); if (stf.isSingleChar()) { return false; } instance.fields.add(stf); cnt += !stf.isSingleChar() ? 1 : 0; //log.debug(term); String termStr = term; if (termStr.startsWith("*")) { stf.setOption(SearchTermField.STARTS_WILDCARD); termStr = termStr.substring(1); stf.setTerm(termStr); } if (termStr.endsWith("*")) { stf.setOption(SearchTermField.ENDS_WILDCARD); termStr = termStr.substring(0, termStr.length() - 1); stf.setTerm(termStr); } // First check to see if it is all numeric. if (StringUtils.isNumeric(termStr)) { stf.setOption(SearchTermField.IS_NUMERIC); if (StringUtils.contains(termStr, '.')) { stf.setOption(SearchTermField.HAS_DEC_POINT); } if (!stf.isOn(SearchTermField.HAS_DEC_POINT) && termStr.length() == 4) { int year = Integer.parseInt(termStr); if (year > 1000 && year <= currentYear) { stf.setOption(SearchTermField.IS_YEAR_OF_DATE); } } } else { // Check to see if it is date Date searchDate = dd.parseDate(searchTermArg); if (searchDate != null) { try { termStr = dbDateFormat.format(searchDate); stf.setTerm(termStr); stf.setOption(SearchTermField.IS_DATE); } catch (Exception ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ESTermParser.class, ex); // should never get here } } } } } return instance.fields.size() > 0 && cnt > 0; }
From source file:com.turqmelon.MelonEco.commands.CurrencyCommand.java
@Override public boolean onCommand(CommandSender sender, Command command, String s, String[] args) { new BukkitRunnable() { @Override// w w w . ja v a 2s . c o m public void run() { if (!sender.hasPermission("eco.currencies")) { sender.sendMessage("cl[Eco] cYou don't have permission to manage currencies."); return; } if (args.length == 0) { sender.sendMessage("el[Eco] eCurrency Management"); sender.sendMessage("el[Eco] bl-> b/currency create 7<Singular> <Plural>"); sender.sendMessage("el[Eco] bl-> b/currency delete 7<Name>"); sender.sendMessage("el[Eco] bl-> b/currency view 7<Name>"); sender.sendMessage("el[Eco] bl-> b/currency list"); sender.sendMessage("el[Eco] bl-> b/currency symbol 7<Name> <Char|Remove>"); sender.sendMessage("el[Eco] bl-> b/currency color 7<Name> <ChatColor>"); sender.sendMessage("el[Eco] bl-> b/currency decimals 7<Name>"); sender.sendMessage("el[Eco] bl-> b/currency payable 7<Name>"); sender.sendMessage("el[Eco] bl-> b/currency default 7<Name>"); sender.sendMessage("el[Eco] bl-> b/currency startingbal 7<Name> <Amount>"); } else { String cmd = args[0]; if (cmd.equalsIgnoreCase("create")) { if (args.length == 3) { String single = args[1]; String plural = args[2]; if (AccountManager.getCurrency(single) == null && AccountManager.getCurrency(plural) == null) { if (StringUtils.contains(single, ':') || StringUtils.contains(single, ',') || StringUtils.contains(plural, ':') || StringUtils.contains(plural, ',')) { sender.sendMessage("cl[Eco] cInvalid character present."); return; } Currency currency = new Currency(UUID.randomUUID(), single, plural); sender.sendMessage("al[Eco] aCreated currency: " + currency.getPlural()); AccountManager.getCurrencies().add(currency); if (AccountManager.getCurrencies().size() == 1) { currency.setDefaultCurrency(true); } MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage("cl[Eco] cCurrency already exists."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("list")) { sender.sendMessage("al[Eco] aThere are f" + AccountManager.getCurrencies().size() + "a currencies."); for (Currency currency : AccountManager.getCurrencies()) { sender.sendMessage("al[Eco] bl-> b" + currency.getSingular()); } } else if (cmd.equalsIgnoreCase("view")) { if (args.length == 2) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { sender.sendMessage("al[Eco] aInfo for " + currency.getUuid().toString()); sender.sendMessage("al[Eco] aSingular: f" + currency.getSingular() + "a, Plural: f" + currency.getPlural()); sender.sendMessage("al[Eco] aNew players start with f" + currency.format(currency.getDefaultBalance()) + "a."); sender.sendMessage("al[Eco] aDecimals? f" + (currency.isDecimalSupported() ? "Yes" : "No")); sender.sendMessage("al[Eco] aDefault? f" + (currency.isDefaultCurrency() ? "Yes" : "No")); sender.sendMessage( "al[Eco] aPayable? f" + (currency.isPayable() ? "Yes" : "No")); sender.sendMessage("al[Eco] aColor: " + currency.getColor() + currency.getColor().name()); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("startingbal")) { if (args.length == 3) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { double amount; if (currency.isDecimalSupported()) { try { amount = Double.parseDouble(args[2]); if (amount <= 0) { throw new NumberFormatException(); } } catch (NumberFormatException ex) { sender.sendMessage("cl[Eco] cPlease provide a valid amount."); return; } } else { try { amount = Integer.parseInt(args[2]); if (amount <= 0) { throw new NumberFormatException(); } } catch (NumberFormatException ex) { sender.sendMessage("cl[Eco] cPlease provide a valid amount."); return; } } currency.setDefaultBalance(amount); sender.sendMessage("al[Eco] aStarting balance for " + currency.getPlural() + " set: " + currency.getDefaultBalance()); MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("color")) { if (args.length == 3) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { try { ChatColor color = ChatColor.valueOf(args[2].toUpperCase()); if (color.isFormat()) { throw new Exception(); } currency.setColor(color); sender.sendMessage("al[Eco] aColor for " + currency.getPlural() + " updated: " + color + color.name()); MelonEco.getDataStore().saveCurrency(currency); } catch (Exception ex) { sender.sendMessage("cl[Eco] cInvalid chat color."); } } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("symbol")) { if (args.length == 3) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { String symbol = args[2]; if (symbol.equalsIgnoreCase("remove")) { currency.setSymbol(null); sender.sendMessage( "al[Eco] aCurrency symbol removed for " + currency.getPlural()); MelonEco.getDataStore().saveCurrency(currency); } else if (symbol.length() == 1) { currency.setSymbol(symbol); sender.sendMessage("al[Eco] aCurrency symbol for " + currency.getPlural() + " updated: " + symbol); MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage( "cl[Eco] cSymbol must be 1 character, or say \"remove\"."); } } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("default")) { if (args.length == 2) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { Currency c = AccountManager.getDefaultCurrency(); if (c != null) { c.setDefaultCurrency(false); MelonEco.getDataStore().saveCurrency(c); } currency.setDefaultCurrency(true); sender.sendMessage( "al[Eco] aSet default currency to " + currency.getPlural()); MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("payable")) { if (args.length == 2) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { currency.setPayable(!currency.isPayable()); sender.sendMessage("al[Eco] aToggled payability for " + currency.getPlural() + ": " + currency.isPayable()); MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("decimals")) { if (args.length == 2) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { currency.setDecimalSupported(!currency.isDecimalSupported()); sender.sendMessage("al[Eco] aToggled Decimal Support for " + currency.getPlural() + ": " + currency.isDecimalSupported()); MelonEco.getDataStore().saveCurrency(currency); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else if (cmd.equalsIgnoreCase("delete")) { if (args.length == 2) { Currency currency = AccountManager.getCurrency(args[1]); if (currency != null) { AccountManager.getAccounts().stream() .filter(account -> account.getBalances().containsKey(currency)) .forEach(account -> account.getBalances().remove(currency)); MelonEco.getDataStore().deleteCurrency(currency); AccountManager.getCurrencies().remove(currency); sender.sendMessage("al[Eco] aDeleted currency: " + currency.getPlural()); } else { sender.sendMessage("cl[Eco] cUnknown currency."); } } else { sender.sendMessage("cl[Eco] cUsage: f/currency create <Singular> <Plural>"); } } else { sender.sendMessage("cl[Eco] cUnknown currency sub-command."); } } } }.runTaskAsynchronously(MelonEco.getInstance()); return true; }
From source file:info.magnolia.commands.CommandsManager.java
/** * Use a delimiter to separate the catalog and command name * @param commandName// www. j a v a2 s .c o m * @return the command */ public Command getCommand(String commandName) { String catalogName = DEFAULT_CATALOG; if (StringUtils.contains(commandName, COMMAND_DELIM)) { catalogName = StringUtils.substringBefore(commandName, COMMAND_DELIM); commandName = StringUtils.substringAfter(commandName, COMMAND_DELIM); } Command command = getCommand(catalogName, commandName); if (command == null) { command = getCommand(DEFAULT_CATALOG, commandName); } return command; }
From source file:com.hangum.tadpole.sql.util.sqlscripts.scripts.OracleDDLScript.java
@Override public String getTableScript(TableDAO tableDAO) throws Exception { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); List<HashMap> srcList = client.queryForList("getTableScript", tableDAO.getName()); StringBuilder result = new StringBuilder(""); result.append("/* DROP TABLE " + tableDAO.getName() + " CASCADE CONSTRAINT; */ \n\n"); result.append("CREATE TABLE " + tableDAO.getName() + "( \n"); for (int i = 0; i < srcList.size(); i++) { HashMap<String, Object> source = srcList.get(i); result.append("\t"); if (i > 0) result.append(","); result.append(source.get("COLUMN_NAME")).append(" "); result.append(source.get("DATA_TYPE")); if (source.get("DATA_PRECISION") != null && ((BigDecimal) source.get("DATA_PRECISION")).intValue() > 0) { result.append("(" + source.get("DATA_PRECISION")); if (source.get("DATA_SCALE") != null && ((BigDecimal) source.get("DATA_SCALE")).intValue() > 0) { result.append("," + source.get("DATA_SCALE")); }//from www .j ava 2 s . c o m result.append(")"); } else if (!StringUtils.contains((String) source.get("DATA_TYPE"), "DATE") && !StringUtils.contains((String) source.get("DATA_TYPE"), "NUMBER") && ((BigDecimal) source.get("DATA_LENGTH")).intValue() > 0) { result.append("(" + source.get("DATA_LENGTH") + ")"); } else { result.append(" "); } if (source.get("DATA_DEFAULT") != null) { if (StringUtils.contains((String) source.get("DATA_TYPE"), "CHAR")) { result.append(" DEFAULT '" + source.get("DATA_DEFAULT") + "'"); } else { result.append(" DEFAULT " + source.get("DATA_DEFAULT")); } } if ("NO".equals(source.get("NULLABLE"))) { result.append(" NOT NULL "); } result.append("\n"); } // primary key List<HashMap> srcPkList = client.queryForList("getTableScript.pk", tableDAO.getName()); for (int i = 0; i < srcPkList.size(); i++) { HashMap<String, Object> source = srcPkList.get(i); if (i == 0) { result.append("\t,CONSTRAINT ").append(source.get("CONSTRAINT_NAME")).append(" PRIMARY KEY ( ") .append(source.get("COLUMN_NAME")); } else { result.append(", " + source.get("COLUMN_NAME")); } if (i == srcPkList.size() - 1) { result.append(") \n"); } } result.append("); \n\n"); // table, column comments List<String> srcCommentList = client.queryForList("getTableScript.comments", tableDAO.getName()); for (int i = 0; i < srcCommentList.size(); i++) { result.append(srcCommentList.get(i) + "\n"); } // foreign key // column constraint (? ? ) // partition table define // storage option // iot_type table define // table grant // table trigger // table synonyms return result.toString(); }