Java Code Examples for java.util.Map

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 activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/.

Source file: IncludesTest.java

  28 
vote

@Test public void shouldBeAbleToIncludeParentOne2Many(){
  deleteAndPopulateTables("users","addresses");
  List<Address> addresses=Address.findAll().orderBy("id").include(User.class);
  a(addresses.get(0).toMap().get("user")).shouldNotBeNull();
  Map user=(Map)addresses.get(0).toMap().get("user");
  a(user.get("first_name")).shouldBeEqual("Marilyn");
  user=(Map)addresses.get(6).toMap().get("user");
  a(user.get("first_name")).shouldBeEqual("John");
}
 

Example 2

From project activemq-apollo, under directory /apollo-util/src/test/scala/org/apache/activemq/apollo/util/.

Source file: URISupportTest.java

  24 
vote

@Test() public void testParsingURI() throws Exception {
  URI source=new URI("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
  Map map=URISupport.parseParamters(source);
  assertEquals(("Size: " + map),2,map.size());
  assertMapKey(map,"cheese","Edam");
  assertMapKey(map,"x","123");
  URI result=URISupport.removeQuery(source);
  assertEquals("result",new URI("tcp://localhost:61626/foo/bar"),result);
}
 

Example 3

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

Source file: StudyGraph.java

  18 
vote

@SuppressWarnings("rawtypes") public void layoutGraph(){
  d_model=new JGraphModelAdapter<Vertex,Edge>(d_pm);
  d_model.setDefaultVertexAttributes(d_vertexAttributes);
  GraphLayoutCache layoutCache=new GraphLayoutCache(d_model,getCellFactory());
  removeAll();
  d_jgraph=createGraph(layoutCache);
  add(d_jgraph,BorderLayout.CENTER);
  final JGraphHierarchicalLayout layout=new JGraphHierarchicalLayout();
  final JGraphFacade facade=new JGraphFacade(d_jgraph);
  layout.run(facade);
  Map nested=facade.createNestedMap(true,true);
  d_jgraph.getGraphLayoutCache().edit(nested);
  d_jgraph.repaint();
}
 

Example 4

From project accesointeligente, under directory /src/org/accesointeligente/client/views/.

Source file: RequestEditView.java

  17 
vote

@Override public void setInstitutions(Map<String,Institution> institutions){
  this.institutions=institutions;
  for (  String name : institutions.keySet()) {
    ((MultiWordSuggestOracle)institutionSearch.getSuggestOracle()).add(name);
  }
}
 

Example 5

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

Source file: ActivityChooserModel.java

  16 
vote

public void sort(Intent intent,List<ActivityResolveInfo> activities,List<HistoricalRecord> historicalRecords){
  Map<String,ActivityResolveInfo> packageNameToActivityMap=mPackageNameToActivityMap;
  packageNameToActivityMap.clear();
  final int activityCount=activities.size();
  for (int i=0; i < activityCount; i++) {
    ActivityResolveInfo activity=activities.get(i);
    activity.weight=0.0f;
    String packageName=activity.resolveInfo.activityInfo.packageName;
    packageNameToActivityMap.put(packageName,activity);
  }
  final int lastShareIndex=historicalRecords.size() - 1;
  float nextRecordWeight=1;
  for (int i=lastShareIndex; i >= 0; i--) {
    HistoricalRecord historicalRecord=historicalRecords.get(i);
    String packageName=historicalRecord.activity.getPackageName();
    ActivityResolveInfo activity=packageNameToActivityMap.get(packageName);
    if (activity != null) {
      activity.weight+=historicalRecord.weight * nextRecordWeight;
      nextRecordWeight=nextRecordWeight * WEIGHT_DECAY_COEFFICIENT;
    }
  }
  Collections.sort(activities);
  if (DEBUG) {
    for (int i=0; i < activityCount; i++) {
      Log.i(LOG_TAG,"Sorted: " + activities.get(i));
    }
  }
}
 

Example 6

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

Source file: AbstractGenerator.java

  16 
vote

public Map<String,Object> createArguments(){
  Map<String,Object> args=new TreeMap<String,Object>();
  Calendar calendar=Calendar.getInstance();
  args.put("year",calendar.get(Calendar.YEAR));
  DateFormat formatter=new SimpleDateFormat("MMMM d, yyyy, HH:mm:ss",Locale.US);
  args.put("datetime",formatter.format(new Date()));
  formatter=new SimpleDateFormat("MMMM d, yyyy",Locale.US);
  args.put("date",formatter.format(new Date()));
  return args;
}
 

Example 7

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

  16 
vote

/** 
 * This is for implementing  {@link IEditorPart} and simply saves the model file.<!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSave(IProgressMonitor progressMonitor){
  final Map<Object,Object> saveOptions=new HashMap<Object,Object>();
  saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
  WorkspaceModifyOperation operation=new WorkspaceModifyOperation(){
    @Override public void execute(    IProgressMonitor monitor){
      boolean first=true;
      for (      Resource resource : editingDomain.getResourceSet().getResources()) {
        if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
          try {
            long timeStamp=resource.getTimeStamp();
            resource.save(saveOptions);
            if (resource.getTimeStamp() != timeStamp) {
              savedResources.add(resource);
            }
          }
 catch (          Exception exception) {
            resourceToDiagnosticMap.put(resource,analyzeResourceProblems(resource,exception));
          }
          first=false;
        }
      }
    }
  }
;
  updateProblemIndication=false;
  try {
    new ProgressMonitorDialog(getSite().getShell()).run(true,false,operation);
    ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
    firePropertyChange(IEditorPart.PROP_DIRTY);
  }
 catch (  Exception exception) {
    WebappEditorPlugin.INSTANCE.log(exception);
  }
  updateProblemIndication=true;
  updateProblemIndication();
}
 

Example 8

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

Source file: ACEEditor.java

  16 
vote

/** 
 * Creates a new ACE Editor application.
 * @param parameters A set of parameters in the form of name/value pairs.
 */
public ACEEditor(Map<String,String> parameters){
  setTitle("ACE Editor");
  this.parameters=parameters;
  lexiconHandler=new LexiconHandler(parameters.get("lexicon"));
  SplitPane splitPane=new SplitPane(SplitPane.ORIENTATION_VERTICAL);
  splitPane.setSeparatorPosition(new Extent(23));
  menuBar=new MenuBar(this);
  menuBar.setSelected("Default Expanded",true);
  menuBar.setSelected("Default Paraphrase",true);
  menuBar.setSelected("Default Syntax Boxes",true);
  menuBar.setSelected("Default Pretty-Printed DRS",true);
  menuBar.setEnabled("Paste",false);
  splitPane.add(menuBar.getContent());
  textColumn.setInsets(new Insets(0,5));
  textColumn.add(finalEntry);
  mainColumn.add(textColumn);
  splitPane.add(mainColumn);
  getContent().add(splitPane);
  select(finalEntry);
}
 

Example 9

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

Source file: TicketDatabaseManager.java

  15 
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 10

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

Source file: AntlibTypeLoader.java

  15 
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 11

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

  15 
vote

/** 
 * This is for implementing  {@link IEditorPart} and simply saves the model file.<!-- begin-user-doc --> <!-- end-user-doc -->
 * @generated
 */
@Override public void doSave(IProgressMonitor progressMonitor){
  final Map<Object,Object> saveOptions=new HashMap<Object,Object>();
  saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED,Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
  WorkspaceModifyOperation operation=new WorkspaceModifyOperation(){
    @Override public void execute(    IProgressMonitor monitor){
      boolean first=true;
      for (      Resource resource : editingDomain.getResourceSet().getResources()) {
        if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
          try {
            long timeStamp=resource.getTimeStamp();
            resource.save(saveOptions);
            if (resource.getTimeStamp() != timeStamp) {
              savedResources.add(resource);
            }
          }
 catch (          Exception exception) {
            resourceToDiagnosticMap.put(resource,analyzeResourceProblems(resource,exception));
          }
          first=false;
        }
      }
    }
  }
;
  updateProblemIndication=false;
  try {
    new ProgressMonitorDialog(getSite().getShell()).run(true,false,operation);
    ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
    firePropertyChange(IEditorPart.PROP_DIRTY);
  }
 catch (  Exception exception) {
    ScalaEditorPlugin.INSTANCE.log(exception);
  }
  updateProblemIndication=true;
  updateProblemIndication();
}
 

