01: /* Copyright 2004 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.core;
07:
08: /**
09: * The object Ids factory.
10: * @author Michael Ivanov, mvi@immagic.com
11: * @version $Revision: 35166 $
12: */
13: public abstract class ObjectIdFactory {
14:
15: protected static class ObjectIdImpl implements IObjectId {
16:
17: protected String id;
18:
19: public ObjectIdImpl(String id) {
20: this .id = id;
21: }
22:
23: public ObjectIdImpl(int id) {
24: this (Integer.toString(id));
25: }
26:
27: public ObjectIdImpl(long id) {
28: this (Long.toString(id));
29: }
30:
31: public boolean equals(Object obj) {
32: return ((obj instanceof IObjectId) && id.equals(obj
33: .toString()));
34: }
35:
36: public String toString() {
37: return id;
38: }
39:
40: public int toInt() {
41: return Integer.parseInt(id);
42: }
43:
44: public long toLong() {
45: return Long.parseLong(id);
46: }
47:
48: }
49:
50: public static IObjectId createId(String id) {
51: return new ObjectIdImpl(id);
52: }
53:
54: public static IObjectId createId(int id) {
55: return new ObjectIdImpl(id);
56: }
57:
58: public static IObjectId createId(long id) {
59: return new ObjectIdImpl(id);
60: }
61: }
|