View Javadoc

1   /*
2   Copyright (C) 2008 Ondrej Par
3   
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as published by
6   the Free Software Foundation; either version 2.1 of the License, or
7   (at your option) any later version.
8   
9   This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  GNU Lesser General Public License for more details.
13  
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program; if not, write to the Free Software
16  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  
18  */
19  
20  package net.sf.jack4j;
21  
22  /**
23   * Represents Jack internal client (internal clients run inside Jack server).
24   * 
25   * <p>
26   * Instances of this
27   * 
28   * @author repa
29   * 
30   */
31  public class JackInternalClient {
32  
33  	static {
34  		JackBridge.initializeJackBridge();
35  	}
36  
37  	@SuppressWarnings("unused")
38  	private volatile long loadingClientHandle;
39  	private volatile long internalClientHandle;
40  
41  	JackInternalClient(long loadingClientHandle, long internalClientHandle) {
42  		this.loadingClientHandle = loadingClientHandle;
43  		this.internalClientHandle = internalClientHandle;
44  	}
45  
46  	/**
47  	 * Returns native handle of this Jack internal client, packed as long.
48  	 */
49  	public long getHandle() {
50  		return internalClientHandle;
51  	}
52  
53  	/**
54  	 * Returns internal client name.
55  	 */
56  	public native String getName();
57  
58  	/**
59  	 * Unloads this internal client.
60  	 */
61  	public native void unload() throws JackException;
62  
63  	/**
64  	 * @see java.lang.Object#hashCode()
65  	 */
66  	@Override
67  	public int hashCode() {
68  		final int prime = 31;
69  		int result = 1;
70  		result = prime * result + (int) (internalClientHandle ^ (internalClientHandle >>> 32));
71  		result = prime * result + (int) (loadingClientHandle ^ (loadingClientHandle >>> 32));
72  		return result;
73  	}
74  
75  	/**
76  	 * @see java.lang.Object#equals(java.lang.Object)
77  	 */
78  	@Override
79  	public boolean equals(Object obj) {
80  		if (this == obj) return true;
81  		if (obj == null) return false;
82  		if (getClass() != obj.getClass()) return false;
83  		final JackInternalClient other = (JackInternalClient) obj;
84  		if (internalClientHandle != other.internalClientHandle) return false;
85  		if (loadingClientHandle != other.loadingClientHandle) return false;
86  		return true;
87  	}
88  }