001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource;
034:
035: import java.io.Serializable;
036:
037: import java.util.StringTokenizer;
038:
039: /**
040: * LibreSource
041: *
042: * @author <a href="mailto:bort@loria.fr">Guillaume Bort</a> - <a
043: * href="http://www.inria.fr">INRIA Lorraine</a>
044: */
045: public class LibresourceResourceIdentifier implements Serializable {
046: private String service;
047: private String resourceType;
048: private String resourceId;
049:
050: public LibresourceResourceIdentifier(String service,
051: String resourceType, String resourceId) {
052: this .service = service;
053: this .resourceType = resourceType;
054: this .resourceId = resourceId;
055: }
056:
057: public String getResourceId() {
058: return resourceId;
059: }
060:
061: public String getResourceType() {
062: return resourceType;
063: }
064:
065: public String getService() {
066: return service;
067: }
068:
069: public static LibresourceResourceIdentifier deserialize(
070: String serializedResourceId) {
071: if (serializedResourceId == null) {
072: return null;
073: }
074:
075: StringTokenizer tokenizer = new StringTokenizer(
076: serializedResourceId, "/");
077:
078: return new LibresourceResourceIdentifier(tokenizer.nextToken(),
079: tokenizer.nextToken(), tokenizer.nextToken());
080: }
081:
082: public String serialize() {
083: return this .getService() + "/" + this .getResourceType() + "/"
084: + this .getResourceId();
085: }
086:
087: public String toString() {
088: return "Service:" + getService() + "; ResourceType:"
089: + getResourceType() + "; ResourceId:" + getResourceId();
090: }
091:
092: public boolean equals(Object o) {
093: LibresourceResourceIdentifier resourceIdentifier = (LibresourceResourceIdentifier) o;
094:
095: return getService().equals(resourceIdentifier.getService())
096: && getResourceType().equals(
097: resourceIdentifier.getResourceType())
098: && getResourceId().equals(
099: resourceIdentifier.getResourceId());
100: }
101: }
|