List of usage examples for java.util Hashtable clear
public synchronized void clear()
From source file:MainClass.java
public static void main(String[] s) { Hashtable table = new Hashtable(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); table.clear(); System.out.println(table);//from www . j a v a 2 s. co m }
From source file:Main.java
public static void main(String[] args) { Hashtable<String, String> ht = new Hashtable<String, String>(); ht.put("1", "One"); ht.put("2", "Two"); ht.put("3", "Three"); ht.clear(); System.out.println(ht.size()); }
From source file:Main.java
public static void main(String[] s) { Hashtable<String, String> table = new Hashtable<String, String>(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); table.clear(); System.out.println(table);// w w w .ja v a2 s . c o m }
From source file:Main.java
public static void main(String args[]) { Hashtable<Integer, String> htable = new Hashtable<Integer, String>(); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "from java2s.com"); // check table content System.out.println("Hash table content: " + htable); // clear the table htable.clear(); // check content after clear System.out.println("Hash table content after clear: " + htable); }
From source file:Main.java
public static void main(String args[]) { Hashtable<Integer, String> htable = new Hashtable<Integer, String>(10); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "from java2s.com"); // check table content System.out.println("Hash table content: " + htable); // clear the table htable.clear(); // check content after clear System.out.println("Hash table content after clear: " + htable); }
From source file:Main.java
public static void main(String args[]) { Hashtable<Integer, String> htable = new Hashtable<Integer, String>(10, 0.75F); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "from java2s.com"); // check table content System.out.println("Hash table content: " + htable); // clear the table htable.clear(); // check content after clear System.out.println("Hash table content after clear: " + htable); }
From source file:Main.java
public static void clearHash(Hashtable hash) { if (hash != null) { hash.clear(); } hash = null; }
From source file:be.fgov.kszbcss.rhq.websphere.config.NamedThreadFactory.java
public Thread newThread(final Runnable runnable) { // The log4j MDC is stored in an InheritableThreadLocal. We need to clear it. Runnable runnableWrapper = new Runnable() { public void run() { Hashtable<?, ?> context = MDC.getContext(); if (context != null) { context.clear(); }/*from w w w . java 2 s .com*/ runnable.run(); } }; Thread t = new Thread(group, runnableWrapper, namePrefix + "-" + threadNumber.getAndIncrement()); t.setDaemon(false); t.setUncaughtExceptionHandler(this); return t; }
From source file:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java
@Override protected void nonInteractiveConfig() { try {//from w w w .jav a 2 s .c o m InputStream input = new FileInputStream(externalFile); POIFSFileSystem fs = new POIFSFileSystem(input); HSSFWorkbook workBook = new HSSFWorkbook(fs); HSSFSheet sheet = workBook.getSheetAt(0); // Calculate the number of rows and columns colInfo = new Vector<ImportColumnInfo>(16); Hashtable<Integer, Boolean> colTracker = new Hashtable<Integer, Boolean>(); boolean firstRow = true; int col = 0; colTracker.clear(); Vector<Integer> badHeads = new Vector<Integer>(); Vector<Integer> emptyCols = new Vector<Integer>(); checkHeadsAndCols(sheet, badHeads, emptyCols); if (firstRowHasHeaders && badHeads.size() > 0) { status = ConfigureExternalDataIFace.Status.Error; showBadHeadingsMsg(badHeads, null, getResourceString("Error")); return; } // Iterate over each row in the sheet @SuppressWarnings("unchecked") Iterator<HSSFRow> rows = sheet.rowIterator(); while (rows.hasNext()) { HSSFRow row = rows.next(); if (firstRow || numRows == 1) { // Iterate over each cell in the row and print out the cell's content int colNum = 0; int maxSize = Math.max(row.getPhysicalNumberOfCells(), row.getLastCellNum()); while (colNum < maxSize) { if (emptyCols.indexOf(new Integer(colNum)) == -1) { ImportColumnInfo.ColumnType disciplinee = ImportColumnInfo.ColumnType.Integer; String value = null; boolean skip = false; HSSFCell cell = row.getCell(colNum); if (cell == null) { //assuming numRows == 1 or not firstRowHasHeaders. //the call to checkHeadsAndCols would have already blank headers. value = ""; disciplinee = ImportColumnInfo.ColumnType.String; } else switch (cell.getCellType()) { case HSSFCell.CELL_TYPE_NUMERIC: double numeric = cell.getNumericCellValue(); value = Double.toString(numeric); disciplinee = ImportColumnInfo.ColumnType.Double; break; case HSSFCell.CELL_TYPE_STRING: HSSFRichTextString richVal = cell.getRichStringCellValue(); value = richVal.getString().trim(); disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BLANK: value = ""; disciplinee = ImportColumnInfo.ColumnType.String; break; case HSSFCell.CELL_TYPE_BOOLEAN: boolean bool = cell.getBooleanCellValue(); value = Boolean.toString(bool); disciplinee = ImportColumnInfo.ColumnType.Boolean; break; default: skip = true; break; } if (numRows == 1 && !skip) { colInfo.get(col).setData(value); col++; } else if (!skip) { if (firstRowHasHeaders) { colInfo.add(new ImportColumnInfo(colNum, disciplinee, value, value, null, null, null)); colTracker.put(col, true); } else { String colName = getResourceString("DEFAULT_COLUMN_NAME") + " " + (colNum + 1); colInfo.add(new ImportColumnInfo(colNum, disciplinee, colName, colName, null, null, null)); colTracker.put(colNum, true); } numCols++; } } colNum++; } firstRow = false; } numRows++; } Collections.sort(colInfo); readMappings(fs); status = Status.Valid; } catch (IOException ex) { edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(ConfigureXLS.class, ex); status = Status.Error; } }
From source file:org.openbravo.erpCommon.ad_reports.MInOutTraceReports.java
private void printPageDataSheet(HttpServletResponse response, VariablesSecureApp vars, String strIn, String strmProductIdGlobal, String strmAttributesetinstanceIdGlobal, Hashtable<String, Integer> calculated, Vector<Integer> count) throws IOException, ServletException { if (log4j.isDebugEnabled()) log4j.debug("Output: dataSheet"); XmlDocument xmlDocument = xmlEngine/*from ww w . j a va2 s .c o m*/ .readXmlTemplate("/org/openbravo/erpCommon/ad_reports/MInOutTraceReports").createXmlDocument(); MInOutTraceReportsData[] data = null; calculated.clear(); if (strmProductIdGlobal.equals("")) { data = new MInOutTraceReportsData[0]; } else { data = MInOutTraceReportsData.select(this, vars.getLanguage(), strmProductIdGlobal, strmAttributesetinstanceIdGlobal, Utility.getContext(this, vars, "#AccessibleOrgTree", "MInOutTraceReports"), Utility.getContext(this, vars, "#User_Client", "MInOutTraceReports")); } xmlDocument.setParameter("calendar", vars.getLanguage()); xmlDocument.setParameter("directory", "var baseDirectory = \"" + strReplaceWith + "/\";\n"); xmlDocument.setParameter("mProduct", strmProductIdGlobal); xmlDocument.setParameter("parameterM_ATTRIBUTESETINSTANCE_ID", strmAttributesetinstanceIdGlobal); xmlDocument.setData("reportM_ATTRIBUTESETINSTANCE_ID", "liststructure", AttributeSetInstanceComboData.select(this, vars.getLanguage(), strmProductIdGlobal, Utility.getContext(this, vars, "#User_Client", "MInOutTraceReports"), Utility.getContext(this, vars, "#AccessibleOrgTree", "MInOutTraceReports"))); xmlDocument.setParameter("productDescription", MInOutTraceReportsData.selectMproduct(this, strmProductIdGlobal)); xmlDocument.setParameter("paramLanguage", "defaultLang=\"" + vars.getLanguage() + "\";"); xmlDocument.setParameter("in", strIn); xmlDocument.setParameter("out", strIn); xmlDocument.setData("structure1", processData(vars, data, strIn, strmProductIdGlobal, calculated, count)); if (log4j.isDebugEnabled()) log4j.debug("****FIN: "/* * + ((data!=null && data.length>0)?data[0].html:"") */); ToolBar toolbar = new ToolBar(this, vars.getLanguage(), "MInOutTraceReports", false, "", "", "", false, "ad_reports", strReplaceWith, false, true); toolbar.prepareSimpleToolBarTemplate(); xmlDocument.setParameter("toolbar", toolbar.toString()); try { WindowTabs tabs = new WindowTabs(this, vars, "org.openbravo.erpCommon.ad_reports.MInOutTraceReports"); xmlDocument.setParameter("parentTabContainer", tabs.parentTabs()); xmlDocument.setParameter("mainTabContainer", tabs.mainTabs()); xmlDocument.setParameter("childTabContainer", tabs.childTabs()); xmlDocument.setParameter("theme", vars.getTheme()); NavigationBar nav = new NavigationBar(this, vars.getLanguage(), "MInOutTraceReports.html", classInfo.id, classInfo.type, strReplaceWith, tabs.breadcrumb()); xmlDocument.setParameter("navigationBar", nav.toString()); LeftTabsBar lBar = new LeftTabsBar(this, vars.getLanguage(), "MInOutTraceReports.html", strReplaceWith); xmlDocument.setParameter("leftTabs", lBar.manualTemplate()); } catch (Exception ex) { throw new ServletException(ex); } { OBError myMessage = vars.getMessage("MInOutTraceReports"); vars.removeMessage("MInOutTraceReports"); if (myMessage != null) { xmlDocument.setParameter("messageType", myMessage.getType()); xmlDocument.setParameter("messageTitle", myMessage.getTitle()); xmlDocument.setParameter("messageMessage", myMessage.getMessage()); } } response.setContentType("text/html; charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(xmlDocument.print()); out.close(); }