View Javadoc

1   /*
2    * Copyright 2010 Fraunhofer Gesellschaft, Munich, Germany,
3    * for its Fraunhofer Institute for Computer Architecture and Software
4    * Technology (FIRST), Berlin, Germany. All rights reserved.
5    * http://www.first.fraunhofer.de/
6    */
7   
8   package net.kwfgrid.gwes;
9   
10  import java.util.HashMap;
11  
12  /**
13   * @author Andreas Hoheisel
14   *         (<a href="http://www.andreas-hoheisel.de">www.andreas-hoheisel.de</a>)
15   * @version $Id: ActivityDescription.java 1419 2010-11-01 14:12:17Z hoheisel $
16   * @deprecated Information for activities is now available through the TransitionOccurrence object.
17   */
18  public class ActivityDescription extends HashMap<String,String> {
19  
20      public static final String KEY_RESOURCE = "resourceName";
21      public static final String KEY_OPERATION = "operationName";
22  
23      public ActivityDescription(String resourceName, String operationName) {
24          super();
25          this.put(KEY_RESOURCE,resourceName);
26          this.put(KEY_OPERATION,operationName);
27      }
28  
29      /**
30       * Returns a string representation of this ActivityDescription.
31       *
32       * @return a String representation of this ActivityDescription.
33       */
34      @Override
35      public String toString() {
36          StringBuffer buffer = new StringBuffer();
37          for (String key:keySet()) {
38              buffer.append(key).append("=").append(get(key)).append("\n");
39          }
40          return buffer.toString();
41      }
42  
43      public String[] toStringArray() {
44          int size = size();
45          String[] strarr = new String[size];
46          StringBuffer buffer = new StringBuffer();
47          int i=0;
48          for (String key:keySet()) {
49              if (i>=size) break;
50              strarr[i++] = buffer.append(key).append("=").append(get(key)).toString();
51          }
52          return strarr;
53      }
54  
55      /**
56       * Returns the long value of a property.
57       * @param key The name of the property.
58       * @return The long value or "-1" if property is not available.
59       * @throws NumberFormatException
60       */
61      public long getPositiveLong(String key) throws NumberFormatException {
62          String str = get(key);
63          return (str == null? -1 : Long.parseLong(str));
64      }
65      
66  }