286N/A/*
286N/A * reserved comment block
286N/A * DO NOT REMOVE OR ALTER!
286N/A */
286N/A/*
286N/A * Copyright 1999-2004 The Apache Software Foundation.
286N/A *
286N/A * Licensed under the Apache License, Version 2.0 (the "License");
286N/A * you may not use this file except in compliance with the License.
286N/A * You may obtain a copy of the License at
286N/A *
286N/A * http://www.apache.org/licenses/LICENSE-2.0
286N/A *
286N/A * Unless required by applicable law or agreed to in writing, software
286N/A * distributed under the License is distributed on an "AS IS" BASIS,
286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
286N/A * See the License for the specific language governing permissions and
286N/A * limitations under the License.
286N/A */
286N/A/*
286N/A * $Id: ExtendedType.java,v 1.2.4.1 2005/09/15 08:15:06 suresh_emailid Exp $
286N/A */
286N/Apackage com.sun.org.apache.xml.internal.dtm.ref;
286N/A
286N/A/**
286N/A * The class ExtendedType represents an extended type object used by
286N/A * ExpandedNameTable.
286N/A */
286N/Apublic final class ExtendedType
286N/A{
286N/A private int nodetype;
286N/A private String namespace;
286N/A private String localName;
286N/A private int hash;
286N/A
286N/A /**
286N/A * Create an ExtendedType object from node type, namespace and local name.
286N/A * The hash code is calculated from the node type, namespace and local name.
286N/A *
286N/A * @param nodetype Type of the node
286N/A * @param namespace Namespace of the node
286N/A * @param localName Local name of the node
286N/A */
286N/A public ExtendedType (int nodetype, String namespace, String localName)
286N/A {
286N/A this.nodetype = nodetype;
286N/A this.namespace = namespace;
286N/A this.localName = localName;
286N/A this.hash = nodetype + namespace.hashCode() + localName.hashCode();
286N/A }
286N/A
286N/A /**
286N/A * Create an ExtendedType object from node type, namespace, local name
286N/A * and a given hash code.
286N/A *
286N/A * @param nodetype Type of the node
286N/A * @param namespace Namespace of the node
286N/A * @param localName Local name of the node
286N/A * @param hash The given hash code
286N/A */
286N/A public ExtendedType (int nodetype, String namespace, String localName, int hash)
286N/A {
286N/A this.nodetype = nodetype;
286N/A this.namespace = namespace;
286N/A this.localName = localName;
286N/A this.hash = hash;
286N/A }
286N/A
286N/A /**
286N/A * Redefine this ExtendedType object to represent a different extended type.
286N/A * This is intended to be used ONLY on the hashET object. Using it elsewhere
286N/A * will mess up existing hashtable entries!
286N/A */
286N/A protected void redefine(int nodetype, String namespace, String localName)
286N/A {
286N/A this.nodetype = nodetype;
286N/A this.namespace = namespace;
286N/A this.localName = localName;
286N/A this.hash = nodetype + namespace.hashCode() + localName.hashCode();
286N/A }
286N/A
286N/A /**
286N/A * Redefine this ExtendedType object to represent a different extended type.
286N/A * This is intended to be used ONLY on the hashET object. Using it elsewhere
286N/A * will mess up existing hashtable entries!
286N/A */
286N/A protected void redefine(int nodetype, String namespace, String localName, int hash)
286N/A {
286N/A this.nodetype = nodetype;
286N/A this.namespace = namespace;
286N/A this.localName = localName;
286N/A this.hash = hash;
286N/A }
286N/A
286N/A /**
286N/A * Override the hashCode() method in the Object class
286N/A */
286N/A public int hashCode()
286N/A {
286N/A return hash;
286N/A }
286N/A
286N/A /**
286N/A * Test if this ExtendedType object is equal to the given ExtendedType.
286N/A *
286N/A * @param other The other ExtendedType object to test for equality
286N/A * @return true if the two ExtendedType objects are equal.
286N/A */
286N/A public boolean equals(ExtendedType other)
286N/A {
286N/A try
286N/A {
286N/A return other.nodetype == this.nodetype &&
286N/A other.localName.equals(this.localName) &&
286N/A other.namespace.equals(this.namespace);
286N/A }
286N/A catch(NullPointerException e)
286N/A {
286N/A return false;
286N/A }
286N/A }
286N/A
286N/A /**
286N/A * Return the node type
286N/A */
286N/A public int getNodeType()
286N/A {
286N/A return nodetype;
286N/A }
286N/A
286N/A /**
286N/A * Return the local name
286N/A */
286N/A public String getLocalName()
286N/A {
286N/A return localName;
286N/A }
286N/A
286N/A /**
286N/A * Return the namespace
286N/A */
286N/A public String getNamespace()
286N/A {
286N/A return namespace;
286N/A }
286N/A
286N/A}