MATSIM
Matrices.java
Go to the documentation of this file.
1 /* *********************************************************************** *
2  * project: org.matsim.*
3  * Matrices.java
4  * *
5  * *********************************************************************** *
6  * *
7  * copyright : (C) 2007 by the members listed in the COPYING, *
8  * LICENSE and WARRANTY file. *
9  * email : info at matsim dot org *
10  * *
11  * *********************************************************************** *
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * See also COPYING, LICENSE and WARRANTY file *
18  * *
19  * *********************************************************************** */
20 
21 package org.matsim.matrices;
22 
23 import java.util.TreeMap;
24 
25 public class Matrices {
26 
28  // member variables
30 
31  private String name = null;
32  private final TreeMap<String, Matrix> matrices = new TreeMap<String, Matrix>();
33 
35  // create methods
37 
38  public final Matrix createMatrix(final String id, final String desc) {
39  // check id string for uniqueness
40  if (this.matrices.containsKey(id)) {
41  throw new RuntimeException("[id="+id+" already exists.]");
42  }
43  // create the matrix
44  Matrix m = new Matrix(id, desc);
45  this.matrices.put(id,m);
46  return m;
47  }
48 
50  // set methods
52 
53  protected final void setName(final String name) {
54  this.name = name;
55  }
56 
58  // get methods
60 
61  public final String getName() {
62  return this.name;
63  }
64 
65  public final TreeMap<String, Matrix> getMatrices() {
66  return this.matrices;
67  }
68 
69  public final Matrix getMatrix(final String id) {
70  return this.matrices.get(id);
71  }
72 
74  // print methods
76 
77  @Override
78  public final String toString() {
79  return "[name=" + this.name + "]" +
80  "[nof_matrices=" + this.matrices.size() + "]";
81  }
82 
83 }
final TreeMap< String, Matrix > matrices
Definition: Matrices.java:32
final void setName(final String name)
Definition: Matrices.java:53
final TreeMap< String, Matrix > getMatrices()
Definition: Matrices.java:65
final Matrix getMatrix(final String id)
Definition: Matrices.java:69
final Matrix createMatrix(final String id, final String desc)
Definition: Matrices.java:38