01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.common.utils.xml;
09:
10: //base classes
11:
12: //project specific classes
13:
14: //other classes
15:
16: public class LinearXPath {
17:
18: private String name = null;
19:
20: private LinearXPath(String inName) {
21: this .name = inName;
22: }
23:
24: public final static LinearXPath r(String inName) {
25:
26: return new LinearXPath(createNode(inName));
27: }
28:
29: public LinearXPath b(String inName) {
30: return b(inName, 1);
31: }
32:
33: public LinearXPath b(String inName, int inIndex) {
34: return new LinearXPath(this .toString()
35: + createNode(inName, inIndex));
36: }
37:
38: private final static String createNode(String inName) {
39: return createNode(inName, 1);
40: }
41:
42: private final static String createNode(String inName, int inIndex) {
43: return ("/" + inName + "[" + inIndex + "]");
44: }
45:
46: public String toString() {
47: return this .name;
48: }
49:
50: public int hashCode() {
51: return this .name.hashCode();
52: }
53:
54: public boolean equals(Object inObject) {
55: boolean outValue = false;
56:
57: if ((inObject != null) && (inObject instanceof LinearXPath)) {
58: LinearXPath xpath = (LinearXPath) inObject;
59: outValue = (this.toString().equals(xpath.toString()));
60: }
61:
62: return outValue;
63: }
64: }
|