Example 12

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

Source file: XYChart.java

  15 
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 13

From project action-core, under directory /src/main/java/com/ning/metrics/action/hdfs/data/parser/.

Source file: SmileRowSerializer.java

  15 
vote

public static void eventToRow(Registrar r,SmileEnvelopeEventDeserializer deserializer,Rows rows){
  final SmileEnvelopeEvent event;
  try {
    event=deserializer.getNextEvent();
  }
 catch (  IOException e) {
    throw new RowAccessException(e);
  }
  final JsonNode node=(JsonNode)event.getData();
  final Map<Short,GoodwillSchemaField> schema=r.getSchema(event.getName());
  final List<ColumnKey> columnKeyList=new ArrayList<ColumnKey>(node.size());
  final List<JsonNodeComparable> data=new ArrayList<JsonNodeComparable>(node.size());
  if (schema == null) {
    final Iterator<String> nodeFieldNames=node.fieldNames();
    while (nodeFieldNames.hasNext()) {
      columnKeyList.add(new DynamicColumnKey(nodeFieldNames.next()));
    }
    final Iterator<JsonNode> nodeElements=node.elements();
    while (nodeElements.hasNext()) {
      JsonNode next=nodeElements.next();
      if (next == null) {
        next=NullNode.getInstance();
      }
      data.add(new JsonNodeComparable(next));
    }
  }
 else {
    for (    final GoodwillSchemaField schemaField : schema.values()) {
      final String schemaFieldName=schemaField.getName();
      columnKeyList.add(new DynamicColumnKey(schemaFieldName));
      JsonNode delegate=node.get(schemaFieldName);
      if (delegate == null) {
        delegate=NullNode.getInstance();
      }
      data.add(new JsonNodeComparable(delegate));
    }
  }
  rows.add(RowFactory.getRow(new RowSchema(event.getName(),columnKeyList),data));
}
 

