Java Code Examples for java.util.HashMap

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project activemq-apollo, under directory /apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/transport/.

Source file: TcpTransportFactory.java

  50 
vote

public TransportServer bind(String location) throws Exception {
  URI uri=new URI(location);
  Map<String,String> options=new HashMap<String,String>(URISupport.parseParamters(uri));
  TcpTransportServer server=createTcpTransportServer(uri,options);
  if (server == null)   return null;
  Map<String,String> copy=new HashMap<String,String>(options);
  IntrospectionSupport.setProperties(server,new HashMap(options));
  return server;
}
 

Example 2

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Manager/.

Source file: TicketDatabaseManager.java

  39 
vote

public Map<String,List<Ticket>> checkTickets(Player[] onlinePlayer){
  try {
    ResultSet rs=dbConnection.getConnection().createStatement().executeQuery(createTicketQuery(onlinePlayer));
    Map<String,List<Ticket>> tickets=new HashMap<String,List<Ticket>>(onlinePlayer.length);
    List<Ticket> list=null;
    while (rs.next()) {
      String userName=rs.getString(1);
      list=tickets.get(userName);
      if (list == null)       list=new LinkedList<Ticket>();
      list.add(new Ticket(rs.getBoolean(2),rs.getBoolean(3),rs.getInt(4)));
      tickets.put(userName,list);
    }
    return tickets;
  }
 catch (  Exception e) {
    ConsoleUtils.printException(e,Core.NAME,"Can't check tickets");
    return null;
  }
}
 

Example 3

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/.

Source file: ActionBarSherlockCompat.java

  34 
vote

@Override public boolean dispatchPrepareOptionsMenu(android.view.Menu menu){
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] android.view.Menu: " + menu);
  if (mActionMode != null) {
    return false;
  }
  mMenuIsPrepared=false;
  if (!preparePanel()) {
    return false;
  }
  if (isReservingOverflow()) {
    return false;
  }
  if (mNativeItemMap == null) {
    mNativeItemMap=new HashMap<android.view.MenuItem,MenuItemImpl>();
  }
 else {
    mNativeItemMap.clear();
  }
  if (mMenu == null) {
    return false;
  }
  boolean result=mMenu.bindNativeOverflow(menu,this,mNativeItemMap);
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] returning " + result);
  return result;
}
 

Example 4

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: Utils.java

  34 
vote

/** 
 * Creates a thread pool not queued with max number of threads defined in properties or DEF_MAX_POOLED_THREAD = 20
 * @param properties where property THREADSINPOOL gives max threads Note if THREADSINPOOL not integers, or negative then DEF_MAX_POOLED_THREAD used
 * @param threadfactory threadfactory to use
 */
public ThreadPool(Properties properties,ThreadFactory threadfactory){
  try {
    maxThreads=Integer.parseInt(properties.getProperty(MAXNOTHREAD));
    if (maxThreads < 0)     maxThreads=DEF_MAX_POOLED_THREAD;
  }
 catch (  Exception e) {
    maxThreads=DEF_MAX_POOLED_THREAD;
  }
  freeThreads=new ArrayList<PooledThread>(maxThreads);
  busyThreads=new HashMap<PooledThread,PooledThread>(maxThreads);
  this.threadFactory=threadfactory;
}
 

Example 5

From project accounted4, under directory /accounted4/stock-quote/stock-quote-yahoo/src/main/java/com/accounted4/stockquote/yahoo/.

Source file: YahooQuoteService.java

  34 
vote

