001 /* 002 * $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 $ 003 * $Revision: 155476 $ 004 * $Date: 2005-02-26 13:31:24 +0000 (Sat, 26 Feb 2005) $ 005 * 006 * ==================================================================== 007 * 008 * Copyright 2004 The Apache Software Foundation 009 * 010 * Licensed under the Apache License, Version 2.0 (the "License"); 011 * you may not use this file except in compliance with the License. 012 * You may obtain a copy of the License at 013 * 014 * http://www.apache.org/licenses/LICENSE-2.0 015 * 016 * Unless required by applicable law or agreed to in writing, software 017 * distributed under the License is distributed on an "AS IS" BASIS, 018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 019 * See the License for the specific language governing permissions and 020 * limitations under the License. 021 * 022 */ 023 024 package org.apache.commons.xmlio.in; 025 026 /** 027 * Represntation of a path element. 028 * 029 */ 030 public final class Item { 031 032 public static final Item ITEM_ANY = null; 033 034 private final String namespaceURI; 035 private final String name; 036 037 public Item() { 038 this(null, null); 039 } 040 public Item(String name) { 041 this(name, null); 042 } 043 044 public Item(String name, String namespaceURI) { 045 this.namespaceURI = namespaceURI; 046 this.name = name; 047 } 048 049 public String getName() { 050 return name; 051 } 052 053 public String getNamespaceURI() { 054 return namespaceURI; 055 } 056 057 public boolean equals(Object o) { 058 if (o == null) { 059 return true; 060 } 061 if (!(o instanceof Item)) { 062 return false; 063 } 064 Item token = (Item) o; 065 return ( 066 (token.name == null || this.name.equals(token.name)) 067 && (this.namespaceURI == null 068 || token.namespaceURI == null 069 || this.namespaceURI.equals(token.namespaceURI))); 070 071 } 072 073 public String toString() { 074 if (namespaceURI == null || namespaceURI.length() == 0) { 075 return name; 076 } else { 077 return namespaceURI + ":" +name; 078 } 079 } 080 }