Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Item |
|
| 1.8571428571428572;1.857 |
1 | /* | |
2 | * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons-sandbox//xmlio/src/java/org/apache/commons/xmlio/in/Item.java,v 1.1 2004/10/08 11:56:20 ozeigermann Exp $ | |
3 | * $Revision: 155476 $ | |
4 | * $Date: 2005-02-26 13:31:24 +0000 (Sat, 26 Feb 2005) $ | |
5 | * | |
6 | * ==================================================================== | |
7 | * | |
8 | * Copyright 2004 The Apache Software Foundation | |
9 | * | |
10 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
11 | * you may not use this file except in compliance with the License. | |
12 | * You may obtain a copy of the License at | |
13 | * | |
14 | * http://www.apache.org/licenses/LICENSE-2.0 | |
15 | * | |
16 | * Unless required by applicable law or agreed to in writing, software | |
17 | * distributed under the License is distributed on an "AS IS" BASIS, | |
18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
19 | * See the License for the specific language governing permissions and | |
20 | * limitations under the License. | |
21 | * | |
22 | */ | |
23 | ||
24 | package org.apache.commons.xmlio.in; | |
25 | ||
26 | /** | |
27 | * Represntation of a path element. | |
28 | * | |
29 | */ | |
30 | public final class Item { | |
31 | ||
32 | 0 | public static final Item ITEM_ANY = null; |
33 | ||
34 | private final String namespaceURI; | |
35 | private final String name; | |
36 | ||
37 | public Item() { | |
38 | 0 | this(null, null); |
39 | 0 | } |
40 | public Item(String name) { | |
41 | 0 | this(name, null); |
42 | 0 | } |
43 | ||
44 | 0 | public Item(String name, String namespaceURI) { |
45 | 0 | this.namespaceURI = namespaceURI; |
46 | 0 | this.name = name; |
47 | 0 | } |
48 | ||
49 | public String getName() { | |
50 | 0 | return name; |
51 | } | |
52 | ||
53 | public String getNamespaceURI() { | |
54 | 0 | return namespaceURI; |
55 | } | |
56 | ||
57 | public boolean equals(Object o) { | |
58 | 0 | if (o == null) { |
59 | 0 | return true; |
60 | } | |
61 | 0 | if (!(o instanceof Item)) { |
62 | 0 | return false; |
63 | } | |
64 | 0 | Item token = (Item) o; |
65 | 0 | return ( |
66 | (token.name == null || this.name.equals(token.name)) | |
67 | && (this.namespaceURI == null | |
68 | || token.namespaceURI == null | |
69 | || this.namespaceURI.equals(token.namespaceURI))); | |
70 | ||
71 | } | |
72 | ||
73 | public String toString() { | |
74 | 0 | if (namespaceURI == null || namespaceURI.length() == 0) { |
75 | 0 | return name; |
76 | } else { | |
77 | 0 | return namespaceURI + ":" +name; |
78 | } | |
79 | } | |
80 | } |