@Override public List<HashMap<QuoteAttribute,String>> executeQuery(List<String> securityList,List<QuoteAttribute> quoteAttributes){
  String tickerList=securityListToString(securityList);
  String attributeList=attributeListToString(quoteAttributes);
  HttpClient httpclient=new DefaultHttpClient();
  String urlString=BASE_URL + "?" + "s="+ tickerList+ "&"+ "f="+ attributeList;
  System.out.println("Query url: " + urlString);
  HttpGet httpGet=new HttpGet(urlString);
  try {
    HttpResponse response=httpclient.execute(httpGet);
    HttpEntity entity=response.getEntity();
    if (entity != null) {
      String stringResponse=EntityUtils.toString(entity);
      return processResponse(stringResponse,quoteAttributes);
    }
  }
 catch (  IOException ex) {
    System.out.println("Error " + ex);
  }
  List<HashMap<QuoteAttribute,String>> result=new ArrayList<>();
  return result;
}
 

Example 6

From project activejdbc, under directory /activejdbc/src/main/java/org/javalite/activejdbc/.

Source file: RowProcessor.java

  34 
vote

protected void processRS(RowListener listener) throws SQLException {
  ResultSetMetaData metaData=rs.getMetaData();
  String labels[]=new String[metaData.getColumnCount()];
  for (int i=1; i <= labels.length; i++) {
    labels[i - 1]=metaData.getColumnLabel(i);
  }
  while (rs.next()) {
    HashMap<String,Object> row=new HashMap<String,Object>();
    for (    String label : labels) {
      row.put(label.toLowerCase(),rs.getObject(label));
    }
    if (!listener.next(row))     break;
  }
  rs.close();
  s.close();
}
 

Example 7

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/cache/.

Source file: TrieBasedUserCache.java

  34 
vote

public synchronized void loadUsers(){
  long nrOfUsers=identityService.createUserQuery().count();
  long usersAdded=0;
  userTrie=(RadixTree<List<User>>)ClojureBridge.createEmptyRadixTree();
  userCache=new HashMap<String,User>();
  keyCache=new HashMap<String,List<String>>();
  while (usersAdded < nrOfUsers) {
    if (LOGGER.isLoggable(Level.INFO)) {
      LOGGER.info("Caching users " + usersAdded + " to "+ (usersAdded + 25));
    }
    List<User> users=identityService.createUserQuery().listPage((int)usersAdded,25);
    for (    User user : users) {
      addTrieItem(user);
      addUserCacheItem(user);
      usersAdded++;
    }
  }
}
 

Example 8

From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/bpmn20/model/.

Source file: Definitions.java

  34 
vote

/** 
 * The namespaces property contains an arbitrary set of namespace prefixes their related URLs referenced inside the diagram.
 * @return the namespaces property. always non-null
 */
public Map<String,String> getNamespaces(){
  if (this.namespaces == null) {
    this.namespaces=new HashMap<String,String>();
  }
  return namespaces;
}
 

Example 9

From project addis, under directory /application/src/main/java/org/drugis/addis/entities/analysis/.

Source file: MetaBenefitRiskAnalysis.java

  34 
vote

public MetaBenefitRiskAnalysis(String name,Indication indication,List<MetaAnalysis> metaAnalyses,TreatmentDefinition baseline,List<TreatmentDefinition> alternatives,AnalysisType analysisType,DecisionContext context){
  super(name);
  d_indication=indication;
  d_metaAnalyses=metaAnalyses;
  d_alternatives=new SortedSetModel<TreatmentDefinition>(alternatives);
  d_baseline=baseline;
  d_alternatives.add(baseline);
  d_baselineModelMap=new HashMap<OutcomeMeasure,MCMCModelWrapper>();
  d_analysisType=analysisType;
  if (d_analysisType == AnalysisType.LyndOBrien && (d_metaAnalyses.size() != 2 || d_alternatives.size() != 2)) {
    throw new IllegalArgumentException("Attempt to create Lynd & O'Brien analysis with not exactly 2 criteria and 2 alternatives");
  }
  d_decisionContext=context;
  for (  MetaAnalysis ma : d_metaAnalyses) {
    double[][] transformation=createTransform(ma);
    d_relativeEffects.put(ma,new TransformedMultivariateNormalSummary(ma.getRelativeEffectsSummary(),transformation));
  }
}
 

Example 10

From project AdminCmd, under directory /src/main/java/be/Balor/bukkit/AdminCmd/.

