List of usage examples for java.util Hashtable Hashtable
public Hashtable()
From source file:Main.java
/** * Parse a deliminated string with keys and values like Content-Type parameters * and cache-control headers. Keys can be present on their own e.g. * no-cache in which case the no-cache key will be in the hashtable with a * blank string value. It can also have an = sign with quoted or unquoted * text e.g. maxage=600 or maxage="600"// w w w . ja v a2s. c om * * @param str String to parse * @param deliminator deliminator character * @return Hashtable of parameters and values found */ public static Hashtable parseParams(String str, char deliminator) { String paramName = null; Hashtable params = new Hashtable(); boolean inQuotes = false; int strLen = str.length(); StringBuffer sb = new StringBuffer(); char c; char lastChar = 0; for (int i = 0; i < strLen; i++) { c = str.charAt(i); if (c == '"') { if (!inQuotes) { inQuotes = true; } else if (inQuotes && lastChar != '\\') { inQuotes = false; } } if ((isWhiteSpace(c) && !inQuotes) || (c == '"' && i < strLen - 1)) { //do nothing more } else if ((c == deliminator || i == strLen - 1)) { //check if we are here because it's the end... then we add this to bufer if (i == strLen - 1 && c != '"') { sb.append(c); } if (paramName != null) { //this is a parameter with a value params.put(paramName, sb.toString()); } else { //this is a parameter on its own params.put(sb.toString(), ""); } sb = new StringBuffer(); paramName = null; } else if (c == '=') { paramName = sb.toString(); sb = new StringBuffer(); } else { sb.append(c); } lastChar = c; } return params; }
From source file:cyrille.jndi.LdapTest.java
@Test public void test() throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, "ldap://localhost:389"); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system"); env.put(Context.SECURITY_CREDENTIALS, "secret"); DirContext dirContext = new InitialDirContext(env); Attributes attributes = dirContext.getAttributes("uid=aeinstein,ou=Users,dc=example,dc=com"); for (NamingEnumeration<Attribute> attributesEnumeration = (NamingEnumeration<Attribute>) attributes .getAll(); attributesEnumeration.hasMore();) { Attribute attribute = attributesEnumeration.next(); System.out.print(attribute.getID() + "="); for (NamingEnumeration<?> attributeValues = attribute.getAll(); attributeValues.hasMore();) { Object value = attributeValues.next(); if (value instanceof byte[] && "userpassword".equals(attribute.getID())) { byte[] bytes = (byte[]) value; System.out.print(new String(bytes) + ", "); } else { System.out.print(value + ", "); }// ww w .j a v a 2 s .c o m } System.out.println(); } }
From source file:Main.java
public Main() { try {//from w w w .jav a 2 s. c o m SyncFactory.registerProvider("MySyncProvider"); Hashtable env = new Hashtable(); env.put(SyncFactory.ROWSET_SYNC_PROVIDER, "MySyncProvider"); crs = new CachedRowSetImpl(env); crs.execute(); // load data from custom RowSetReader System.out.println("Fetching from RowSet..."); while (crs.next()) { displayData(); } if (crs.isAfterLast() == true) { System.out.println("We have reached the end"); System.out.println("crs row: " + crs.getRow()); } System.out.println("And now backwards..."); while (crs.previous()) { displayData(); } // end while previous if (crs.isBeforeFirst()) { System.out.println("We have reached the start"); } crs.first(); if (crs.isFirst()) { System.out.println("We have moved to first"); } System.out.println("crs row: " + crs.getRow()); if (!crs.isBeforeFirst()) { System.out.println("We aren't before the first row."); } crs.last(); if (crs.isLast()) { System.out.println("...and now we have moved to the last"); } System.out.println("crs row: " + crs.getRow()); if (!crs.isAfterLast()) { System.out.println("we aren't after the last."); } } catch (SQLException e) { e.printStackTrace(); System.err.println("SQLException: " + e.getMessage()); } }
From source file:TestTree4.java
public TestTree4() { super("Custom Icon Example"); setSize(350, 450);/*from ww w . jav a 2s . c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); // Build the hierarchy of containers & objects String[] schoolyard = { "School", "Playground", "Parking Lot", "Field" }; String[] mainstreet = { "Grocery", "Shoe Shop", "Five & Dime", "Post Office" }; String[] highway = { "Gas Station", "Convenience Store" }; String[] housing = { "Victorian_blue", "Faux Colonial", "Victorian_white" }; String[] housing2 = { "Mission", "Ranch", "Condo" }; Hashtable homeHash = new Hashtable(); homeHash.put("Residential 1", housing); homeHash.put("Residential 2", housing2); Hashtable cityHash = new Hashtable(); cityHash.put("School grounds", schoolyard); cityHash.put("Downtown", mainstreet); cityHash.put("Highway", highway); cityHash.put("Housing", homeHash); Hashtable worldHash = new Hashtable(); worldHash.put("My First VRML World", cityHash); // Build our tree out of our big hashtable tree1 = new JTree(worldHash); tree2 = new JTree(worldHash); DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer) tree2.getCellRenderer(); renderer.setClosedIcon(new ImageIcon("door.closed.gif")); renderer.setOpenIcon(new ImageIcon("door.open.gif")); renderer.setLeafIcon(new ImageIcon("world.gif")); JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tree1, tree2); getContentPane().add(pane, BorderLayout.CENTER); }
From source file:info.magnolia.jaas.principal.EntityImpl.java
public EntityImpl() { this.properties = new Hashtable(); }
From source file:com.modeln.build.ctrl.charts.CMnPatchCountChart.java
/** * Create a chart representing the number of patches per customer. * The data is passed in as a hashtable where the key is the customer * information and the value is the number of patch requests. * * @param data Hashtable containing accounts and the corresponding counts * @param label Count label/*from w w w . j av a2 s .co m*/ * * @return Bar chart repesenting the customer and count information */ public static final JFreeChart getPatchesByCustomerChart(Hashtable<CMnAccount, Integer> data, String label) { Hashtable<String, Integer> hash = new Hashtable<String, Integer>(); Enumeration accountList = data.keys(); while (accountList.hasMoreElements()) { CMnAccount account = (CMnAccount) accountList.nextElement(); Integer value = data.get(account); hash.put(account.getName(), value); } return getBarChart(hash, label + " by Customer", "Customer", label); }
From source file:fr.aliasource.webmail.proxy.Application.java
public Object start(IApplicationContext context) throws Exception { logger.info("MiniG backend starting..."); Hashtable<String, Object> settings = new Hashtable<String, Object>(); settings.put(JettyConstants.HTTP_PORT, 8081); settings.put(JettyConstants.CONTEXT_PATH, ""); settings.put(JettyConstants.CUSTOMIZER_CLASS, "org.minig.jetty.JettyPimper"); File sslP12 = new File("/etc/minig/minig.p12"); if (sslP12.exists()) { settings.put(JettyConstants.HTTPS_ENABLED, true); settings.put(JettyConstants.HTTPS_PORT, 8083); settings.put(JettyConstants.SSL_KEYSTORETYPE, "PKCS12"); settings.put(JettyConstants.SSL_KEYSTORE, sslP12.getAbsolutePath()); settings.put(JettyConstants.SSL_PASSWORD, "password"); settings.put(JettyConstants.SSL_KEYPASSWORD, "password"); settings.put(JettyConstants.SSL_PROTOCOL, "SSL"); settings.put(JettyConstants.SSL_WANTCLIENTAUTH, false); settings.put(JettyConstants.SSL_NEEDCLIENTAUTH, false); } else {/*from www . j av a 2s .c o m*/ logger.info("/etc/minig/minig.p12 not found, backend ssl support not activated"); } System.setProperty("org.mortbay.jetty.Request.maxFormContentSize", "" + (20 * 1024 * 1024)); JettyConfigurator.startServer("minig_backend", settings); loadBundle("org.eclipse.equinox.http.registry"); return EXIT_OK; }
From source file:de.devmil.common.licensing.LicenseInfo.java
private LicenseInfo() { _Licenses = new Hashtable<String, LicenseDefinition>(); _Packages = new ArrayList<PackageInfo>(); }
From source file:com.manning.blogapps.chapter10.metaweblogclient.MetaWeblogResource.java
public MetaWeblogResource(MetaWeblogBlog blog, String name, String contentType, File uploadFile) { super(blog, new Hashtable()); this.blog = blog; this.name = name; this.contentType = contentType; this.uploadFile = uploadFile; }
From source file:edu.harvard.i2b2.eclipse.plugins.adminTool.utils.SecurityUtil.java
/** * Initialize HighEncryption variable for empi and notes. *///from w w w .j a v a 2 s. c o m private void initHighEncrypt() { try { // init high encryption with notes key Hashtable<String, String> hashNotestemp = new Hashtable<String, String>(); hashNotestemp.put("A:\\I401.txt", notesKey); notesHighEnc = new HighEncryption("A:\\I401.txt", hashNotestemp); } catch (Exception e) { e.printStackTrace(); } }