SEIntArray.java
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
00003  * All rights reserved. This program is made available under the terms of the
00004  * Eclipse Public License v1.0 which accompanies this distribution, and is
00005  * available at http://www.eclipse.org/legal/epl-v10.html
00006  * Contributors:
00007  * General Robotix Inc.
00008  * National Institute of Advanced Industrial Science and Technology (AIST) 
00009  */
00017 package com.generalrobotix.ui.view.graph;
00018 
00019 import java.util.StringTokenizer;
00020 
00021 public class SEIntArray implements StringExchangeable {
00022     Integer value_[];
00023 
00029     public SEIntArray(int size) {
00030         value_ = new Integer[size];
00031         for (int i = 0; i < size; i ++) {
00032             value_[i] = new Integer(0);
00033         }
00034     }
00035 
00041     public SEIntArray(Integer value[]) {
00042         value_ = value;
00043     }
00044 
00050     public SEIntArray(int value[]) {
00051         value_ = new Integer[value.length];
00052         for (int i = 0; i < value.length; i ++) {
00053             value_[i] = new Integer(value[i]);
00054         }
00055     }
00056 
00062     public SEIntArray(String value) {
00063         StringTokenizer tokenizer = new StringTokenizer(value);
00064         value_ = new Integer[tokenizer.countTokens()];
00065         for (int i = 0; tokenizer.hasMoreTokens(); i ++) {
00066             value_[i] = new Integer(tokenizer.nextToken());
00067         }
00068     }
00069 
00070     public int size() {
00071         if (value_ == null) { return 0; }
00072         return value_.length;
00073     }
00074 
00075 
00081     public String toString() {
00082         String str;
00083 
00084         if (value_.length == 0) return new String();
00085         str = value_[0].toString();
00086         for (int i = 1; i < value_.length; i ++) {
00087             str += " " + value_[i].toString();
00088         }
00089         return str;
00090     }
00091 
00098     public Object fromString(String str) {
00099         StringTokenizer token = new StringTokenizer(str);
00100 
00101         for (int i = 0; i < value_.length; i ++) {
00102             if (token.hasMoreTokens()) {
00103                 value_[i] = new Integer(token.nextToken());
00104             } else {
00105                 break;
00106             }
00107         }
00108         return (Object)value_;
00109     }
00110 
00116     public void setValue(Object value) {
00117         value_ = (Integer[])value;
00118     }
00119 
00125     public void setValue(String str) {
00126         StringTokenizer token = new StringTokenizer(str);
00127 
00128         for (int i = 0; i < value_.length; i ++) {
00129             if (token.hasMoreTokens()) {
00130                 value_[i] = new Integer(token.nextToken());
00131             } else {
00132                 break;
00133             }
00134         }
00135     }
00136 
00142     public Object getValue() {
00143         return (Object)value_;
00144     }
00145 };


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sun Apr 2 2017 03:43:57