SEEnumeration.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
17 package com.generalrobotix.ui.view.graph;
18 
19 import java.util.StringTokenizer;
20 
21 public class SEEnumeration implements StringExchangeable {
22  String[] item_;
23  int selection_;
24 
25  public SEEnumeration(String[] s, int selection) {
26  item_ = s;
27  selection_ = selection;
28  }
29 
33  public SEEnumeration(String str) {
34  StringTokenizer tokenizer = new StringTokenizer(str, ",");
35  item_ = new String[tokenizer.countTokens()];
36  for (int i = 0; tokenizer.hasMoreTokens(); i ++) {
37  item_[i] = tokenizer.nextToken();
38  }
39  selection_ = 0;
40  }
41 
47  public String toString() {
48  return item_[selection_];
49  }
50 
57  public Object fromString(String str) {
58  if (str == null) {
59  selection_ = 0;
60  return item_[selection_];
61  }
62 
63  for(int i =0; i < item_.length; i ++) {
64  if (str.equals(item_[i])) {
65  selection_ = i;
66  break;
67  }
68  }
69  return item_[selection_];
70  }
71 
78  public void setValue(Object value) {
79  fromString((String)value);
80  }
81 
87  public void setValue(String str) {
88  fromString((String)str);
89  }
90 
96  public Object getValue() {
97  return item_[selection_];
98  }
99 
105  public String[] getSelectionNames() {
106  return item_;
107  }
113  public int getSelectedIndex() {
114  return selection_;
115  }
116 }
#define null
our own NULL pointer
Definition: IceTypes.h:57
png_voidp int value
Definition: png.h:2113
png_uint_32 i
Definition: png.h:2735


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:41