01: /*
02: ItsNat Java Web Application Framework
03: Copyright (C) 2007 Innowhere Software Services S.L., Spanish Company
04: Author: Jose Maria Arranz Santamaria
05:
06: This program is free software: you can redistribute it and/or modify
07: it under the terms of the GNU Affero General Public License as published by
08: the Free Software Foundation, either version 3 of the License, or
09: (at your option) any later version. See the GNU Affero General Public
10: License for more details. See the copy of the GNU Affero General Public License
11: included in this program. If not, see <http://www.gnu.org/licenses/>.
12: */
13:
14: package org.itsnat.impl.core;
15:
16: /**
17: *
18: * @author jmarranz
19: */
20: public class CachedNode {
21: protected MarkupTemplateVersionImpl template;
22: protected String id;
23: protected String code;
24: protected String markCode;
25:
26: public CachedNode(MarkupTemplateVersionImpl template, String code) {
27: this .template = template;
28: this .id = template.generateUniqueId();
29: this .code = code;
30: // Los ids NO deben de tener comas (,)
31: this .markCode = getMarkCodeStart() + "," + template.getId()
32: + "," + id + "}";
33: }
34:
35: public String getId() {
36: return id;
37: }
38:
39: public String getCode() {
40: return code;
41: }
42:
43: public static String getMarkCodeStart() {
44: return "${itsnat_cached_node";
45: }
46:
47: public static String getTemplateId(String mark) {
48: int start = getMarkCodeStart().length() + 1;
49: int last = mark.lastIndexOf(',');
50: return mark.substring(start, last);
51: }
52:
53: public static String getNodeId(String mark) {
54: int start = mark.lastIndexOf(',') + 1;
55: return mark.substring(start, mark.length() - 1);
56: }
57:
58: public String getMarkCode() {
59: return markCode;
60: }
61: }
|