KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > tools > jbicommon > descriptor > PetalsExtensionsUris


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005-2006 EBM WebSourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id$
20  * -------------------------------------------------------------------------
21  */

22
23 package org.objectweb.petals.tools.jbicommon.descriptor;
24
25 import java.net.URI JavaDoc;
26 import java.net.URISyntaxException JavaDoc;
27
28 /**
29  * Constants for Petals extensions uris.
30  *
31  * @author ofabre
32  *
33  */

34 public enum PetalsExtensionsUris {
35     PETALS_EXTENSIONS("http://petals.objectweb.org/extensions/"),
36     PETALS_EXTENSION_KEY_VALUE(
37             "http://petals.objectweb.org/extensions/key-value/");
38
39     private final String JavaDoc nameSpace;
40
41     private PetalsExtensionsUris(String JavaDoc nameSpace) {
42         this.nameSpace = nameSpace;
43     }
44
45     /**
46      * Returns an URI matching the related {@link PetalsExtensionsUris}
47      *
48      * @return the URI linked to the related {@link PetalsExtensionsUris}
49      */

50     public URI JavaDoc value() {
51         URI JavaDoc extURI = null;
52         try {
53             extURI = new URI JavaDoc(nameSpace);
54         } catch (URISyntaxException JavaDoc e) {
55             throw new Error JavaDoc("Unexpected Error in JBI URI namespace syntax", e); // NOPMD
56
}
57         return extURI;
58     }
59
60     /**
61      * Returns a {@link PetalsExtensionsUris} matching the given URI pattern
62      *
63      * @param pattern
64      * the pattern to identify
65      * @return the {@link PetalsExtensionsUris} matching the given pattern or
66      * null.
67      */

68     public static PetalsExtensionsUris valueOf(final URI JavaDoc pattern) {
69         PetalsExtensionsUris result = null;
70         for (PetalsExtensionsUris extURI : PetalsExtensionsUris.values()) {
71             if (extURI.nameSpace.equals(pattern.toString())) {
72                 result = extURI;
73             }
74         }
75         return result;
76     }
77 }
78
Popular Tags