Example 14

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

Source file: ActivityChooserModel.java

  15 
vote

public void sort(Intent intent,List<ActivityResolveInfo> activities,List<HistoricalRecord> historicalRecords){
  Map<String,ActivityResolveInfo> packageNameToActivityMap=mPackageNameToActivityMap;
  packageNameToActivityMap.clear();
  final int activityCount=activities.size();
  for (int i=0; i < activityCount; i++) {
    ActivityResolveInfo activity=activities.get(i);
    activity.weight=0.0f;
    String packageName=activity.resolveInfo.activityInfo.packageName;
    packageNameToActivityMap.put(packageName,activity);
  }
  final int lastShareIndex=historicalRecords.size() - 1;
  float nextRecordWeight=1;
  for (int i=lastShareIndex; i >= 0; i--) {
    HistoricalRecord historicalRecord=historicalRecords.get(i);
    String packageName=historicalRecord.activity.getPackageName();
    ActivityResolveInfo activity=packageNameToActivityMap.get(packageName);
    if (activity != null) {
      activity.weight+=historicalRecord.weight * nextRecordWeight;
      nextRecordWeight=nextRecordWeight * WEIGHT_DECAY_COEFFICIENT;
    }
  }
  Collections.sort(activities);
  if (DEBUG) {
    for (int i=0; i < activityCount; i++) {
      Log.i(LOG_TAG,"Sorted: " + activities.get(i));
    }
  }
}
 

Example 15

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

Source file: BoundaryErrorEventTest.java

  15 
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 16

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

Source file: EnumFormPropertyRenderer.java

  15 
vote

@SuppressWarnings("unchecked") @Override public Field getPropertyField(FormProperty formProperty){
  ComboBox comboBox=new ComboBox(getPropertyLabel(formProperty));
  comboBox.setRequired(formProperty.isRequired());
  comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED,getPropertyLabel(formProperty)));
  comboBox.setEnabled(formProperty.isWritable());
  Map<String,String> values=(Map<String,String>)formProperty.getType().getInformation("values");
  if (values != null) {
    for (    Entry<String,String> enumEntry : values.entrySet()) {
      comboBox.addItem(enumEntry.getKey());
      if (enumEntry.getValue() != null) {
        comboBox.setItemCaption(enumEntry.getKey(),enumEntry.getValue());
      }
    }
  }
  return comboBox;
}
 

Example 17

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

Source file: Definitions.java

  15 
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 18

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

Source file: ActionExecutionPut.java

  15 
vote

@Override protected void execute(ActivitiRequest req,Status status,Cache cache,Map<String,Object> model){
  String connectorId=req.getMandatoryString("connectorId");
  String artifactId=req.getMandatoryString("artifactId");
  String actionId=req.getMandatoryString("actionName");
  Map<String,Object> parameters=req.getFormVariables();
  try {
    repositoryService.executeParameterizedAction(connectorId,artifactId,actionId,parameters);
    model.put("result",true);
  }
 catch (  Exception e) {
    model.put("result",false);
    throw new RuntimeException(e);
  }
}
 

Example 19

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

Source file: BackendMessageDecoder.java

  15 
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);
}