1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.test.vcl.client;
25 
26 
27 /**
28  * ID of GUI controls may have two types: number or string.
29  * @deprecated From AOO3.4, all IDs should be string
30  */
31 public class SmartId {
32 
33 	private long id = 0;
34 
35 	private String sid = null;
36 
SmartId(long id)37 	public SmartId(long id) {
38 		super();
39 		this.id = id;
40 	}
41 
SmartId(String sid)42 	public SmartId(String sid) {
43 		super();
44 		this.sid = sid;
45 	}
46 
getId()47 	public long getId() {
48 		return id;
49 	}
50 
getSid()51 	public String getSid() {
52 		return sid;
53 	}
54 
toString()55 	public String toString() {
56 		if (sid == null)
57 			return Long.toString(id);
58 		else
59 			return sid;
60 	}
61 
hashCode()62 	public int hashCode() {
63 		if (sid == null)
64 			return new Long(id).hashCode();
65 		return sid.hashCode();
66 	}
67 
equals(Object o)68 	public boolean equals (Object o) {
69 		if (!(o instanceof SmartId))
70 			return false;
71 		SmartId id2 = (SmartId) o;
72 		return id2.id == this.id && ((this.sid == null && id2.sid == null) || (this.sid != null && this.sid.equals(id2.sid)));
73 	}
74 }
75