Source file: ACHelper.java

  34 
vote

/** 
 * Add an item to the Command BlackList
 * @param name
 * @return
 */
public boolean addBlackListedBlock(final CommandSender sender,final String name){
  final MaterialContainer m=checkMaterial(sender,name);
  if (!m.isNull()) {
    final ExtendedConfiguration config=fManager.getYml("blacklist");
    List<Integer> list=config.getIntList("BlackListedBlocks",null);
    if (list == null) {
      list=new ArrayList<Integer>();
    }
    list.add(m.getMaterial().getId());
    config.set("BlackListedBlocks",list);
    try {
      config.save();
    }
 catch (    final IOException e) {
    }
    if (blockBlacklist == null) {
      blockBlacklist=new ArrayList<Integer>();
    }
    blockBlacklist.add(m.getMaterial().getId());
    final HashMap<String,String> replace=new HashMap<String,String>();
    replace.put("material",m.getMaterial().toString());
    Utils.sI18n(sender,"addBlacklistBlock",replace);
    return true;
  }
  return false;
}
 

Example 11

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/.

Source file: ActionBarSherlockCompat.java

  33 
vote

@Override public boolean dispatchPrepareOptionsMenu(android.view.Menu menu){
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] android.view.Menu: " + menu);
  mMenuIsPrepared=false;
  if (!preparePanel()) {
    return false;
  }
  if (isReservingOverflow()) {
    return false;
  }
  if (mNativeItemMap == null) {
    mNativeItemMap=new HashMap<android.view.MenuItem,MenuItemImpl>();
  }
 else {
    mNativeItemMap.clear();
  }
  if (mMenu == null) {
    return false;
  }
  boolean result=mMenu.bindNativeOverflow(menu,this,mNativeItemMap);
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] returning " + result);
  return result;
}
 

Example 12

From project Aardvark, under directory /aardvark-core/src/main/java/gw/vark/typeloader/.

Source file: AntlibTypeLoader.java

  33 
vote

@Override protected HashMap<String,IType> init(){
  HashMap<String,String> antlibs=new HashMap<String,String>();
  for (  Pair<String,IFile> pair : TypeSystem.getExecutionEnvironment().getCurrentModule().getFileRepository().findAllFilesByExtension("antlib")) {
    IFile file=pair.getSecond();
    antlibs.put(file.getBaseName(),readFile(file).trim());
  }
  antlibs.put(ANT_ANTLIB_SYMBOL,ANT_ANTLIB_RESOURCE);
  HashMap<String,IType> types=new HashMap<String,IType>();
  for (  Map.Entry<String,String> entry : antlibs.entrySet()) {
    String antlibName=entry.getKey();
    String antlibResource=entry.getValue();
    log("loading antlib " + antlibName + " ("+ antlibResource+ ")",Project.MSG_VERBOSE);
    String typeName=GW_VARK_TASKS_PACKAGE + antlibName;
    types.put(typeName,TypeSystem.getOrCreateTypeReference(new AntlibType(typeName,antlibResource,AntlibTypeLoader.this)));
  }
  return types;
}
 

Example 13

From project acceleo-modules, under directory /psm-gen-scala/plugins/com.github.sbegaudeau.acceleo.modules.psm.gen.scala.editor/src-gen/com/github/sbegaudeau/acceleo/modules/psm/gen/scala/model/scala/presentation/.

Source file: ScalaEditor.java

  33 
vote

