01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.data.store;
17:
18: /**
19: * A real class for naming feature collections, see generic name for the geoapi take.
20: * <p>
21: * Compare contrast with XPath utility class in ext/view. These may merge if TypeRef
22: * is reduced to an XPath expression in the future.
23: * </p>
24: * @author Jody Garnett, Refractions Research
25: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/data/store/TypeRef.java $
26: */
27: public class TypeRef {
28: private final String dataStoreId;
29: private final String typeName;
30:
31: public TypeRef(String dataStoreId, String typeName) {
32: this .dataStoreId = dataStoreId;
33: this .typeName = typeName;
34: }
35:
36: public TypeRef(String typeRef) {
37: int split = typeRef.indexOf('/');
38: if (split == -1) {
39: dataStoreId = null;
40: typeName = typeRef;
41: } else {
42: dataStoreId = typeRef.substring(0, split);
43: typeName = typeRef.substring(split + 1);
44: }
45: }
46:
47: static String parseDataStoreId(String typeRef) {
48: int split = typeRef.indexOf('/');
49: return split == -1 ? null : typeRef.substring(0, split);
50: }
51:
52: static String parseTypeName(String typeRef) {
53: int split = typeRef.indexOf('/');
54: return split == -1 ? typeRef : typeRef.substring(split + 1);
55: }
56:
57: static TypeRef parseTypeRef(String typeRef) {
58: return new TypeRef(typeRef);
59: }
60:
61: /** External representation of "dataStoreId/typeName" */
62: public String toString() {
63: return dataStoreId + "/" + typeName;
64: }
65:
66: /**
67: * @return Returns the dataStoreId.
68: */
69: public String getDataStoreId() {
70: return dataStoreId;
71: }
72:
73: /**
74: * @return Returns the typeName.
75: */
76: public String getTypeName() {
77: return typeName;
78: }
79: }
|