SEIntArray.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 SEIntArray implements StringExchangeable {
22  Integer value_[];
23 
29  public SEIntArray(int size) {
30  value_ = new Integer[size];
31  for (int i = 0; i < size; i ++) {
32  value_[i] = new Integer(0);
33  }
34  }
35 
41  public SEIntArray(Integer value[]) {
42  value_ = value;
43  }
44 
50  public SEIntArray(int value[]) {
51  value_ = new Integer[value.length];
52  for (int i = 0; i < value.length; i ++) {
53  value_[i] = new Integer(value[i]);
54  }
55  }
56 
62  public SEIntArray(String value) {
63  StringTokenizer tokenizer = new StringTokenizer(value);
64  value_ = new Integer[tokenizer.countTokens()];
65  for (int i = 0; tokenizer.hasMoreTokens(); i ++) {
66  value_[i] = new Integer(tokenizer.nextToken());
67  }
68  }
69 
70  public int size() {
71  if (value_ == null) { return 0; }
72  return value_.length;
73  }
74 
75 
81  public String toString() {
82  String str;
83 
84  if (value_.length == 0) return new String();
85  str = value_[0].toString();
86  for (int i = 1; i < value_.length; i ++) {
87  str += " " + value_[i].toString();
88  }
89  return str;
90  }
91 
98  public Object fromString(String str) {
99  StringTokenizer token = new StringTokenizer(str);
100 
101  for (int i = 0; i < value_.length; i ++) {
102  if (token.hasMoreTokens()) {
103  value_[i] = new Integer(token.nextToken());
104  } else {
105  break;
106  }
107  }
108  return (Object)value_;
109  }
110 
116  public void setValue(Object value) {
117  value_ = (Integer[])value;
118  }
119 
125  public void setValue(String str) {
126  StringTokenizer token = new StringTokenizer(str);
127 
128  for (int i = 0; i < value_.length; i ++) {
129  if (token.hasMoreTokens()) {
130  value_[i] = new Integer(token.nextToken());
131  } else {
132  break;
133  }
134  }
135  }
136 
142  public Object getValue() {
143  return (Object)value_;
144  }
145 };
#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 Thu Sep 8 2022 02:24:05