01: /*
02: * Helma License Notice
03: *
04: * The contents of this file are subject to the Helma License
05: * Version 2.0 (the "License"). You may not use this file except in
06: * compliance with the License. A copy of the License is available at
07: * http://adele.helma.org/download/helma/license.txt
08: *
09: * Copyright 1998-2003 Helma Software. All Rights Reserved.
10: *
11: * $RCSfile$
12: * $Author: hannes $
13: * $Revision: 8621 $
14: * $Date: 2007-10-11 14:21:40 +0200 (Don, 11 Okt 2007) $
15: */
16:
17: package helma.objectmodel.db;
18:
19: import helma.util.StringUtils;
20:
21: /**
22: * This class describes a parent relation between releational nodes.
23: */
24: public class ParentInfo {
25: public final String propname;
26: public final String virtualname;
27: public final String collectionname;
28: public final boolean isroot;
29:
30: /**
31: * Creates a new ParentInfo object.
32: *
33: * @param desc a single parent info descriptor
34: */
35: public ParentInfo(String desc) {
36:
37: // [named] isn't used anymore, we just want to keep the parsing compatible.
38: int n = desc.indexOf("[named]");
39: desc = n > -1 ? desc.substring(0, n) : desc;
40:
41: String[] parts = StringUtils.split(desc, ".");
42:
43: propname = parts.length > 0 ? parts[0].trim() : null;
44: virtualname = parts.length > 1 ? parts[1].trim() : null;
45: collectionname = parts.length > 2 ? parts[2].trim() : null;
46:
47: isroot = "root".equalsIgnoreCase(propname);
48: }
49:
50: /**
51: * @return a string representation of the parent info
52: */
53: public String toString() {
54: StringBuffer b = new StringBuffer("ParentInfo[")
55: .append(propname);
56: if (virtualname != null)
57: b.append(".").append(virtualname);
58: if (collectionname != null)
59: b.append(".").append(collectionname);
60: return b.append("]").toString();
61: }
62: }
|