2 * Copyright (C) 2011 Openismus GmbH
4 * This file is part of GWT-Glom.
6 * GWT-Glom is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
11 * GWT-Glom is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with GWT-Glom. If not, see <http://www.gnu.org/licenses/>.
20 package org.glom.web.client.place;
22 import com.google.gwt.place.shared.PlaceTokenizer;
23 import com.google.gwt.place.shared.Prefix;
25 public class DetailsPlace extends HasSelectableTablePlace {
26 private String primaryKeyValue = "";
28 public DetailsPlace(String documentID, String tableName, String primarykey) {
29 super(documentID, tableName);
30 this.primaryKeyValue = primarykey;
33 public String getPrimaryKeyValue() {
34 return primaryKeyValue;
38 public static class Tokenizer extends HasSelectableTablePlace.Tokenizer implements PlaceTokenizer<DetailsPlace> {
40 private final String primaryKeyValueKey = "value=";
43 public String getToken(DetailsPlace place) {
44 return documentKey + place.getDocumentID() + seperator + tableKey + place.getTableName() + seperator
45 + primaryKeyValueKey + place.getPrimaryKeyValue();
49 public DetailsPlace getPlace(String token) {
50 String[] tokenArray = token.split(seperator);
52 if (tokenArray.length != 3)
53 return new DetailsPlace("", "", "");
55 String documentID = "", tableName = "", primaryKeyValue = "";
57 if (documentKey.equals(tokenArray[0].substring(0, documentKey.length()))) {
58 documentID = tokenArray[0].substring(documentKey.length());
61 if (tableKey.equals(tokenArray[1].substring(0, tableKey.length()))) {
62 tableName = tokenArray[1].substring(tableKey.length());
65 if (primaryKeyValueKey.equals(tokenArray[2].substring(0, primaryKeyValueKey.length()))) {
66 primaryKeyValue = tokenArray[2].substring(primaryKeyValueKey.length());
69 return new DetailsPlace(documentID, tableName, primaryKeyValue);