/** 
 * This sets up the editing domain for the model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void initializeEditingDomain(){
  adapterFactory=new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
  adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
  adapterFactory.addAdapterFactory(new ScalaItemProviderAdapterFactory());
  adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
  BasicCommandStack commandStack=new BasicCommandStack();
  commandStack.addCommandStackListener(new CommandStackListener(){
    public void commandStackChanged(    final EventObject event){
      getContainer().getDisplay().asyncExec(new Runnable(){
        public void run(){
          firePropertyChange(IEditorPart.PROP_DIRTY);
          Command mostRecentCommand=((CommandStack)event.getSource()).getMostRecentCommand();
          if (mostRecentCommand != null) {
            setSelectionToViewer(mostRecentCommand.getAffectedObjects());
          }
          if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
            propertySheetPage.refresh();
          }
        }
      }
);
    }
  }
);
  editingDomain=new AdapterFactoryEditingDomain(adapterFactory,commandStack,new HashMap<Resource,Boolean>());
}
 

Example 14

From project acceleo-webapp-generator, under directory /plugins/org.eclipse.acceleo.tutorial.webapp.editor/src-gen/org/eclipse/acceleo/tutorial/webapp/presentation/.

Source file: WebappEditor.java

  33 
vote

/** 
 * This sets up the editing domain for the model editor. <!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
protected void initializeEditingDomain(){
  adapterFactory=new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
  adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
  adapterFactory.addAdapterFactory(new WebappItemProviderAdapterFactory());
  adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
  BasicCommandStack commandStack=new BasicCommandStack();
  commandStack.addCommandStackListener(new CommandStackListener(){
    public void commandStackChanged(    final EventObject event){
      getContainer().getDisplay().asyncExec(new Runnable(){
        public void run(){
          firePropertyChange(IEditorPart.PROP_DIRTY);
          Command mostRecentCommand=((CommandStack)event.getSource()).getMostRecentCommand();
          if (mostRecentCommand != null) {
            setSelectionToViewer(mostRecentCommand.getAffectedObjects());
          }
          if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
            propertySheetPage.refresh();
          }
        }
      }
);
    }
  }
);
  editingDomain=new AdapterFactoryEditingDomain(adapterFactory,commandStack,new HashMap<Resource,Boolean>());
}
 

Example 15

From project accent, under directory /src/test/java/net/lshift/accent/.

Source file: ControlledConnectionProxy.java

  33 
vote

public DirectionHandler(BlockingCell<Exception> waitCell,boolean inBound,DataInputStream inStream,DataOutputStream outStream){
  this.waitCell=waitCell;
  this.inStream=inStream;
  this.outStream=outStream;
  this.assemblers=new HashMap<Integer,AMQCommand.Assembler>();
}
 

Example 16

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.

Source file: ACEEditorMenuCreator.java

  33 
vote

public List<SpecialMenuItem> createSpecialMenuItems(NextTokenOptions options){
  List<SpecialMenuItem> items=new ArrayList<SpecialMenuItem>();
  Map<String,String> m=new HashMap<String,String>();
  for (  String s : extCats) {
    if (options.containsCategory(s)) {
      String menuGroup=cats.get(s);
      if (m.containsKey(menuGroup)) {
        m.put(menuGroup,m.get(menuGroup) + s + ":");
      }
 else {
        m.put(menuGroup,"new:" + s + ":");
      }
    }
  }
  if (!editor.isLexiconImmutable()) {
    for (    String menuGroup : m.keySet()) {
      items.add(new SpecialMenuItem("new...",menuGroup,m.get(menuGroup),this));
    }
  }
  return items;
}
 

Example 17

From project AChartEngine, under directory /achartengine/src/org/achartengine/chart/.

Source file: XYChart.java

  33 
vote

protected Map<Integer,List<Double>> getYLabels(double[] minY,double[] maxY,int maxScaleNumber){
  Map<Integer,List<Double>> allYLabels=new HashMap<Integer,List<Double>>();
  for (int i=0; i < maxScaleNumber; i++) {
    allYLabels.put(i,getValidLabels(MathHelper.getLabels(minY[i],maxY[i],mRenderer.getYLabels())));
  }
  return allYLabels;
}
 

Example 18

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/.

Source file: ActionBarSherlockCompat.java

  33 
vote

@Override public boolean dispatchPrepareOptionsMenu(android.view.Menu menu){
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] android.view.Menu: " + menu);
  if (mActionMode != null) {
    return false;
  }
  mMenuIsPrepared=false;
  if (!preparePanel()) {
    return false;
  }
  if (isReservingOverflow()) {
    return false;
  }
  if (mNativeItemMap == null) {
    mNativeItemMap=new HashMap<android.view.MenuItem,MenuItemImpl>();
  }
 else {
    mNativeItemMap.clear();
  }
  if (mMenu == null) {
    return false;
  }
  boolean result=mMenu.bindNativeOverflow(menu,this,mNativeItemMap);
  if (DEBUG)   Log.d(TAG,"[dispatchPrepareOptionsMenu] returning " + result);
  return result;
}
 

Example 19

From project activiti, under directory /src/activiti-examples/org/activiti/examples/bpmn/event/error/.

Source file: BoundaryErrorEventTest.java

  33 
vote

@Deployment(resources={"org/activiti/examples/bpmn/event/error/reviewSalesLead.bpmn20.xml"}) @Test public void testReviewSalesLeadProcess(){
  Map<String,Object> variables=new HashMap<String,Object>();
  variables.put("initiator","kermit");
  RuntimeService runtimeService=activitiRule.getRuntimeService();
  String procId=runtimeService.startProcessInstanceByKey("reviewSaledLead").getId();
  TaskService taskService=activitiRule.getTaskService();
  Task task=taskService.createTaskQuery().taskAssignee("kermit").singleResult();
  assertEquals("Provide new sales lead",task.getName());
  taskService.complete(task.getId());
  Task ratingTask=taskService.createTaskQuery().taskCandidateGroup("accountancy").singleResult();
  assertEquals("Review customer rating",ratingTask.getName());
  Task profitabilityTask=taskService.createTaskQuery().taskCandidateGroup("management").singleResult();
  assertEquals("Review profitability",profitabilityTask.getName());
  variables=new HashMap<String,Object>();
  variables.put("notEnoughInformation",true);
  taskService.complete(profitabilityTask.getId(),variables);
  Task provideDetailsTask=taskService.createTaskQuery().taskAssignee("kermit").singleResult();
  assertEquals("Provide additional details",provideDetailsTask.getName());
  taskService.complete(provideDetailsTask.getId());
  List<Task> reviewTasks=taskService.createTaskQuery().orderByTaskName().asc().list();
  assertEquals("Review customer rating",reviewTasks.get(0).getName());
  assertEquals("Review profitability",reviewTasks.get(1).getName());
  taskService.complete(reviewTasks.get(0).getId());
  variables.put("notEnoughInformation",false);
  taskService.complete(reviewTasks.get(1).getId(),variables);
  assertNull("Process ended",activitiRule.getRuntimeService().createProcessInstanceQuery().processInstanceId(procId).singleResult());
}
 

Example 20

From project activiti-webapp-rest-generic, under directory /activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/session/.

Source file: HttpSessionContext.java

  33 
vote

public Map<String,Object> getValues(){
  HashMap<String,Object> result=new HashMap<String,Object>();
  for (@SuppressWarnings("unchecked") Enumeration<String> e=session.getAttributeNames(); e.hasMoreElements(); ) {
    String key=e.nextElement();
    result.put(key,session.getAttribute(key));
  }
  return result;
}
 

Example 21

From project adbcj, under directory /postgresql/codec/src/main/java/org/adbcj/postgresql/codec/backend/.

Source file: BackendMessageDecoder.java

  33 
vote

private AbstractBackendMessage decodeError(DecoderInputStream input) throws IOException {
  Map<ErrorField,String> fields=new HashMap<ErrorField,String>();
  for (; ; ) {
    byte token=input.readByte();
    if (token == 0) {
      break;
    }
    ErrorField field=ErrorField.toErrorField(token);
    String value=input.readString(connectionState.getBackendCharset());
    if (field == null) {
      logger.warn("Unrecognized error field of type '{}' with the value '{}'",(char)token,value);
    }
 else {
      fields.put(field,value);
    }
  }
  return new ErrorResponseMessage(fields);
}