blob: f70aee5089e502cddee936760b6bb7a9dee4f8e0 [file] [log] [blame]
Jason Sams36e612a2009-07-31 16:26:13 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.renderscript;
18
19import android.util.Log;
20
21/**
22 * @hide
23 *
24 **/
25class BaseObj {
26
27 BaseObj(RenderScript rs) {
28 mRS = rs;
29 mID = 0;
30 }
31
32 public int getID() {
33 return mID;
34 }
35
36 int mID;
37 String mName;
38 RenderScript mRS;
39
40 public void setName(String s) throws IllegalStateException, IllegalArgumentException
41 {
42 if(s.length() < 1) {
43 throw new IllegalArgumentException("setName does not accept a zero length string.");
44 }
45 if(mName != null) {
46 throw new IllegalArgumentException("setName object already has a name.");
47 }
48
49 try {
50 byte[] bytes = s.getBytes("UTF-8");
51 mRS.nAssignName(mID, bytes);
52 mName = s;
53 } catch (java.io.UnsupportedEncodingException e) {
54 throw new RuntimeException(e);
55 }
56 }
57
58 protected void finalize() throws Throwable
59 {
60 if (mID != 0) {
61 Log.v(RenderScript.LOG_TAG,
62 "Element finalized without having released the RS reference.");
63 }
64 super.finalize();
65 }
66}
67