List of usage examples for java.util Hashtable put
public synchronized V put(K key, V value)
From source file:mypackage.FeedlyClient.java
public FeedlyClient() { _app = (MyApp) UiApplication.getUiApplication(); _feedlyapi = new FeedlyAPI(this, client_id, client_secret, sandbox); _network = new Network(this); _connectionFactory = _network.selectTransport(); ///*from w ww. ja va2 s . c o m*/ //?@foCX?? // // Get the code signing key associated with "ACME" codeSigningKey = CodeSigningKey.get(CodeModuleManager.getModuleHandle("GreenFeedReader"), "ACME"); //PersistentStore.destroyPersistentObject(PERSISTENT_OBJECT_KEY); //return; _persist = PersistentStore.getPersistentObject(PERSISTENT_OBJECT_KEY); // ?NnbVe?[u`?????B synchronized (_persist) { if (_persist.getContents(codeSigningKey) == null) { Hashtable _tmp_ht = new Hashtable(); _tmp_ht.put("id", ""); _tmp_ht.put("access_token", ""); _tmp_ht.put("refresh_token", ""); _tmp_ht.put("expires_in", new Integer(0)); _tmp_ht.put("update", new Long(0)); _persist.setContents(new ControlledAccess(_tmp_ht, codeSigningKey)); PersistentObject.commit(_persist); } } // WJ Hashtable _tmp_ht = (Hashtable) _persist.getContents(codeSigningKey); this.id = (String) _tmp_ht.get("id"); this.access_token = (String) _tmp_ht.get("access_token"); this.refresh_token = (String) _tmp_ht.get("refresh_token"); this.expires_in = ((Integer) _tmp_ht.get("expires_in")).intValue(); this.update = ((Long) _tmp_ht.get("update")).longValue(); // // ?XeCg? // // HomeXeCg??B _homeState = new State_Home(this); _currentState = _homeState; }
From source file:com.softlayer.objectstorage.ObjectFile.java
/** * upload this file from a local file copy to the objectstorage server * /* w ww .ja va 2s . c o m*/ * @param localFileLocation * string representation of the path of the local file * @param tags * Map of tags to attach to this file * @return etag value of this upload * @throws EncoderException * @throws IOException */ public String uploadFile(String localFileLocation, Map<String, String> tags) throws EncoderException, IOException { if (super.isValidName(this.name)) { File file = new File(localFileLocation); bytes = new byte[(int) file.length()]; FileInputStream fis = new FileInputStream(file); fis.read(bytes); Hashtable<String, String> params = super.createAuthParams(); Iterator<Map.Entry<String, String>> it = tags.entrySet().iterator(); while (it.hasNext()) { Map.Entry<String, String> pairs = (Map.Entry<String, String>) it.next(); params.put(Client.X_OBJECT_META + pairs.getKey(), pairs.getValue()); it.remove(); } String uName = super.saferUrlEncode(this.containerName); String fName = super.saferUrlEncode(this.name); Representation representation = new InputRepresentation(new ByteArrayInputStream(bytes), MediaType.ALL); ClientResource client = super.put(params, representation, super.storageurl + "/" + uName + "/" + fName); this.headers = client.getResponseAttributes(); Form head = (Form) this.headers.get("org.restlet.http.headers"); return head.getFirstValue("Etag"); } else { throw new EncoderException("invalid file name"); } }
From source file:com.greenpepper.repository.FileSystemRepository.java
private Vector<Object> toHierarchyNodeVector(File file) { Vector<Object> vector = new Vector<Object>(); vector.add(0, URIUtil.relativize(root.getAbsolutePath(), file.getAbsolutePath())); vector.add(1, !file.isDirectory());/*from ww w. j av a2 s .c om*/ vector.add(2, false); Hashtable<String, Object> hashtable = new Hashtable<String, Object>(); if (file.isDirectory() && file.listFiles() != null) { File[] files = file.listFiles(NOT_HIDDEN); if (files != null) { for (File node : files) { try { hashtable.put(node.getName(), toHierarchyNodeVector(node)); } catch (Exception e) { // URI not standard skip it ! } } } } vector.add(3, hashtable); return vector; }
From source file:com.adobe.acs.commons.replication.packages.automatic.impl.ConfigurationUpdateListener.java
@Override protected ServiceRegistration registerServiceObject(Resource config, Hashtable<String, Object> props) { AutomaticPackageReplicatorModel model = new AutomaticPackageReplicatorModel(config); AutomaticPackageReplicatorJob job = new AutomaticPackageReplicatorJob(resourceResolverFactory, replicator, eventAdmin, model.getPackagePath()); ServiceRegistration serviceRegistration = null; props.put(TRIGGER_KEY, model.getTrigger().name()); if (AutomaticPackageReplicatorModel.TRIGGER.cron == model.getTrigger()) { if (StringUtils.isEmpty(model.getCronTrigger())) { throw new IllegalArgumentException("No cron trigger specified"); }/*from w ww. j a v a 2 s . c o m*/ props.put(Scheduler.PROPERTY_SCHEDULER_EXPRESSION, model.getCronTrigger()); log.debug("Registering cron runner with: {}", props); serviceRegistration = super.getBundleContext().registerService(Runnable.class.getCanonicalName(), job, props); } else { if (StringUtils.isEmpty(model.getEventTopic())) { throw new IllegalArgumentException("No event topic specified"); } props.put(EventConstants.EVENT_TOPIC, new String[] { model.getEventTopic() }); if (StringUtils.isNotEmpty(model.getEventFilter())) { props.put(EventConstants.EVENT_FILTER, model.getEventFilter()); } log.debug("Registering event handler runner with: {}", props); serviceRegistration = super.getBundleContext().registerService(EventHandler.class.getCanonicalName(), job, props); } return serviceRegistration; }
From source file:com.jaspersoft.jasperserver.export.RemoveDuplicatedDisplayName.java
private boolean hashNames(List objects) { Hashtable ht = new Hashtable(); for (int i = 0; i < objects.size(); i++) { String curDisplayName = ((Resource) objects.get(i)).getLabel(); if (!ht.containsKey(curDisplayName)) { ArrayList checkList = new ArrayList(); checkList.add(objects.get(i)); ht.put(curDisplayName, checkList); } else {/* w w w . ja v a2s . c o m*/ ((List) (ht.get(curDisplayName))).add(objects.get(i)); } } updateDuplicateNames(ht); return true; }
From source file:edu.ku.brc.specify.utilapps.CreateTextSchema.java
/** * @param tables/*from ww w . ja v a 2s. c om*/ */ @SuppressWarnings("unchecked") protected void makeTableIndexes(final Vector<DBTableInfo> tables) { po.write(" <tr>\n"); po.write(" <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("IndexName") + "</td>\n"); po.write( " <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("ColumnName") + "</td>\n"); po.write(" <td class=\"hd\" colspan=\"1\">" + UIRegistry.getResourceString("Table") + "</td>\n"); po.write(" </tr>\n"); for (DBTableInfo tn : tables) { System.out.println("Indexing " + tn.getName()); Hashtable<String, String> colToTitle = new Hashtable<String, String>(); for (DBFieldInfo fi : tn.getFields()) { colToTitle.put(fi.getColumn(), StringUtils.isNotEmpty(fi.getTitle()) ? fi.getTitle() : fi.getColumn()); } if (tn.getTableIndexMap() != null) { Vector<String> keys = new Vector<String>(tn.getTableIndexMap().keySet()); Collections.sort(keys); for (String key : keys) { String title = colToTitle.get(key); if (StringUtils.isNotEmpty(title)) { title = key; } po.write("<tr>\n"); po.write("<td align=\"center\">"); po.write(tn.getTableIndexMap().get(key)); po.write("</td>\n"); po.write("<td align=\"center\">"); po.write(key); po.write("</td>\n"); po.write("<td align=\"center\">"); //if (!tableName.equals(prevTbl)) //{ po.write(" <a href=\"#" + tn.getName() + "\">"); po.write(tn.getTitle()); po.write("</a>"); //prevTbl = tableName; //} else //{ // po.write(NBSP); //} po.write("</td>\n"); po.write("</tr>\n"); } } } }
From source file:edu.stolaf.cs.wmrserver.TransformProcessor.java
private File compile(SubnodeConfiguration languageConf, String transformTypeString, File srcTransformFile, File jobTransformDir) throws CompilationException, IOException { // Determine correct compiler, returning if none specified String compiler = languageConf.getString("compiler-" + transformTypeString, ""); if (compiler.isEmpty()) compiler = languageConf.getString("compiler", ""); if (compiler.isEmpty()) return srcTransformFile; // Determine destination filename File compiledTransformFile = new File(jobTransformDir, "compiled-job-" + transformTypeString); // Create map to replace ${wmr:...} variables. // NOTE: Commons Configuration's built-in interpolator does not work here // for some reason. File jobTempDir = getJobTempDir(); Hashtable<String, String> variableMap = new Hashtable<String, String>(); File libDir = getLibraryDirectory(languageConf); variableMap.put("wmr:lib.dir", (libDir != null) ? libDir.toString() : ""); variableMap.put("wmr:src.dir", relativizeFile(srcTransformFile.getParentFile(), jobTempDir).toString()); variableMap.put("wmr:src.file", relativizeFile(srcTransformFile, jobTempDir).toString()); variableMap.put("wmr:dest.dir", relativizeFile(jobTransformDir, jobTempDir).toString()); variableMap.put("wmr:dest.file", relativizeFile(compiledTransformFile, jobTempDir).toString()); // Replace variables in compiler string compiler = StrSubstitutor.replace(compiler, variableMap); // Run the compiler CommandLine compilerCommand = CommandLine.parse(compiler); DefaultExecutor exec = new DefaultExecutor(); ExecuteWatchdog dog = new ExecuteWatchdog(60000); // 1 minute ByteArrayOutputStream output = new ByteArrayOutputStream(); PumpStreamHandler pump = new PumpStreamHandler(output); exec.setWorkingDirectory(jobTempDir); exec.setWatchdog(dog);//from w w w .j a va2 s. c om exec.setStreamHandler(pump); exec.setExitValues(null); // Can't get the exit code if it throws exception int exitStatus = -1; try { exitStatus = exec.execute(compilerCommand); } catch (IOException ex) { // NOTE: Exit status is still -1 in this case, since exception was thrown throw new CompilationException("Compiling failed for " + transformTypeString, exitStatus, new String(output.toByteArray())); } // Check for successful exit if (exitStatus != 0) throw new CompilationException("Compiling failed for " + transformTypeString, exitStatus, new String(output.toByteArray())); // Check that output exists and is readable, and make it executable if (!compiledTransformFile.isFile()) throw new CompilationException( "Compiler did not output a " + transformTypeString + " executable (or it was not a regular file).", exitStatus, new String(output.toByteArray())); if (!compiledTransformFile.canRead()) throw new IOException(StringUtils.capitalize(transformTypeString) + " executable output from compiler was not readable: " + compiledTransformFile.toString()); if (!compiledTransformFile.canExecute()) compiledTransformFile.setExecutable(true, false); return compiledTransformFile; }
From source file:de.ub0r.android.websms.connector.sipgate.ConnectorSipgate.java
/** * {@inheritDoc}//from w ww .j a va 2 s .c om */ @Override protected final void doSend(final Context context, final Intent intent) { Log.d(TAG, "doSend()"); Object back; try { XMLRPCClient client = this.init(context); Vector<String> remoteUris = new Vector<String>(); ConnectorCommand command = new ConnectorCommand(intent); final String defPrefx = command.getDefPrefix(); String u; String[] rr = command.getRecipients(); for (String t : rr) { if (t != null && t.length() > 1) { u = "sip:" + Utils.national2international(defPrefx, Utils.getRecipientsNumber(t)) .replaceAll("\\+", "") + "@sipgate.net"; remoteUris.add(u); Log.d(TAG, "Mobile number: " + u); } } u = null; rr = null; Hashtable<String, Serializable> params = // . new Hashtable<String, Serializable>(); final String sender = Utils.getSender(context, command.getDefSender()); if (sender.length() > 6) { String localUri = "sip:" + sender.replaceAll("\\+", "") + "@sipgate.net"; params.put("LocalUri", localUri); } params.put("RemoteUri", remoteUris); params.put("TOS", "text"); params.put("Content", command.getText().replace("\n", " ")); back = client.call("samurai.SessionInitiateMulti", params); Log.d(TAG, back.toString()); } catch (XMLRPCFault e) { Log.e(TAG, null, e); if (e.getFaultCode() == HttpStatus.SC_UNAUTHORIZED) { throw new WebSMSException(context, R.string.error_pw); } throw new WebSMSException(e); } catch (XMLRPCException e) { Log.e(TAG, null, e); throw new WebSMSException(e); } }
From source file:eionet.util.Util.java
/** * A method for formatting the given timestamp into a String released_datasets.jsp. * * @param timestamp Milliseconds since 1 January 1970. *//* w w w . j a va 2 s .c o m*/ private static String releasedDate(long timestamp, boolean shortMonth) { Date date = new Date(timestamp); String year = String.valueOf(1900 + date.getYear()); String month = String.valueOf(date.getMonth()); String day = String.valueOf(date.getDate()); day = (day.length() < 2) ? ("0" + day) : day; Hashtable months = new Hashtable(); months.put("0", "January"); months.put("1", "February"); months.put("2", "March"); months.put("3", "April"); months.put("4", "May"); months.put("5", "June"); months.put("6", "July"); months.put("7", "August"); months.put("8", "September"); months.put("9", "October"); months.put("10", "November"); months.put("11", "December"); String time = day + " " + (shortMonth ? months.get(month).toString().substring(0, 3) : months.get(month)) + " " + year; return time; }